Quick Index

Back to Top
What Needs to Be Done
The Easy Stuff
The Hard Stuff

5 p a n e l . d a n c e

↙️ ↖️ ⏺️ ↗️ ↘️

GitHub • YouTube • BlueSky • Discord • Ko-Fi


Info

This is a work in progress!
I'm no C++ dev, but I'm doing my best. None of this page should be treated as professional! I am but a man with a keyboard and a search engine.

What Needs to Be Done

If you've read my blog post about the Meshlet node I designed, you're probably aware that it didn't survive even the earliest winter months here in Alberta, Canada. It got too cold and dark too quickly for the node to be able to keep up, with its dinky solar panel and meager 3000mAh LiPo.

I was hoping that flashing the EasySkyMesh firmware would be enough to help. It does a frankly incredible job saving power on ESP32 nodes, enough to make them solar viable. nRF52 nodes also gain a noticeable increase in battery life compared to stock, which is crazy given how efficient they are by default. Unfortunately, aside from the new LoRa radio duty cycle additions that save power on the radio, it doesn't seem like anything is actually done to save power on the Pico 2/RP2350 platform.

With the default EasySkyMesh firmware, I'm reading ~25mA draw at a 4.2V input on the board's external power connector. This connector on the Meshlet specifically goes to the BQ25185 battery charger IC, which needs a minimum of 3.8V input (in my testing, at least) to power on & supply the load. So, the ~25mA average draw is a reading for the entire board, including all of its peripherals. The majority of this draw is the RP2350; we can get some easy power savings by throttling the core clock and slapping a good ol' __wfi() in there. However, we can also save additional power by cutting off serial (I2C, etc) and any other peripherals we aren't using. Let's see what happens!


The Easy Stuff

I only have a tiny bit of barely usable C++ knowledge, so we're gonna start small.

First off, we'll add a few lines of code to the Begin() function in my board's variant. During wake, we don't really need everything the RP2350 has to offer. Towards the end of the function, we'll downclock the CPU, lower the core voltage, hold the PIO cores in reset, and disable the PIO core clock.

void RP2350Board::begin() { ... everything else // Slow clock for power savings // 52.8MHz is the slowest base speed that still allows USB to work reliably. // See RP2350-E12 in the chip's datasheet. set_sys_clock_khz(52800, true); // Downvolt from 1.10V to 1.00V vreg_set_voltage(VREG_VOLTAGE_1_00); // Shut down PIO cores because we don't need 'em pio_set_sm_mask_enabled(pio0, 0x0F, false); pio_set_sm_mask_enabled(pio1, 0x0F, false); pio_set_sm_mask_enabled(pio2, 0x0F, false); // Hold PIO cores in reset reset_block(RESETS_RESET_PIO0_BITS | RESETS_RESET_PIO1_BITS | RESETS_RESET_PIO2_BITS); const uint32_t pio_clk_mask = CLOCKS_WAKE_EN0_CLK_SYS_PIO0_BITS | CLOCKS_WAKE_EN0_CLK_SYS_PIO1_BITS | CLOCKS_WAKE_EN0_CLK_SYS_PIO2_BITS; // Disable the PIO clocks cuz we don't need 'em either hw_clear_alias(clocks_hw)->sleep_en0 = pio_clk_mask; hw_clear_alias(clocks_hw)->wake_en0 = pio_clk_mask; }

This brings us down from an average of ~25mA down to roughly ~16mA! That's some impressive savings already. That said, I also need to implement a new sleep mode routine, to further reduce draw when the CPU is waiting on a LoRa packet. That's going to be the hard stuff.


The Hard Stuff

Option 1: powman

In my search for power saving optimization, I stumbled across mamba2410's "powman-sleep" repo, detailing how to achieve sub-500uA sleep mode on th eRP2350. This sounds incredible! It's proven to work shockingly well, too. There's also this Gigazine blog post in which another developer (whose name I can't seem to find, sorry!) was able to also achieve sub-500uA draw. So, we know this works - however, there are a ton of different ways to implement it. In mamba2410's case, the goal was to preserve the program state and allow a "warm wake" to resume execution, which is what we'd want. In the case of the Gigazine article, the RP2350 would simply cold boot upon wake, effectively resetting it. We don't want this.

