pyb.standby() and ExtInt Line identification
-
- Posts: 1
- Joined: Mon Sep 28, 2015 1:00 pm
pyb.standby() and ExtInt Line identification
Hi,
New to the forum and new to micropython but I have been playing and getting the LoNet GSM/GPS module working with my pyBoard.
As part of this I have hooked up a PIR sensor to get the board to send a REST call to a server via the LoNet board. All works okay but I want to try reducing the power consumption. All seems good with using external interrupts and getting the board to do as expected, so all is going well.
I now want to add a second sensor on a second external interrupt, and that is where my skills are failing me. How do I get the value of the external interrupt line that was triggered and woke up the board after a py.standby() or py.stop()?
Ideally, I would like to use pyb.standby() but will settle for pyb.stop() if that gives me the information that will let me identify the external interrupt that was triggered. I can see the line value in the callback from pyb.stop() but can't work out how to make it available else where in my program (it's probably a lack of understanding on the use of global on python variables, so sorry for my very basic question).
Many thanks
Carl
New to the forum and new to micropython but I have been playing and getting the LoNet GSM/GPS module working with my pyBoard.
As part of this I have hooked up a PIR sensor to get the board to send a REST call to a server via the LoNet board. All works okay but I want to try reducing the power consumption. All seems good with using external interrupts and getting the board to do as expected, so all is going well.
I now want to add a second sensor on a second external interrupt, and that is where my skills are failing me. How do I get the value of the external interrupt line that was triggered and woke up the board after a py.standby() or py.stop()?
Ideally, I would like to use pyb.standby() but will settle for pyb.stop() if that gives me the information that will let me identify the external interrupt that was triggered. I can see the line value in the callback from pyb.stop() but can't work out how to make it available else where in my program (it's probably a lack of understanding on the use of global on python variables, so sorry for my very basic question).
Many thanks
Carl
Re: pyb.standby() and ExtInt Line identification
When you register an interrupt callback with the ExtInt module, it gets passed a line. That is what you use to tell you which line caused the interrupt.
The lines correspond to the pin number. So CPU pin B3 will use line 3 (modulo me being off by 1 because I'm saying this off the top of my head without actually testing it first).
The lines correspond to the pin number. So CPU pin B3 will use line 3 (modulo me being off by 1 because I'm saying this off the top of my head without actually testing it first).
Re: pyb.standby() and ExtInt Line identification
I don't believe interrupts work in standby() mode.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: pyb.standby() and ExtInt Line identification
From the docs for pyb.standby() http://docs.micropython.org/en/latest/library/pyb.html:I don't believe interrupts work in standby() mode.
To wake from this sleep state requires an external interrupt or a real-time-clock event. Upon waking the system undergoes a hard reset.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: pyb.standby() and ExtInt Line identification
When suspend() mode is woke by an external interrupt resulting in a hard reset, how can one identify the source of the interrupt?
Perhaps in the boot.py?
Perhaps in the boot.py?
Re: pyb.standby() and ExtInt Line identification
The reference manual (RM0090) Table 23 (Section 5.3 - Low Power Modes on page 126) seems to indicate that EXTI can only wake the processor up when its in stop mode, and not when its in standby mode.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: pyb.standby() and ExtInt Line identification
@dhylands That seems unambiguous. In which case the Pyboard docs are wrong: http://docs.micropython.org/en/latest/l ... -functions states
pyb.standby()
Put the pyboard into a “deep sleep” state.
This reduces power consumption to less than 50 uA. To wake from this sleep state requires an external interrupt or a real-time-clock event. Upon waking the system undergoes a hard reset.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: pyb.standby() and ExtInt Line identification
@JimTal001 Further study indicates that it's possible to wake the Pyboard from standby() with an external event by using the Tamper input. This is on pin X18. I'm hacking some code together to enable access to this. It works but needs tidying up and documenting: I expect to update my micropower repo on Github in the next few days.
It's perhaps stating the obvious, but response to an external event isn't exactly quick. The Pyboard goes through its boot sequence on recovery from standby. I haven't yet measured it, but on the basis of previous measurements and visual impressions it's on the order of 0.5S.
It's perhaps stating the obvious, but response to an external event isn't exactly quick. The Pyboard goes through its boot sequence on recovery from standby. I haven't yet measured it, but on the basis of previous measurements and visual impressions it's on the order of 0.5S.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: pyb.standby() and ExtInt Line identification
This is good news regarding pin X18. Is there a way to determine whether the interrupt is from X18 or RTC?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: pyb.standby() and ExtInt Line identification
Yes. I have a test program which distinguishes between the three reasons for wakeup, namely boot, RTC timeout and tamper. I'll post here when it's ready.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.