Introduction to MicroPython – Python for Microcontrollers

Wish to start programming your microcontrollers and start on your own home automation project? Perhaps even build your own smart robot! With Micropython, you can do just that and many more other projects!

Through this Micropython guide, you will learn all about Micropython from:

  • What is Micropython?
  • What do you use Micropython for?
  • Why use Micropython?
  • Micropython Enabled Development boards
  • Getting started with Micropython

What is Micropython

Basically, Micropython is a lean and efficient implementation of the Python programming language. It is tiny and open source that runs on small embedded development boards which are your microcontrollers!

Micropython allows you to write clean and simple Python code to control your boards instead of using other more complicated languages like C++.

If you new to the world of coding and programming the Micropython would be perfect for you as they are more simplified and accessible compared to other programming languages while having enough power for industrial uses. Packed full of advanced features such as an interactive prompt, arbitrary precision integers, closures, list comprehension, generators, exception handling, Micropython remains compact enough to fit and run within just 256k of code space and 16k of RAM.

Using Python? No worries as Micropython supports most of Python syntax which frequent users of Python will find familiar.

Python vs Micropython

If you are wondering what are their differences, the main difference is that Micropython has a smaller standard library (Micropython only has a small subset of the Python standard library) compared to Python and are designed to work under constrained conditions.

However, Micropython allows modules to access low-level hardware. (eg. libraries to easily access and interact with GPIOs).


What do you use Micropython for?

Similar to other programming langauges, you can use Micropython for almost anything!

You can program a smart home system, run motors, control robots, control displays and many more! Want to talk to I2C and SPI devices? You can do that too!

Here is a video demo of what Micropython can do! Here, a maker used Micropython to program a micro:bit to make it talk!

Ref: Anish Ansari

Want to try it out for yourself? You can try out a live Micropython Pyboard simulator here!

Limitations

When using Micropython, there are very few limitations that you have to worry about.

However, do note that Micropython code aren’t as fast and uses a little more memory when compared to other programming languages like C++.

Due to this, coes which has tight timing or performance requirements might not work in Micropython. For example, “bit banging” which is a fast serial protocol can’t work in Micropython. Despite sharing similarities with Python 3 language, it is not entirely the same as Python has an extensive standard library while Micropython runs on tiny boards with only kilobytes of memory.


Why use Micropython?

Compared to other programming languages, why use Micropython you may ask with all those limitations listed above. Well despite its limitations, Micropython actually has alot to offer. Lets look at some of them:

Perfect for beginners

As said above, with Micropython simplicity, they are an excellent choice for beginners who want to pick up programming and coding. They are easy to learn, with a few days or maybe even hours to learn the basics, you can move on to programming your microcontroller. Not to mention, if you’ve already used Python before, you can easily transit to Micropython with minimal challenges!

Rapid Feedback

Micropython also allow for rapid feedback. It has a interactive REPL (read-evaluate-print-loop) where you can interactively enter commands and get a response using the REPL = no need for compiling or uploading when executing your code = quick learning and experimenting! Compared to iterating your code through code-compile-upload-execute, this is much faster.

Extensive software library

Micropython has libraries built in to support many tasks. With built in libraries for parsing JSON data from a web service, string handling, network socket programming and many more, things are so much easier!

Extensive

Lastly, Micropython is also extensible with low-level C/ C++ functions where you can mix both of them together and have the best of both worlds. This can be done by having your main logic in clean and easy to understand Micropython code together with performance critical parts written in faster low-level code.


Micropython Enabled Development boards

Interested in Micropython and wish to use it? Good news! There are many boards that support micropython like the:

If you are looking for a Micropython board to get started with, Seeed got you covered! Here are a few of our favourite Micropython boards:

Wio Terminal: ATSAMD51 Core with Realtek RTL8720DN BLE 5.0 & Wi-Fi 2.4G/5G Dev Board

Wio Terminal: ATSAMD51 Core with Realtek RTL8720DN BLE 5.0 & Wi-Fi 2.4G/5G Dev Board

Compatible with Arduino and Micropython, Wio Terminal is an ATSAMD51-based microcontroller with wireless connectivity supported by Realtek RTL8720DN. Its CPU speed runs at 120MHz (Boost up to 200MHz). 

Realtek RTL8720DN chip supports both Bluetooth and Wi-Fi providing the backbone for IoT projects. The Wio Terminal itself is equipped with a 2.4” LCD Screen, onboard IMU(LIS3DHTR), microphone, buzzer, microSD card slot, light sensor, and infrared emitter(IR 940nm). On top of that, it also has two multifunctional Grove ports for Grove Ecosystem and Raspberry pi 40-pin compatible GPIO for more add-ons.

Wio Terminal supports ArduPy. But what is ArduPy?

ArduPy is a combination of Arduino and MicroPython. MicroPython uses the universal Arduino API to control the hardware so that it can be compatible with new platforms quickly. With the help of the AIP package manager we provided, you can transform your favorite Arduino library into a MicroPython library. Through ArduPy, you can use Python to verify your ideas, learn python programming as well as micro-controller programming in a more efficient way.

ArduPy consists of two parts, one is the ArduPy Core, and the other part is the Arduino Library Python wrapper.

ArduPy Core is Pyboard-friendly and supports basic hardware operations on the board. We wish to develop the ArduPy into a community-driven software and look forward to your participation. If you want to integrate more useful libraries, please feel free to contact us at Github.

Pycom LoPy4 MicroPython enabled development board (LoRa, Sigfox, WiFi, Bluetooth)

The LoPy4 is a compact quadruple network MicroPython enabled development board (LoRa, Sigfox, WiFi, Bluetooth). It’s the perfect enterprise grade IoT platform for your connected Things. With the latest Espressif ESP32 chipset the LoPy4 offers a perfect combination of power, friendliness and flexibility.

The LoPy4 can also act as a LoRa nano gateway and a multi-bearer (LoRa, Sigfox, WiFi and BLE) development platform suitable for all LoRa and Sigfox networks around the globe.

It is programmable with MicroPython and the Pymakr plugins for fast IoT application development, easy programming in-field and extra resilience with network failover. You can also configure the LoPy4 in raw LoRa mode to send packets directly between LoPy4’s. The best blend of speed to deployment and access to new LPWAN networks rolling out across Europe, USA, Africa and India. The LoPy4 is CE, FCC approved, LoRaWAN and Sigfox certified.

WiPy 2.0

WiPy 2.0, it is a tiny Micro Python enabled WiFi & Bluetooth IoT development platform. With a 1KM WiFi range, state of the art Espressif ESP32 chipset and dual processor, the WiPy is all about taking the Internet of Things to the next level.

It fits in a standard breadboard with headers with a ultra-low power usage. (a fraction compared to other microcontrollers. It features an extra ULP-coprocessor that can monitor GPIOs, the ADC channels and control most of the internal peripherals during deep-sleep mode while only consuming 25uA. Not to mention its main processor is entirely free to run the user application.

Looking for other development boards or sensor shields that support Micropython? We have them too! Check them all out here!


Getting started with Micropython

So you have decided to use Micropython, where do you learn more about Micropython and also get help from? Here a few resources and links to help you out!

Learning

Help

Tutorials

Please follow and like us:

Calendar

March 2020
M T W T F S S
« Feb   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
Wordpress Social Share Plugin powered by Ultimatelysocial