Categories
Examples

MicroPython getting started Guide

MicroPython is getting hype these days, due to the most advanced microcontrollers and development boards are now supporting the MicroPython. Especially the MicroPython support for ESP8266 and MicroPython for ESP32 board and now the modern Raspberry Pi Pico board is also supporting the MicroPython. Originally the MicroPython was designed for Pyboard which was specially designed on STM32F4 devices to support the MicroPython. It was originally Australian programmer and physicist Damien George who run a Kickstarter campaign successfully in 2013. It gains its popularity nowadays due to the New Raspberry Pi Pico board supporting the MicroPython.

MicroPython has official documentation where you can check out the available libraries set and the getting started guide in detail. In this article, we will summarize the easiest getting started guide for MicroPython. If you are interested in more Raspberry Pi Pico beginners friendly projects, you may want to check out our previous article about the Basic Raspberry Pi Pico Project Ideas. Or You may be interested in looking at the Previous years top Raspberry Pi Pico Project’s List.

Brief Introduction to the MicroPython

MicroPython has a similar syntax to the Python3 so if you are already familiar with the Python3 syntax you are good to start with. If you have access to the Raspberry Pi 3 or the Raspberry Pi 4 you can directly program your Raspberry Pi Pico with the Raspberry Pi 3 or the Raspberry Pi 4. The best supported Ide for the MicroPython is Thonny Python IDE. Thonny is the best beginner’s friendly IDE for Python as well as MicroPython.

Unlike Python, MicroPython does not need any operating system to run onto. The MicroPython can directly run underneath the microcontroller bare-metal. So if you are planning to use the MicroPython on ESP8266 or to run MicroPython on ESP32 board or any other MicroPython supported board, you do not need to install any operating system on that microcontroller. Or You may need not worry that you need to install some Linux on the microcontroller just like you do install the Raspbian OS on the Raspberry Pi. So, all you need to do is to grab a binary image file from the official site download that binary file into your desired MicroPython supported board and you are good to go.

If you are using the Raspberry Pi Pico board, you may directly start programming it from the Thonny IDE as it comes with the MicroPython support out of the box.

Supported Libraries

Although the MicroPython does not come with fully functional libraries, just like the original Python3 comes with. So you can consider the MicroPython a mico version of the original Python3 without the batteries included. Although the above statement is not fully true, because, now the MicroPython has the support of numerous libraries, similar to the Original Libraries of Python 3 like “os, time, gc, ascii, json, collections, cmatch” etc. You may see the complete set of libraries from their official documentation.

Flashing MicroPython to ESP32 or ESP8266

If you want to use the MicroPython with the ESP32 or the ESP8266 module, you need to first grab the esptool which do the binary flashing for the ESP compatible devices. You can grab this file easily from the pip package manager if you have Python installed and configured into your Windows, Linux or Mac, whichever operating system you currently using.

pip install esptool

Or you can directly download from their GitHub link https://github.com/espressif/esptool/.

Once you have the esptool, all you need to do is to download the stable binary file from the MicroPython Official website and save it into a directory of your choice on your computer.

Erase the ESP32

The documentation suggests it is better to first erase the board using the following command

esptool.py --port COM1 erase_flashCode language: CSS (css)

Deploy the Firmware

The next step is to deploy the firmware you just downloaded and you can do this using the following command by replacing your respective serial port number and the file name

esptool.py --chip esp32 --port COM1 write_flash -z 0x1000 esp32-20180511-v1.9.4.binCode language: CSS (css)

By Abdul Rehman

My name is Abdul Rehman and I love to do Reasearch in Embedded Systems, Artificial Intelligence, Computer Vision and Engineering related fields. With 10+ years of experience in Research and Development field in Embedded systems I touched lot of technologies including Web development, and Mobile Application development. Now with the help of Social Presence, I like to share my knowledge and to document everything I learned and still learning.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.