How to Load MicroPython on a Microcontroller Board

Pages
Contributors: Shawn Hymel
Favorited Favorite 4

OpenMV M7 Camera

The OpenMV is a development platform with an integrated camera that lets you create computer vision projects. Out of the box, it comes loaded with the MicroPython interpreter, so you don't need to load anything onto the M7 or H7.

OpenMV H7 Camera

OpenMV H7 Camera

SEN-15325
$65.00

Update Firmware

Heads up! This tutorial was written for the M7 but it applies to the H7 as well. We'll refer to the M7 in the following instructions.

OpenMV recommends that you use the OpenMV IDE to develop applications for the M7, which is probably a good thing, considering it allows you to make updates to your code while and watch a live camera feed. If you would like to update the firmware (which includes the MicroPython interpreter), it is recommended that you do so through the OpenMV IDE.

Head to the OpenMV Downloads page and click to download the IDE for your operating system. Install it, accepting all the default options. If you are on Windows, you will likely be asked to install one or more USB drivers.

Open the OpenMV IDE and connect the M7 to your computer. Click the Connect button in the bottom-left corner of the IDE to open a connection to your M7.

OpenMV IDE connect button

Make sure your computer is connected to the Internet, and if your M7's firmware is out of date, you'll get a pop-up asking you to update it. Click OK to automatically start the update process. If you don't want to save any files that you've stored on the M7, click Yes when asked about erasing the internal file system (otherwise, click No).

Once the flashing process is complete, you should see that the reported firmware (bottom right of the IDE) has been updated to reflect the most recent version (it should also say [ latest ]).

OpenMV IDE showing latest firmware version

Test It

By far the easiest way to begin developing on the M7 is to use the OpenMV IDE. When you first open it, you should see some example code (named helloworld_1.py). Click the Play button (bottom left of the IDE), and you should get a live video stream from the camera (don't forget to remove the lens cap!) along with real-time color histogram updates.

Live video feed from the OpenMV M7

If you don't want to use the OpenMV IDE, then there are a number of ways you can interact with the camera. The first is by opening up a file explorer/finder and browsing to the enumerated drive while the M7 is plugged in (likely called USB DRIVE). Here, you will find a few files that reside in the M7's flash memory. If you modify main.py, you can change the code that runs on the M7. When you save changes (overwriting the original main.py), the M7 will automatically restart and begin running the code in main.py.

Alternatively, you can open a serial connection to the M7 using your choice of serial terminal programs. Find the device port number or device file (for example, Device Manager in Windows might show something like COM8, macOS might show /dev/cu.usbserial-<some letters/numbers>, or Linux might show /dev/ttyUSB0). Open a connection with a baud rate of 115200, and press enter to see the MicroPython REPL command prompt (>>>).

Enter the following commands:

language:python
import pyb
led = pyb.LED(3)
led.on()

This should turn on the blue LED on the M7.

Testing MicroPython on the OpenMV M7

Enter the following command to turn the LED off:

language:python
led.off()

This should hopefully show you the various ways to interact with the MicroPython interpreter on the OpenMV M7! To learn more about how to use the M7, see OpenMV's documentation page located at docs.openmv.io.