
MicroPython vs CircuitPython | What is MicroPython and CircuitPython?
22 September 2023In this article, we’ll talk about MicroPython vs CircuitPython and What is MicroPython and CircuitPython, two options for programming microcontroller boards. These are popular choices for developers working on IoT (Internet of Things) or embedded projects. CircuitPython, developed by Adafruit Industries, is a programming language designed to make it simpler for people to experiment and learn programming on affordable microcontroller boards.
Have you ever wished to use Python to program your microcontrollers instead of Arduino? Well, MicroPython and CircuitPython make it possible by adding hardware support! In MicroPython, Python remains mostly the same, but it gains the capability to work with hardware. CircuitPython is a variation of MicroPython that makes some adjustments to make the language more accessible for learning and use. Adafruit develops and maintains it, and it serves as a beginner-friendly, open-source version of MicroPython. CircuitPython is compatible with Adafruit’s educational development boards.
What is MicroPython?
MicroPython is like a special version of the Python programming language made to work on small microcontroller devices. These devices are like tiny computers that do specific tasks. Damien George from Australia created it after a successful crowdfunding campaign in 2013.
MicroPython lets you write and run Python code on these tiny devices. It’s quite powerful, even though it doesn’t take up much space in memory. You can use it to do all sorts of things, like connecting to the device and running code without needing to go through a complicated process of compiling and uploading. This is handy for learning and experimenting with hardware quickly.
MicroPython also comes with lots of useful features, just like regular Python. It has a library of pre-made code for different tasks, such as working with web data, searching text, or doing network stuff. This makes it easier to get things done without writing everything from scratch.
And if you’re a more advanced user, you can even mix in some low-level code written in C or C++ to make things work even faster when you need it.
The goal of MicroPython is to be as compatible as possible with regular Python, so you can easily transfer your code from a regular computer to a tiny microcontroller or embedded system. It’s a versatile tool for working with small devices.
CircuitPython adds hardware support to all of these amazing features. If you already have Python knowledge, you can easily apply that to using CircuitPython. If you have no previous experience, it’s really simple to get started!
Here is the MicroPython code to blink the onboard LED in Raspberry Pi Pico:
from machine import Pin import time #initialize pin connected to onboard LED as output.led = Pin("LED", Pin.OUT) while True: led.low() time.sleep(1) led.high() time.sleep(1)
What is CircuitPython?
CircuitPython is a special version of the Python programming language made just for tiny computers called microcontrollers.It resembles another similar language called MicroPython, which Adafruit Industries introduced in 2017, and it has gained popularity among people who enjoy building things. It represents a specialized computer language designed to simplify the process of playing and learning about programming on small and affordable mini-computers.
You can use CircuitPython on little boards like Circuit Playground Express, Trinket M0, Gemma M0, and more. These boards are great for experimenting with electronics.
Now, why we use CircuitPython?
- Easy Updates: You can change your code anytime. It’s like editing a document. You can even keep different versions of your code for testing.
- Live Feedback: You can talk to your board and get answers from it while your code runs. It’s like having a conversation with your mini-computer.
- File Storage: CircuitPython can save and use files, which is handy for things like recording data or playing sound.
- Lots of Hardware Support: There are many extra tools and add-ons for CircuitPython that help you connect sensors and other cool stuff to your mini-computer.
- It’s Python: Python is a popular programming language, and CircuitPython is almost like regular Python, but it also knows how to work with hardware.
So, if you want to have fun and learn while tinkering with small computers, CircuitPython is a great choice. It’s like having a friendly guide to help you explore the world of programming and electronics.
CircuitPython code to blink an LED continuously. Its syntax has some differences from MicroPython.
import time import board import digitalio #initialize pin connected to onboardLED as output. led = digitalio.DigitalInOut(board.LED) led.direction = digitalio.Direction.OUTPUT while True: led.value = 1 time.sleep(1) led.value = 0 time.sleep(1)
MicroPython vs CircuitPython
CircuitPython and MicroPython both utilize the Python programming language but have adjustments for hardware integration. They share similarities, but the primary distinction lies in CircuitPython, which Adafruit customizes for their boards, primarily crafted for educators and beginners. MicroPython, on the other hand, is for a broader range of boards. Both CircuitPython and MicroPython are specialized versions of the Python programming language tailored for working with hardware. While they share many similarities, there is a significant distinction between them. Adafruit developed CircuitPython specifically to support their brand of boards, which they designed with educators and beginners in mind. In contrast, MicroPython is more versatile and caters to a broader range of microcontroller boards.
Here are some key differences:
- Board Support: CircuitPython focuses on supporting Adafruit’s specific boards. This optimization makes it an excellent choice for users of Adafruit products, while MicroPython is designed to function with a broader spectrum of microcontroller boards.
- Origin and Focus: CircuitPython is essentially an offshoot of MicroPython, but it places a strong emphasis on compatibility with Adafruit’s boards. Manufacturers carefully craft these boards to be user-friendly for newcomers to electronics and programming. In contrast, MicroPython is designed to function with a broader range of microcontroller boards, extending beyond Adafruit’s product lineup.
- Updates and Compatibility: Since CircuitPython is built upon MicroPython, it generally incorporates updates and improvements made to MicroPython. However, CircuitPython may introduce some modifications and enhancements, primarily to enhance compatibility with Adafruit’s boards. This ensures that users have a smoother experience when working with Adafruit hardware.
In essence, both CircuitPython and MicroPython serve as valuable tools for programming hardware using Python. Your choice between the two depends on your hardware preferences and your familiarity with programming.
Suggested Reads!
- https://docs.circuitpython.org/en/8.2.x/README.html
- https://docs.micropython.org/en/latest/
- A Complete Guide for MQTT Protocal
Hey there, I’m Anshul Pal, a tech blogger and Computer Science graduate. I’m passionate about exploring tech-related topics and sharing the knowledge I’ve acquired. With two years of industry expertise in blogging and content writing, I’m also the co-founder of HVM Smart Solution. Thanks for reading my blog – Happy Learning!