pico sleep modes

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

pico sleep modes

Post by KJM » Wed Oct 06, 2021 6:15 am

I really like the detective work that has gone into https://ghubcoder.github.io/posts/awaking-the-pico/ & its promise of 1.3mA sleep with wakeup from an internal timer. Unfortunately I only know micropython, no C++ experience.

Would the code have to be re-written in micropython to be usable in micropython or could it be run somehow using pioasm or some other technique for running C++ code from within a micropython program?

hippy
Posts: 130
Joined: Sat Feb 20, 2021 2:46 pm
Location: UK

Re: pico sleep modes

Post by hippy » Wed Oct 06, 2021 12:38 pm

It is not clear what part of that effort you need or want to use but it seems to me the best way would be to include the required code in a MicroPython C Extension Module and include that in your own MicroPython build.

Others would be able to create such a C Extension for you if you can indicate what code should be included, how you want to call it.

I had embarked upon doing that after a similar post to the Raspberry Pi Pico forum, but haven't done much, and would need those details to know what it should include.

KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

Re: pico sleep modes

Post by KJM » Wed Oct 06, 2021 10:34 pm

I just want to use the pico to take a sensor reading then sleep itself for a nominated time before taking the next reading, I guess I was thinking something like machine.deepsleep(nominated time). The thought of a custom build fills me with trepidation. Is there no way for micropython to call C++ code as a subroutine or def function? https://docs.micropython.org/en/latest/ ... dules.html sort of suggests that a C++ program in a .mpy file can be imported without doing a custom build?

hippy
Posts: 130
Joined: Sat Feb 20, 2021 2:46 pm
Location: UK

Re: pico sleep modes

Post by hippy » Wed Oct 13, 2021 6:21 pm

C Extensions are an integrated part of MicroPython so have access to pretty much anything. But one needs a custom build to include one's own.

Native C Modules from which a '.mpy' file can be created, and used just by placing it on the file system, allows C code to be used without a custom build, but the problem is that such modules don't have access to everything.

I am guessing you will want to call library functions in the Pico SDK to do what you want and I doubt they will be available for use in such a Native C Module.

Rebuilding custom firmware, adding your own C Extensions, isn't that hard, and there's help at hand for doing that.

Post Reply