MicroPython on XIAO MG24 with working lightsleep (6.6 µA) and deepsleep (~2 µA)

Hi all

I’ve been working on getting MicroPython’s sleep modes going on the plain XIAO MG24 and I’m happy to share the result: Custom MicroPython v1.29.0 firmware (on Zephyr v4.4.0) where machine.lightsleep() and machine.deepsleep() actually reach EM2 and EM4.

Whole-board current on a LiPo, USB unplugged:

Current
Stock MicroPython firmware, idle 13.1 mA
machine.lightsleep(), EM2 (RAM kept) 6.6 µA
machine.deepsleep(), EM4 (RAM lost) ~2 µA

What made the difference:

  • The console blocks EM2. On this port, the UART’s RX interrupt holds a power-management lock so time.sleep() never gets below EM1. lightsleep() now turns RX off while it sleeps.
  • PA8 back-powers the SAMD11 on battery (~10 mA), and the debug pins leak (~80 µA). I see others in the “Power consumption of XIAO MG24” thread found the same, so it was great to have that confirmed.
  • RF switch power (PB5) costs ~81 µA when it’s left on. Switch it on only when you use the radio.
  • The onboard flash is on PA6/PA0/PB0/PB1 according to the schematic. The wiki’s Demo 3 sends the sleep command on PA3/PA4/PA5, which are the header SPI pins. On the correct pins, deep power-down saved a further 7.6 µA.
  • deepsleep() uses EM4 with a BURTC wake-up and pin retention, so all the above fixes hold while asleep.

The board fixes are in a small low_power.py module, so a sleeping sensor script is only a few lines.

Everything is here: prebuilt firmware, the patch, build instructions, config files and example scripts:

It’s tested on the plain XIAO MG24 only, not the Sense. I’d love to hear if it works for you, and any ideas for squeezing out more.

Thanks to Seeed for the board and the schematic and to everyone in the earlier power threads, whose findings helped point the way.

Chris