Python and C hybrid programming on a microcontroller with Zerynth
It’s clear that Python is on the rise in the IoT and embedded sphere. More and more engineers, product designers, and developers are starting to use it in their work. Compiling languages are making room for Python in the embedded category.
We can’t forget that there is a whole new generation of developers who use Python as a default language for everything from machine learning and scientific experiments to prototyping and data analysis.
And even though this is means that Python is pushing C out of its place in the embedded world, that doesn’t mean that they can’t be used together. Developers who are used to working with mostly C over the years may feel the need to defend their position and list all the ways in which C works for them. Or they could join this recent development in the microcontroller world and try a high-level language like Python.
That about sums it up, but let’s go more in depth and see how Zerynth tools fit in this picture.
Zerynth tools for IoT and embedded
Zerynth is the middleware for IoT – the bridge between the microcontroller and the Cloud.
Imagine this, on one side you have a 32-bit microcontroller based development board and on the other, you have your preferred Cloud Service. The Zerynth toolset is what connects them to each other.
With thousands of users over the world, it’s clear that developers and engineers have recognized the value of Zerynth tools.
Python/C programming with Zerynth tools
Furthermore, Zerynth allows mixing Python and C, in the same project.
This is how it works:
Python is compiled to bytecode and executed by the Zerynth Virtual Machine independently of the target board. On the other hand, C is compiled to object code dependent on the target microcontroller instruction set. These two can coexist because, during the uplinking phase, Zerynth resolves any unresolved symbol from the C code and saves C function addresses in the bytecode.
This kind of “hybrid” programming is extremely useful in those scenarios where you need to write or you have already written performant low-level code for time-critical tasks, but you want to retain Python flexibility and readability for non-time critical sections.
You can mix things up. Code your high-level logic in Python, and for all those parts where you need more speed, you can use C.
You can learn more about it here.
Tutorial on programming the ESP32 in C/Python with Zerynth
And if after everything you’ve just read now, you’re up for a challenge, you can check out this tutorial on programming the popular ESP32 in C/Python with Zerynth.
You can recreate in on any of the Zerynth Supported Devices, so the author of the tutorial has picked the ESP32 DevKit V1.
Download Zerynth Studio
All you need to do now is download Zerynth Studio! It’s free for download and available for Windows, Linux, and Mac OS.