The biggest problem with both of these, at least for me, is that I don't understand the fundamentals well enough to have any idea how to effectively implement them on someone else's firmware, lmao. Believe me, I gave it an honest shot - and I did achieve sleep mode down to 3mA! Which isn't amazing compared to sub-500uA, but I would attribute that to other components of the Meshlet also drawing power on top of the RP2350. And, crucially, I also could not get it to reawaken from sleep mode. Ever. Womp womp. A repeater that can't repeat packets isn't much good. So, I've Unfortunately had to abandon powman for the time being.

Option 2: the easier way

Instead of trying to stick with powman, I'm taking the easier version of the "hard stuff" route. The goal here is simple: cut down on & disable as many features as possible that aren't being used during sleep, by brute force. In total, this includes:

  • Disabling I2C clocks
  • Disabling SPI peripherals & SPI clocks
  • Downclocking to 18MHz (the lowest I felt comfortable going before risking stability problems)
  • Undervolting the core voltage to 0.9V
There's probably much, much more I could cut down on, but this is the most I was able to figure out how to do reliably with my limited knowledge. All said and done, this brings consumption down to ~10mA during sleep! That's a power draw decrease of roughly 60%! Here's the sleep mode code I slapped together, for reference:

void MeshletBoard::sleep(uint32_t secs) { // Calculate time to sleep uint64_t target_us = time_us_64() + ((uint64_t)secs * 1000000ULL); // Disable the I2C0 and I2C1 system clocks hw_clear_bits(&clocks_hw->sleep_en0, CLOCKS_SLEEP_EN0_CLK_SYS_I2C0_BITS | CLOCKS_SLEEP_EN0_CLK_SYS_I2C1_BITS ); // Disable the SPI0 and SPI1 peripheral & system clocks hw_clear_bits(&clocks_hw->sleep_en1, CLOCKS_SLEEP_EN1_CLK_PERI_SPI0_BITS | CLOCKS_SLEEP_EN1_CLK_SYS_SPI0_BITS | CLOCKS_SLEEP_EN1_CLK_PERI_SPI1_BITS | CLOCKS_SLEEP_EN1_CLK_SYS_SPI1_BITS ); // Decrease clock speed to 18MHz set_sys_clock_khz(18000, true); // Crank down core voltage to 0.9V vreg_set_voltage(VREG_VOLTAGE_0_90); while (time_us_64() < target_us) { // Disable the CPU clock until it gets an interrupt __wfi(); // Break if a LoRa packet arrives if (digitalRead(P_LORA_DIO_1) == HIGH) { break; } } // Restore core voltage to 1.00V upon wake vreg_set_voltage(VREG_VOLTAGE_1_00); // Bring clock speed back up to 52.8MHz upon wake set_sys_clock_khz(52800, true); }

Now, the question that remains is, is this the best way to do all this? Almost definitely not. Pretty much all of it was cobbled together from forums posts & other projects. It doesn't seem like the amount of power I'm saving is exceptionally stable, either; while it consistently reaches a low of ~10mA, it also sometimes sits at 12-13mA, for reasons I'm unsure of. I sincerely doubt AI could help me here, either. Even if it could, I don't like using it, nor do I have any desire to. So for the time being, I'm very happy with my ~14mA savings, and I think it'll be enough to get my node through the Albertan winter!

At the very least, I hope this can be a decent starting point for any other madman that's decided to build their platform off the Raspberry Pi Pico/RP2350 platform, instead of using an nRF52 or ESP32 like a normal person. I love this chip, I love how cheap it is, and I love what it's capable of - most importantly, I already know how to design hardware around it! It's not leaving my arsenal any time soon. Thank you for reading :)