The C programming language has been the dominant language when developing software for a microcontroller. The language is well suited for the low-level hardware control that is necessary when developing an embedded system. There have been other programming languages such as C++ and Java that have found their niche within the industry but even when using these languages there is still the need to understand the low level hardware. The popularity of the Raspberry Pi and the use of Python has always been an interesting avenue for development but that doesn’t directly transition over to microcontroller work … at least not until recently.
Figure 1 – The PyBoard running MicroPython
Within the last few years an organization started by Damien George began to port Python to the STM32F4. The result was the creation of what is now known as MicroPython. MicroPython, as one might guess, is Python for microcontrollers! MicroPython includes a set of libraries known as the pyb library that provides access to peripherals such as ADC, UART, I2C and GPIO all from within the confines of a Python script or terminal. The MicroPython organization created a development board known as the PyBoard, which contains the first releases of MicroPython.
At first glance the use of MicroPython might seem to be very niche and not well suited for production intent devices. The fact of the matter is that entirely depends on the type of product that is being developed. The MicroPython source is available on GitHub and can easily be ported to other microcontrollers or on custom STM32 hardware. Even beyond the customized hardware, there are plenty of applications within the industrial space or even within small satellite space systems for the use Python on a microcontroller.
MicroPython can also be used for rapid prototyping. The PyBoard uses an STM32 ARM Cortex-M4 microcontroller with many of the peripheral drivers already in place. Using the PyBoard to connect to sensors and other devices for proof of concept work makes lots of sense. Rather than write low level C code to get a sensor or device up and running just write a simple MicroPython script with terminal output and glean insights at a rate that previously would not have been possible.
MicroPython isn’t going to replace C or the way most production systems are developed; However, it does offer a unique niche for rapid prototyping within the microcontroller space that until now just wasn’t previously available.
To learn more about the PyBoard check-out http://micropython.org/
To take a self-paced MicroPython course with over 4 hours of video tutorials and 4 hours of lab exercises visit http://beningo.com/real-time-software-using-micro-python-the-basics/