Some success in getting Pi Pico to sleep

I've seen posts where people want to get the Raspberry Pi Pico to run in low-power sleep mode, but there is no easy way to do this (ie a library call). I'm an experienced programmer but not an Arduino expert but I have managed to get my Pico to sleep, although it was complicated.

I used the sketch in this GitHub post

[https://github.com/matthias-bs/arduino-pico-sleep](https://github.com/matthias-bs/arduino-pico-sleep)

It won't compile on its own. I had to copy his src files (C++ and C) into the sketch itself, the .h files into the sketch folder, and install the ESP32time library. I had to edit one header file that referenced another and remove the ../ prefix as they were now all in the same folder.

Once it compiled it ran straight away. It resets the Pico when it comes back from sleep. My measurements show the Pico consuming about 28mA when running doing nothing much, and about 3.6 mA when sleeping.

Like I said, I'm not an expert, so i dont know how to turn this bodge into something simpler to use. I also don't understand why the RTC needs the date&time entered, or why the sketch resets the Pico after sleeping

I'm having the same issues, found this post trying to see if anyone else has figured it out.

It seems like there is (currently) no straightforward to get a pico to sleep and wake up via the Arduino IDE. Everything I've seen involves re-compiling the earlephilhower core.

All I'm looking to accomplish is to have the pico go to sleep after a few minutes of inactivity and wake up if a button is pressed.

I have now successfully created a Arduino IDE2 library that lets a sketch make a single call to put the Pico to sleep for a specified number of seconds. When it returns, the sketch continues normally. It uses the RTC timer and I have verified that the Pico current consumption dropped below 3 mA during sleep. The library also works for an Arduino RP2040 Connect. I took code from several articles on the Web and combined it, with some minor additions of my own. I have not published the library, partly because it uses other people's code, partly because I don't fully understand it. For the Pico there are a couple of oddities that might need investigating: 1. the serial monitor does not disconnect, but it stops communicating, and 2. the Pico current consumption after sleep is about 3mA more than after power-on. I suspect the latter has to do with clock frequency, the library has to restart several clocks.

I'm not planning to publish the library any time soon. If you would like to try it, is there a way I can send it to you?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.