Microcontrollers: Best Language – MicroPython, CircuitPython, Arduino, or C?

Microcontrollers: Best Language - MicroPython, CircuitPython, Arduino, or C? Ultrasonic Sensor Altium Designer 1

Microcontroller development boards are now a staple in the maker community, enabling control of modules like sensors, motors, LEDs and HIDs. To program these devices, you’ll need to learn a scripting language that the microcontroller can interpret. The most popular languages include MicroPython, CircuitPython, Arduino (simplified C++), and C, each with its own advantages and disadvantages.

MicroPython

language

MicroPython is a lightweight implementation of Python 3 that is specifically designed for microcontrollers. It was created in 2013 by Dr. Damien George to enable faster prototyping and to make it easier for people already familiar with Python to program microcontrollers using a similar language.

Functionalities

MicroPython is an excellent language for beginners who want to program microcontrollers. Its use of human-readable commands in simple structures makes it easy to understand, even for those with no coding experience. Additionally, it employs a read-evaluate-print-loop (REPL) runtime environment, which provides an interactive coding experience.

Execution speed and effectiveness

Programming a microcontroller using MicroPython involves flashing firmware containing the interpreter, libraries, and other dependencies into the microcontroller. This allows MicroPython code to be interpreted and executed locally by the microcontroller, enabling live feedback during coding and faster prototyping.

However, because of how processors execute code, interpreted languages like MicroPython will be significantly slower than compiled languages like C++. Therefore, while prototyping can be much faster with MicroPython, code execution itself is slower by default.

Adaptability

To interpret and execute programs, MicroPython utilizes local resources, requiring a microcontroller to have at least 256kB of flash memory and 16kB of RAM. Unfortunately, some popular development boards like the Arduino Uno do not meet these specifications. However, there are still many boards that are compatible with MicroPython.

Presently, MicroPython officially supports several boards, including the Pyboard, ESP32, ESP8266, Raspberry Pi Pico, BBC micro:bit, STM32 development boards, and certain Arduino boards like the Nano 33 BLE, Nano RP2040, Giga R1, and Portenta H7.

Community and Support


Since its inception in 2013, MicroPython has amassed a substantial following. Learning MicroPython is easy for beginners due to its well-written documentation. If further assistance is required, the MicroPython community forum is available, where users can share tutorials, ideas, and provide solutions for any problems related to MicroPython.

Arduino

Microcontrollers: Best Language - MicroPython, CircuitPython, Arduino, or C? image 8
Arduino

Arduino is a well-known open-source platform primarily targeted towards electronics and do-it-yourself (DIY) enthusiasts. The platform provides an easy-to-use development environment and a range of microcontroller boards with varying capabilities, making it a popular choice among hobbyists and professionals alike.

The Arduino programming language is based on C and C++, making it simple for those with prior knowledge of these languages to quickly adapt to the Arduino environment. The Arduino language was first introduced in 2005 by a group of Italian engineers, artists, and designers who wanted to create a simple tool for their students to prototype interactive objects. Since then, the platform has grown in popularity, with a vast community of developers contributing to its extensive library of code and projects. Whether you’re a beginner or an experienced developer, the Arduino platform provides an excellent starting point for bringing your electronics projects to life.

Functionalities


The programming language used by Arduino is a simplified version of both C and C++, which simplifies the learning and development process. The use of compiled code in Arduino results in faster code execution as compared to interpreted languages. Additionally, Arduino requires minimal system resources, making it compatible with a wide range of microcontrollers and development boards.

Execution speed and effectiveness


In contrast to MicroPython and CircuitPython, Arduino employs a compiled programming language. This involves compiling the code on a compiler, which is already included in the Arduino IDE, before executing the entire program on the microcontroller.

The advantage of using a compiled language is that the microcontroller does not need to use resources to interpret each code line. Additionally, the program is translated into machine code during the compilation process, which the microcontroller can natively execute without installing additional dependencies.

This results in significantly faster code execution since the microcontroller can execute the program directly, without allocating time and hardware resources to translating the code.

Supported Hardware Devices

With the compiling stage handled by the IDE, microcontrollers with as little as 32kB of flash memory and 2kB of RAM can be utilized for Arduino programming. This opens up a wide range of board alternatives to use instead of official Arduino boards. Some of the popular microcontrollers used in these alternatives include ATmega328P, ATmega2560, SAMx8E, ESP8266, ESP32, and STM32.

