Thanks a lot @James46717 , let see if that do so good! I will see if some of the folks who reported issues before can test the changes.
Don’t we all?
Thanks a lot @James46717 , let see if that do so good! I will see if some of the folks who reported issues before can test the changes.
Don’t we all?
Hi, I have tried this on a Lilygo T-Pico C3 (on the RP2040 side) but I can’t get the prints when the microcontroller wakes up.
I copied the above code in a lowpower.py file, and imported it in my sketch as follows
from machine import Pin
from time import sleep
import lowpower
btn6 = Pin(6, Pin.IN, Pin.PULL_DOWN)
btn6.irq(lambda e: print("button 6 event!"), Pin.IRQ_RISING)
btn7 = Pin(7, Pin.IN, Pin.PULL_DOWN)
btn7.irq(lambda e: print("button 7 event!"), Pin.IRQ_RISING)
c = 1
LED_BUSY = 25
busy_led = Pin(LED_BUSY, Pin.OUT)
def blink_n_times(n):
for _ in range(n):
busy_led.value(1)
sleep(0.5)
busy_led.value(0)
sleep(0.5)
while True:
print('count: '+str(c))
blink_n_times(c)
print("before dormant")
lowpower.dormant_until_pin(6)
# lowpower.dormant_until_pin(7)
sleep(0.5)
print("after dormant")
sleep(0.5)
c += 1
But, I never get the “after dormant” nor “button 6 event” message after pushing the buttons. However, the led blink count increases each time. However, it seems the RP2040 is sleeping and then awakes when I push the button.
But how can I recover the prints?
Welcome Fabrice!!
If you keep the RP2040 from entering any sleep mode do you see the interrupts firing?
I’d definitely check out the project where Jim applies low power modes on the Pico: Simple Relay Timer - Tutorial Australia
It might be possible that the UART peripheral isn’t awakened, though I haven’t had an extensive look through Jim’s amazing port.
Liam
Hi Liam, thanks for your answer.
Yes I can see the messages from the interrupts.
I tried to add sleep(1)
after the dormant instruction with no luck.
I am using now the deep sleep implementation of Tom Jorquera (see message above) which enables to wake up from several pins:
lowpower.dormant_until_pins([7,6])
I get wake-up fine but no prints either.
Fyi @James46717, this snippet was featured in Jeff Geerling’s Pico 2 review video @ 4:54 !
Hi @James46717 @Tom209315 ,
My name is ashely amaya, I’m an electronic engineering student and with my partner we are doing our degree work, which consists of the design and implementation of a low-consumption ammonia sensor. To do this we are using the lowpower tomjorquera library and when using it we had the problem that you explained in this forum, which was that it didn’t wake up from dormant mode, so we also used your alternative but the raspberry still does not wake up. For this reason, we don’t know if you can help us or guide us to discover the error or why it doesn’t wake up in order to find a solution.
Below I attach the main code that we are using, the clock library (since the point is to wake up the raspberry by means of an interruption generated in an external clock (DS3231) and that when programming an alarm and its time coincides with the current one, the impulse that wakes up the raspberry is sent, it should be noted that we have already tested that this works but when we went to test to wake up the raspberry it simply does not wake up) and the lowpower library file from you and Tom.
Thank you very much for your help, remain attentive for any news.
Codes.zip (7.2 KB)
Hi @Ashely280243 the code I posted did not do anything other than put the Pico to sleep, it was woken by me physically changing the state of the pin. I abandoned further research because, as a method for putting the Pico to sleep, it was impractical.
I have had better success with reducing the power consumption of the Pico by removing power, using something like the Makerverse Nano Timer, which consumes only 35nA when timing. But the timer is limited because it wakes at regular intervals.
It might be possible to use the DELAY / M_DRV pin of the TPL5110 to switch the Timer Mosfet On via your clock circuit, essentially switching the Pico On. The startup time of the Pico is short and would have to be considered by your design. The Timer could be set to maximum delay (2 hours) or a custom value to suit your design.
I have had a lot of success with Arduino ATMega328P & ESP devices with respect to sleeping and reducing power consumption.
Regards
Jim