PyCon DE & PyData 2025

Using Python to enter the world of Microcontrollers
2025-04-25 , Titanium3

So you've happily used the Raspberry Pi for your homelab projects, of course with Python based solutions as we all do. You've been down the rabbit hole with everything about temperature and humidity measurements, energy and solar tracking, video recording and time-lapse photography, object detection and security surveillance.

You don't just buy these things of the shelve. You want to deeply understand what it takes to create such a thing, and you've been quite happy with your results so far, learned a lot.

But for many simple applications ... the power draw! Yes, it's just 5 Watts you say for using a Raspberry Pi. Not a big deal in terms of cost. But you'll always need a power adapter and a free socket.

You've heard of these guys using microcontrollers that run on batteries or even solar, for days, weeks, even months.

That's exciting, but there's also a catch. These people write code in C-like languages, they build firmware to make their projects run. And it's all bare metal! That seems very different. That'll be a steep learning curve to take ... Or is it?

Well, there's MicroPython to the rescue. Let me take you with me on a journey to make a simple microcontroller based application to read a Power Meter and send the readings over WiFi for more in depth processing somewhere else.


Over the past years Python became available on more and more platforms, both software and hardware ones. From MacOS and Linux to Windows. From Desktop Computers and SoC Platforms such as the Raspberry Pis to Data Centers. And even on the smallest side Python is available today.

MicroPython implements our beloved language for direct use on embedded platforms built on top of popular microcontrollers, such as the original PyBoard using an STM32 microcontroller, the ESP32 platform and the Raspberry Pi Picos.

In this talk we'll have a look at how MicroPython feels compared to the fully fledged Python implementations, by "porting" a simple application that initially was built to run on a Raspberry Pi to an ESP32 based Microcontroller.

The application was used to retrieve Power Meter Readings via its internal Infrared LED using a small photo transistor based circuit connected to the Raspberry Pi and calculate current power draw from these readings to send them somewhere else for further processing.

We'll see what it takes to make such an application work on a Microcontroller running just on batteries.


Expected audience expertise: Domain:

Intermediate

Expected audience expertise: Python:

Intermediate

A physicist currently tackling the development of embedded devices at Rosenxt for various use cases. My journey with Python began a long, long time ago, when the interpreters version string said 1.4.

Besides my current efforts I can rely on great experience from various other roles in my prior career as a scientist, technology manager and department head.