Learn how the Raspberry Pi and Python combine to make it easy and inexpensive for makers to develop products.
Makers are familiar with Python being the core programming language for the Raspberry Pi and a variety of embedded development platforms. Raspberry Pi has been the dominant embedded platform using the Python programming language. There are a wealth of online projects and technical books that illustrate the ease and computing complexity of the Raspberry Pi and the Python language. These resources allow makers and embedded developers the benefit of developing simple to advanced products using an open-source programming language and a low-cost SBC (single board computer).
Now, there is MicroPython for the pyboard. MicroPython and the pyboard were developed by Dr. Damien George. The pyboard, like the Raspberry Pi, provides Python 3 programming language on a smaller development board. The core microcontroller is the ST32F405RGT6 32-bit device manufactured by STMicroelectronics. In this article, I'll explore the pyboard’s architecture and the MicroPython programming language by way of an LED flasher project.
The Pyboard Architecture
The pyboard is a 33mm x 43mm x 4mm PCB (printed circuit board) powered by a 32-bit microcontroller. The weight of the tiny development platform is 6g. The tiny microcontroller PCB provides an ample supply of GPIO (general-purpose input/output) pins and ADC (analog-to-digital converter) channels for developing a variety of embedded controller applications. The embedded platform has two board versions: a pyboard and a pyboard lite. A STM32F405RG microcontroller powers the standard pyboard, whereas a STM32F4R11E drives the lite PCB version.
The pyboard lite design has a 1-channel ADC that is multiplexed into 16 bits operating at 96MHz. 512KB of flash and 128KB of RAM (Random Access Memory) provide the memory capacity for the pyboard lite architecture. The standard pyboard provides 3 channels of ADC per 12 bits and 1MB of flash memory supported by 192KB of RAM. A 2x12-bit DAC (digital-to-analog converter) is packaged with the pyboard as well.
I selected the pyboard lite because of the low cost, the high GPIO pin count, the ADC channel, and the flash and RAM memory capacity. This board is sufficient for embedded labs development of my electrical system technology courses at the college. Also, the pyboard lite allows adequate exploration for the hands-on project of this blog post.
MicroPython is a software rewrite of the Python 3.4 programming language. The rewrite of Python 3.4 allows MicroPython to install and run properly on the STM32F411E/405RG microcontrollers. The MicroPython executes bare metal on the pyboard to run a Python operating system on it. Bare metal refers to MicroPython supporting the functional role of the OS (operating system) for the STM32F microcontroller. Whereas the Raspberry Pi requires a Linux OS image to be loaded onto the microSD card for proper operation, the pyboard doesn’t, because of the bare-metal OS concept.
MicroPython provides functions and classes built into the pyb module that controls the microcontroller-supporting peripherals, such as the UART (universal asynchronous receiver transmitter), I2C (inter-integrated circuit) communications, SPI (serial peripheral interface), ADC, and DAC.
Python is an interpretative programming language that allows each line of instruction to be executed, and results immediately observe either on the IDLE (integrated development) window or with an attached physical electrical or electronic load. REPL allows the developer to interact with code. In this interactive operation, MicroPython functions like Python. Therefore, this interactive interpreter mode is called REPL. REPL appears automatically on the developer’s machine screen with absence of a microSD card. In this developer’s mode, the MicoPython code concepts can be evaluated immediately by using REPL.
In our next post, we'll make an LED flasher project using MicroPython and pyboard.