DEV Community

Cover image for What is Micropython????
Ndukwu Pius Onyema
Ndukwu Pius Onyema

Posted on • Updated on

What is Micropython????

Finding how to task my python skills with hardware has not been easy, because I had only microcontrollers. The issue with using a microcontroller to run python is its limited memory to run python, the only viable option was to get a raspberry pi, but the cost of getting a computer like raspberry pi was way out of my league, but luckily for me, I heard a guy named Damien George created a new version of python that can run on very little memory and is great for microcontrollers.

Why Micropython?
  • Easy to learn: Python,itself is an easy language to learn, so micropython will not be an exception. Compared to the conventional c++ used for microcontrollers, micropython is easier to write. For example to toggle an led in C++ Arduino ,the code should look something like this
const int LED_PIN=2;
const int BUTTON_PIN;
int ledState=HIGH;
void setup(){

void loop(){

// if button was pressed
delay(500); // wait for half a sec
Enter fullscreen mode Exit fullscreen mode

But for micropython it is a simple as this

// this example is for a pyboard
import pyb
button = pyb.Switch()

while true:
Enter fullscreen mode Exit fullscreen mode

Yes it that simple

Also when it comes to quoting long strings micro python is way easier.
let assume this is our text

hjdbkhfknbjkHBKDVDdkdbkbdkbkjkjBJBKDBjkbdkhdbKDBJDBJKFBJDBkjbdkbfjkbJKBJKBbkbfkBFJKBDJBJdbbdjbnLUkegkdbfkbKD,N kdkdkjd KHDHDVNM hhJHbkeBK VDJKvj dljkdbjbbJbhdkavKBFKAdhbkjbfuhfKJBFJBfkBJKDBKbkjkbjBHBDKdhkndjagdfkjadhdbfkhjbdkhfvhvakhbidghfbkbadbjbafhjbvhvhfbkhabahdgyetkfrhfiabfhfkjksbkjf

To quote this in C++ i will have to quote each line, like this

"UkegkdbfkbKD,N kdkdkjd KHDHDVNM hJH bkBK VDJKvj" 
Enter fullscreen mode Exit fullscreen mode

But for micropython i just have to "triple quote"

kegkdbfkbKD,N kdkdkjd KHDHDVNM hhJHbkeBK VDJKvj        dljkdbjbbJbhdkavKBFKAdhbkjbfuhfKJBFJBfkBJKDBKbkjkb   jBHBDKdhkndjagdfkjadhdbfkhjbdkhfvhvakhbidghfbkbadb     
Enter fullscreen mode Exit fullscreen mode

if you are interested in learning micropython, you can visit there are documentations for the most common micro python boards. The most common and cheapest boards that can handle micropython in Nigeria are the ESP8266 12E and ESP32 boards.
To learn more about ESP8266 with micro-python click here

To learn more about ESP32 with micro-python click here

Note: Although micro-python is very easy to write, I would not recommend in for beginners because it is still a new language and doesn't have a lot of resources to help beginners unlike arduino that has been around for a long time, beginner friendly and has unlimited resources to help both pro's and beginners. In arduino there is a library for almost anything you can think of. so for newbies in the embedded system world I would advice you start with arduino.

If you are a Nigerian and you are interested with learning micropython you can buy the ESP8266 board here
or the ESP32 here

Thanks for reading.

Top comments (0)