The rise of Python for Embedded Systems
According to IEEE Spectrum, Python is ranked No. 1 in the top programming languages of 2017.
Python has continued its upward trajectory from last year and jumped two places to the No. 1 in the overall ranking. While the first position is confirmed for Web and Enterprise categories, this amazing language still needs to explode in the Embedded category, despite the rise of Python-based embedded development platforms like Zerynth and MicroPython.
This ranking is not that surprising. Today the vast majority of embedded code is still written in C. Expert and skilled C programmers could justify this stating that “C generates a faster, more compact, and more reliable code”
if you replace C with “assembly” in that statement, you’d have exactly what an extinct generation of programmers said about 20 years ago!
Why using Python for Embedded Applications
If you have a quick Google for something like “Python for Embedded Systems” you’ll find lots of very interesting articles like the following:
- Python is better than C! (Or is it the other way round?) by Clive (Max) Maxfield, Editor in Chief at Embedded.com
- Python vs. C/C++ in embedded systems by Tom Radcliffe, Vice President Of Engineering at ActiveState.com
- Python’s role in developing real time embedded systems, by Jacob Beningo, embedded software consultant and owner at beningo.com
- Is Tomorrow’s Embedded-Systems Programming Language Still C?, by Ron Wilson, Eng tech at Intel Corporation
- Python For Embedded Systems and More [PODCAST], by Joe Colantonio
As is very well summarized in one of the articles mentioned above, we can say that:
If a problem can be solved in Python, then it can also be solved in C; the reverse is not always true. However, if the problem can be solved in Python:
— The solution (source code) will be simpler than the corresponding C code.
— It will be more “readable.”
— Perhaps, more importantly, it will be more “writeable” (this is an oft-overlooked quality!).
So, while C/C++ is slow to write, error prone, and often unreadable, Python is known for its writability, error reduction, and readability.
For these and other reasons, according to one recent study, Python isn’t just the most-popular language for introductory CS programs and hobbyist developers, it’s also the fastest-growing language for embedded computing. There’s an enormous crowd of professionals skilled in using Python “potentially” able to develop the software for the “next big thing” in IoT and to ship new amazing embedded applications in a short time.
Why using Zerynth for your Python-based embedded applications
Zerynth reaches beyond professional embedded developers to also offer high-level programmers, product designers, and IoT developers a complete set of high-quality embedded development tools to create interactive and connected solutions.
Zerynth allows designing embedded applications and IoT connected devices using any 32-bit microcontroller and connecting to any cloud infrastructure. All in Python and hybrid C/Python language.
Easy for beginners and powerful for experts
One word: simplicity! Unlike other Python implementations for microcontrollers, with Zerynth there’s no need to copy/paste creepy scripts from different web sources. No need to drag-and-drop any file in any folder or via FTP. No need to install Python on your PC and no need to install Putty or special drivers. Thanks to Zerynth, you can make your device programmable in Python with just a few clicks!
As you can see in this tutorial on how to program a NodeMCU board using Zerynth, you just need to:
- Download and install Zerynth Studio
- Connect, Register and Virtualize the ESP8266 board
- Clone an example and uplink it to the board
That’s it. Following these very simple steps, you can program your device in Python instead of having to use complex low-level languages like C or C++. This is an excellent choice for beginners who are new to programming.
For advanced users, Zerynth allows mixing Python and C code in the same project.
This kind of “hybrid” programming is extremely powerful in scenarios where the project needs low-level code for time critical tasks while keeping Python flexibility and readability for non-time critical sections.
With Zerynth you haven’t to choose between development speed and runtime speed. You can have both!
Find out more about the Zerynth-C language interface in the official doc.
Write once, run everywhere
Zerynth Virtual Machine, the core element of the Zerynth stack provides a real hardware abstraction layer allowing code reuse on a wide range of 32-bit microcontrollers, the heart of embedded and IoT solutions.
The hardware independence is critical for many:
- for Product Designers, it reduces the time to market because they haven’t to re-write the code when they switch from prototyping to production;
- for System Integrators, it makes it easier to focus on the integration part and select the board that better fits with the project, without the need to worry about low-level functionalities and programmability;
- for Embedded Producers, it speeds up the adoption of new embedded hardware and opens to the huge community of Python programmers.
The Zerynth Virtual Machine has been developed with the goal of making Python usable in the Embedded world. To do so some features of Python have been discarded because they were too resource intensive, while non-Python features have been introduced because they were more functional in the embedded setting. Take a look at the official doc to see a (not-comprehensive) list of the differences between Zerynth and Python.
What you can do with Zerynth
Unlike other IoT development platforms, Zerynth provides a complete “ecosystem” of tools that allow you to go from the firmware development to the cloud connection, thanks to an extensive collection of libraries.
Need inspiration? The Zerynth Academy website section provides a list of tutorials that guide you to develop embedded and IoT solutions in Python with the Zerynth Stack. You will learn:
- how to use Zerynth to program in Python for ESP8266, a successful and widely adopted microcontroller for IoT and embedded applications;
- how to use Zerynth and Arduino MKR1000 to enable IoT Security;
- how to create a LoRa network programmed in Python using Zerynth and connected to The Things Network;
- how to get and visualize sensor data of LoRa nodes using Zerynth and Matplotlib, a very popular Python plotting library;
- how to use Zerynth program in Python for Hexiwear, one of the most loved wearable IoT development platforms
- how to use Zerynth to program in Python for Nordic’s nRF52832, a Bluetooth 5-ready SoC supporting Bluetooth Low Energy (BLE).
Beyond Arduino and Raspberry Pi…
As mentioned above, students and hobbyist migrating into the industry with experience programming in Python for drones, robots, or other projects frequently have a Raspberry Pi or an Arduino background.
Zerynth offers the benefits of microprocessor-based boards like Raspberry Pi:
- Python language (or hybrid C/Python if necessary)
- Multithreading support
along with the great advantages of microcontroller-based boards:
- lower power consumption with respect to microprocessor-based boards
- lower hardware costs in the prototyping phase
- extremely lower hardware costs in the industrialization phase
All this, with a relatively tiny footprint of 60k-80k of flash, 3-5k ram.
…for scaling up without pain
Zerynth is already used by companies and professional teams to build amazing IoT and embedded solutions in different sectors: retail, commercial refrigeration, waste management, smart devices and much more, as you can see in the “Built with Zerynth” wall.
Download Zerynth Studio and Zetynth VM – it’s free, it’s easy
Now that you know all the advantages of embedded development in Python it’s time to download Zerynth Studio and Zerynth Virtual Machine and start your dream project. After all, it’s free, it’s easy, and tailored to your needs.
Until next time,
The Zerynth team