How to Load MicroPython on a Microcontroller Board

Pages
Contributors: Shawn Hymel
Favorited Favorite 5

Pycom LoPy4

The Pycom LoPy4 is a combination of wireless radios (WiFi, Bluetooth, LoRa, SigFox) and a MicroPython development platform that helps users get started making their own Internet of Things (IoT) endpoints.

Pycom LoPy4 Development Board

WRL-14674
1 Retired
Note: The LoPy4 is capable of running MicroPython out of the box. If you would like to update the firmware on the LoPy4, see the instructions below.

Update Firmware

To load firmware onto the LoPy4, you will need to purchase a Pycom Expansion Board 3.0.

While it's not required, Pycom recommends that you update the firmware on the Expansion Board by following these steps.

With the Expansion Board disconnected from your computer, connect the LoPy4 to the expansion board, and then plug in a USB cable to the Expansion Board.

Pycom LoPy4 on an Expansion Board 3.0

Navigate to Pycom's Updating Firmware page and download the firmware tool for your operating system (links at the top of the page). Run the program and follow the instructions to install Pycom's firmware update tool.

Run the tool, and follow the on-screen instructions to connect to your LoPy4 board. Make sure that the serial port is selected correctly (leave the other options as default).

Updating the MicroPython firmware on the LoPy4

If you would like to use the Pybytes IoT platform, head to the Pybytes site, make an account, and copy in the activation key when asked. Otherwise, feel free to skip that step (the firmware will install regardless of whether you provided a Pybytes key or not).

Once the update is complete, you should see a "successfully updated" message.

Successfully updated firmware on the LoPy4

Test It

Download and install a serial terminal program of your choosing. If you are on Windows, open the Device Manager and find out which COM port your LoPy4 is associated with (mine is COM34). On macOS, it will likely be /dev/cu.usbserial-<some letters/numbers>, and on Linux, it's probably something like /dev/ttyUSB0.

Open up your serial terminal program, and connect to your LoPy4 using the associated serial port and a baud rate of 115200. Press the enter key, and you should be presented with the MicroPython REPL command prompt (>>>). Enter the following commands:

language:python
import pycom
pycom.heartbeat(False)
pycom.rgbled(0x0000FF)

This should turn the onboard LED to blue.

MicroPython on the Pycom LoPy4

Enter the following command to turn it off:

language:python
pycom.rgbled(0x000000)

If you were able to turn the LED on and off, it means that MicroPython is running on your Pycom board! Pycom also makes a plugin named Pymakr for the Atom and Visual Studio Code IDEs that you can use to develop MicroPython for the LoPy4 (and other Pycom boards). To learn more about Pymakr, see this page. Pycom has a MicroPython example for Pymakr that you can see here to help you get started.