Community and Support

Arduino has been an open-source platform since 2005 and has an extensive documentation that is regularly updated by the Arduino Foundation. Additionally, the Arduino community is highly active, providing excellent support to beginners and enthusiasts alike. You can find a wide variety of tutorials, ideas, and troubleshooting tips shared by the community, ensuring that you will always find help when needed. Therefore, with Arduino, you can expect to have access to reliable support.

CircuitPython

Microcontrollers: Best Language - MicroPython, CircuitPython, Arduino, or C? image 9
circuit python

CircuitPython is a Python 3 implementation created by Adafruit, based on MicroPython. While CircuitPython was originally forked from MicroPython, it has been enhanced to offer a more enjoyable and approachable experience when learning how to work with microcontrollers.

Functionalities

CircuitPython was designed with the goal of making it easier for beginners to learn how to program microcontrollers. It provides several features to achieve this, such as an interactive coding environment, built-in libraries, and a simplified syntax that is easier to learn than that of MicroPython. Additionally, CircuitPython offers excellent documentation and guides to help users get started with programming microcontrollers.

Execution speed and effectiveness

As CircuitPython is built on top of MicroPython, it inherits many of its strengths and weaknesses. Although it has more features and additional libraries than MicroPython, the program run time is slightly slower. However, this difference is hardly noticeable, as CircuitPython requires more powerful microcontrollers to function properly.

Supported Hardware Devices


CircuitPython’s integrated libraries and easy-to-use syntax come at the cost of increased resource requirements compared to MicroPython. A microcontroller must have at least an 8-bit processor, 256kB of flash memory (512kB recommended), and 32kB of RAM (64kB recommended) to run CircuitPython. However, given these higher resource requirements, CircuitPython supports a wider range of development boards than MicroPython, with over 390 boards currently listed on the official website.

Community and Support

Adafruit is recognized for producing user-friendly products, and CircuitPython is no exception. You can easily access comprehensible documentation and books on CircuitPython, thanks to Adafruit’s focus on providing beginner-friendly resources. Despite only being introduced in 2017, CircuitPython has a more substantial community following than MicroPython, and you can connect with like-minded individuals via Discord and the official forum. Adafruit is also continuously releasing updates, providing support, and developing new products, ensuring that you can quickly find assistance and support when needed.

C

C was developed in the 1970s by Dennis Ritchie at Bell Labs and is a compiled programming language that has been widely used by engineers and professionals to program microcontrollers efficiently.

Features

Despite being a more challenging language to learn, C offers greater speed, efficiency, control, and portability than MicroPython, CircuitPython, and Arduino. This makes it an ideal language for programming microcontrollers that will be used in finished products.

Performance

C is renowned for its performance and can run programs faster than Arduino, MicroPython, and CircuitPython, even on lower-resource microcontrollers. This is because C is a more efficient language and requires fewer dependencies. Although a compiled Arduino program can also run on bare-metal hardware like a C program, its machine code comes with pre-installed libraries and tools that can reduce performance.

Supported Boards

C is incredibly portable and can be used to program virtually any Arm-based microcontroller. Additionally, it can be used with boards based on Atmel AVR, STM32, PIC, and MSP microcontrollers.

Community and Support

The C programming language has a vast online community due to its robust programming applications and the fact that it has been in existence for several decades. One can easily seek help by exploring various online forums, chat rooms, and blogs that focus on discussing and sharing ideas related to the C language.

What Programming Language Should You Choose?

When choosing a language to program microcontrollers, it’s important to consider your level of experience and the specific needs of your project.

If you’re a professional designer looking to create electronics for production, then the C language is the most suitable language for you. It offers a high level of speed, efficiency, and control, making it ideal for programming microcontrollers to be used in finished products.

If you’re a beginner with no coding experience, then CircuitPython would be a great place to start. It offers an interactive coding environment, built-in libraries, simple syntax, and excellent documentation and guides, making learning easy and fun.

For those already familiar with Python, MicroPython provides a similar platform for programming microcontrollers.

However, for the majority of the DIY/maker community, Arduino is still the go-to language for programming microcontrollers. It strikes an excellent balance between performance, portability, features, and community support. With its open-source platform, robust documentation, and active community, Arduino is a great choice for hobbyists and professionals alike.