MicroPython with Arduino Boards

Last updated on October 3rd, 2023

MicroPython is a microcontroller-optimized version of the Python programming language that includes a portion of the Python standard library. Utilizing MicroPython offers several benefits, including being simple to learn and having excellent documentation for a variety of boards. There are now four boards that work with MicroPython; you can learn more about them in the section on compatible boards.

MicroPython’s OpenMV branch is officially supported by Arduino, and you may install MicroPython, connect and disconnect your board, and upload your scripts using the OpenMV IDE. Learn how to set up your environment, how to utilize the famous Python programming language with Arduino boards, and get in-depth tutorials and helpful resources.

MicroPython is officially supported on Arduino boards

The Arduino programming language, which is based on C++, and MicroPython are significantly different from each other in terms of how we program an Arduino board. When we upload a “sketch” to a board, we first compile the sketch we write before uploading it to the board and replace the previous drawing with the new one.

Installing MicroPython on the board is the first step before using it. We may then load a script.py

Like the following blink example:

import time
led = Pin(6, Pin.OUT)
while (True):
led.on()
time.sleep_ms(250)
led.off()
time.sleep_ms(250)

We simply need to supply the instructions because MicroPython is already running on the board; we don’t need to compile and upload the code (which is done via serial communication).

  1. MicroPython can only execute MicroPython programs after being installed on a board until it is “uninstalled.
  2. MicroPython can only execute the MicroPython program after being installed on a board until it is “uninstalled. 
  3. Resetting the bootloader, which is a specific procedure for each board, is required to return the board to “normal mode.” 
  4. The compatible board’s portion of this article contains these instructions. In essence, you need to bootload the board and upload any.ino sketch.

OpenMV Editor

Python is not currently supported by the Arduino IDE. So we use OpenMV, a framework that enables MicroPython programming on Arduino boards. We can set up MicroPython and upload scripts straight to the board using the OpenMV editor. Numerous examples are also provided right in the editor.

OpenMV Editor

OpenMV Examples

Compatible Boards

MicroPython is now officially supported by four Arduino boards. All of the following are compatible with OpenMV IDE. Here is a list of them:

Nano 33 BLE

Double-tap the reset button quickly to reset the bootloader on the Nano 33 BLE board. This will return your board to its original factory settings. If you’ve used an Arduino Nano in the past, the Nano 33 BLE is a pin-equivalent replacement. Your code will still function, but keep in mind that it works at 3.3V. This implies you’ll have to alter your original design if it’s not 3.3V compliant. Aside from that, the key differences between the Nano and the original are a faster processor, a micro-USB port, and a 9-axis IMU.

Nano 33 BLE Sense

The Arduino Nano 33 BLE Sense is an upgrade of the standard Arduino Nano, but with a much more powerful processor, the Nordic Semiconductors nRF52840, a 32-bit ARM® Cortex®-M4 CPU running at 64 MHz. This allows you to create far larger programs than with the Arduino Uno (it has 1MB of program memory, which is 32 times greater) and with far more variables (the RAM is 128 times bigger). Other remarkable features of the main processor include Bluetooth® connection through NFC and super low power consumption modes.

Nano RP2040 Connect

The Nano RP2040 Connect is a little board, but it packs a substantial punch. It is compatible with the well-known Arduino Nano form factor, making it an ideal update for projects of various sizes. You may program and control the Nano RP2040 Connect using your web browser. From the start, everything is fully compatible. Upload your sketches over the air and control them instantly using the free Arduino IoT Remote smartphone app.

Portenta H7

Portenta H7 executes both high-level code and real-time operations at the same time. The architecture incorporates two processors that can perform tasks concurrently. It is feasible, for example, to run Arduino-compiled code alongside MicroPython code and have both cores interact with one another. Portenta has two modes of operation: it may serve as an embedded microcontroller board or as the main processor of an embedded computer.

Conclusion

Python is not yet supported by the Arduino IDE. We can instead use OpenMV, a platform that allows us to program Arduino boards with MicroPython. We can install MicroPython and upload scripts directly to the board using the OpenMV editor.

Leave a Reply

Your email address will not be published. Required fields are marked *