As Python became the dominant programming language, MicroPython became increasingly popular in the embedded systems space, especially in the popular ESP32 and the RP2040 microcontroller-based Pico module just released by the Raspberry PI Foundation.
As a bannon who could not write a line of code, I felt very limited in most of the time, and vowed to find a good time to learn a programming language. I devoted myself to MicroPython during the 7-day National Day holiday, and realized all the functions of peripherals on the board on the Pico extension learning board designed by myself:
Fancy lighting - monochrome, RGB three colors, all kinds of combinations, can also be controlled by buttons and sensors
The OLED screen displays text, images and waveforms
The audio signal is collected and displayed on the OLED screen - making a cool waveform display
Playing "Me and my Country" with the buzzer on the board
Porting someone else's code to generate arbitrary waveforms - changing waveforms, changing frequency, changing magnitude, etc
What IMPRESSED me most during the 7-day "exploration" was how easy it was to get started with embedded systems in MicroPython - rich open source resources, various forms of reference, such as video courses, text cases, etc.
MicroPython is really a great programming language - object-oriented, flexible, simple, elegant!
My personal learning benefits from others' sharing (open source), and the best way to pass knowledge is to share what I have learned and what I have learned. Therefore, I plan to launch a Micro Python embedded programming tutorial based on Pico, which will be officially launched in a month. Of course, In the early stage, there will be 15 PCB design live courses, which will lead you to design a Pico learning board by yourself. After all, in the convenient environment of free printing board and free shipping, based on a Pico core board, everyone can design PCB to make various interesting applications in the future. Learning how to design a PCB can also be an advantage for embedded systems engineers.
From now on, there will be a series of technical articles related to this course. Today is the first one:
1. What is MicroPython
MicroPython is a small open source Python programming language interpreter that runs on a small embedded development board. With MicroPython, you can write clean, simple Python code to control the hardware without having to use complex underlying languages such as C or C ++ (Arduino for programming).
The simplicity of the Python programming language makes MicroPython an ideal choice for beginners in programming and hardware. MicroPython is very full-featured and supports most Python syntax, so even experienced Python veterans will find using MicroPython familiar and fun.
In addition to being easy to use, MicroPython has some unique features that set it apart from other embedded systems:
Use interactive interpreter: REPL (Read Read- Evaluate Evaluate- Print Print- Loop Loop) - this allows you to connect to a board and have it execute code without compiling or uploading - perfect for fast learning and experimenting with hardware!
Rich Software Libraries - Like the regular Python programming language, MicroPython has a large number of libraries built in to support many tasks. For example, through MicroPython's built-in libraries, it is easy to parse JSON data from Web services, search text using regular expressions, and even do network socket programming.
Extensibility - For advanced users, MicroPython can be extended with low-level C/C++ functions, so you can mix expressive high-level MicroPython code with faster low-level code when needed.
MicroPython is a variant of the Python 3 language. It is the brainchild of Darrien P. George, Ph.D., of The University of Cambridge, who worked with a crowdfunding team to develop a microPython-enabled hardware development board called PyBoard in 2013. MicroPython1.0 was presented at Python conference (PyCon) in 2014. Dr. George also set up the Micro Python.org website (www.micropython.org) to support MicroPython and Pyboard.
The official MicroPython.Org Logo
MicroPython.Org PyBoard, based on the STM32 controller.
2. What can MicroPython do?
MicroPython is designed to create embedded system control programs quickly and efficiently. Embedded systems can simply be defined as any project that requires the use of microcontrollers to meet engineering needs. Typical embedded systems typically use sensors and sometimes electromechanical actuators to interface with microcontrollers. They may be attached to human-machine interface devices for easy interaction, but are more automated, for stand-alone operation or remote access to the cloud.
Just like Arduino boards, MicroPython can control hardware and connected devices -- you can control GPIO pin flashing lights, read switches and more; Can drive the PWM signal that can drive the server and LED; Analog sensors can be read and read via an analog-to-digital converter. It is also easy to communicate with I2C or SPI devices. You can even find network and WiFi support on some boards. MicroPython even has libraries for controlling other hardware, such as NeoPixels and LED strips, miniature OLED displays, and so on. In short, MicroPython can do a lot of things!
What are the limitations of MicroPython?
MicroPython has very few limitations, and almost anything Arduino can do can be done via MicroPython boards. However, it is important to note that MicroPython code is not as fast and may require more memory than similar Arduino or other C/C++ based low-level code, although this usually does not matter because the speed and memory differences are not large enough to affect most applications. Be aware that code that is time or performance critical may not work in MicroPython. For example, using software entirely to drive IO pins to implement some high-speed serial communication protocols in MicroPython may not be the best idea. However, there are ways to mix MicroPython and low-level C/C++ code so that we can have the best of both worlds - the main logic is clean and easy-to-understand MicroPython code, while the performance-critical parts are written in faster low-level code.
The MicroPython language implements most of the core Python 3 language, but MicroPython does not implement the entire Python 3 standard library. Python is known for having an extensive standard library, but trying to compress such a large library onto a small board with only kilobytes of memory is impossible. Instead, MicroPython implements some smaller versions of the Python standard library, providing a great development experience.
Disclaimer: This article is reprinted from "electronic forest", this article only represents the author's personal views, does not represent the views of Sakwei and the industry, only reproduced and shared, support the protection of intellectual property rights, please indicate the original source and author, if there is infringement, please contact us to delete.