M5Paper, Arduino, PlatformIO, and MicroPython (part 2)

Previously I've described how Arduino didn't work out for me


Everything on PlatformIO's website sounds very corporate and it's very hard to tell what is it exactly. After trying it I'd describe it this way:

A package manager and a build system for embedded programming with a vast ecosystem of supported boards, components, and drivers for them.

That's not complete and PlatformIO also has tools for testing and some stuff for teams collaborating on projects, but the package manager and build system are at the core.

And it's actually really good! I've downloaded M5Paper's "FactoryTest" from GitHub (which happens to be developed with PlatformIO) and was able to build and flash it on M5Paper without a single issue.

PlatformIO has even broader support than Arduino, because whole Arduino ecosystem is included and available as packages for PlatformIO. What I like about PlatformIO is that it doesn't try to hide that the drivers and your code are just C++. It doesn't try to force any "PlatformIO IDE" on you and instead is packaged as CLI or extension for VS Code and some other IDEs. Thank you, PlatformIO!

I would love to stop here and I think I'd prefer to use PlatformIO, except remember when I said it built the project without any troubles? Well that was on my bigger desktop. On RaspberryPi it fails with presumably the same error as Arduino, because it uses the same libraries as Arduino.

Very unfortunate! I'm kind of running out of options at this point.


I was reluctant to try MicroPython because it feels wasteful to run it on such a low-powered device. ESP32 has 240MHz CPU with 320KB RAM, extended on M5Paper with additional 4MB PSRAM + 4MB more that can be used indirectly.

But this is where interpreted language with runtime may actually be valuable. I can't build C++ for ESP32 on my RaspberryPi, but I can download already built binary of MicroPython and flash it on M5Paper. And it worked! So now I can actually write MicroPython on the RaspberryPi and flash it to the device. Even more, I have a REPL running on the device, so I can try stuff and immediately get feedback. This is very valuable when you explore outputs from different components on the board.

My setup is still imperfect as the MicroPython core I've installed on the device is built for generic ESP32 board. It doesn't have any M5Paper libraries.

There is some weird archived repo from M5Stack, which is a fork of unofficial MicroPython fork and has not been updated for 2 years.

So I'm not sure what's the best way to get drivers for the display, touchscreen and few smaller things. Maybe I'll have to read specs and implement myself, or try to port RaspberryPi implementations for same micorchips. I'm exploring MicroPython's support for native C extensions as well.

But this is way better than getting compilation errors from Arduino and PlatformIO.


I didn't look too much, but UIFlow is a visual programming language with blocks, like Scratch. I believe you can switch between graphical representation and MicroPython code.

That's where they lost me. I'm okay with text editor and Python. It's one of the most pleasant languages to program in my opinion, and my RaspberryPi doesn't even have mouse attached.

Although I should look more if M5Stack put more support for M5Paper in UIFlow. Maybe I can steal some MicroPython drivers from there?

What's next?

Currently I'm exploring how to get drivers for the display. I'll be very happy when I'll be able to flip some of those E-ink pixels from white to black.

I've been also trying to figure out how to get battery charge level. I have no idea what's the impact of 'lightsleep' and 'deepsleep' on the battery, and I'm curious about M5Paper's battery capacity. I've seen many mentions on forums that the display and its chip IT8951 drain way too much power, even when ESP32 is in the 'deepsleep' mode.

The first project I'd like to complete is a simple phone-like "locked screen" that displays time, date, battery percentage and maybe temperature and humidity, just because M5Paper has those sensors. We'll see how long it will take to get there.

2022-01-19 | #m5paper #platformio #micropython

Agent Parsley

All posts