Sleep
Last updated
Last updated
This chapter describes the various methods for sleep and wakeup which are embedded in Pytrack and Pysense libraries. Both Pytrack and Pysense have the same methods, although the appropriate class, either pytrack
or pysense
, has to be instantiated.
The following example is also available at
In the event of a sleep session that was awoken by an asynchronous event (Accelerometer, INT pin or Reset button) the approximate sleep remaining interval (expressed in seconds) can be found out. The user has to manually use setup_sleep()
to configure the next sleep interval.
Returns the last wakeup reason. Possible values are:
Note: the WAKE_REASON_INT_PIN
can be used if the PIC_RC1
pin (pin#6 on External IO Header) is toggled.
As in the above example, this method should be called at the beginning of the script, to find out the reset (wakeup) reason.
Puts the board in sleep mode, for the duration, which has to be set previously with pytrack.setup_sleep(timout_sec)
. The optional boolean parameter sets the GPS state during sleep.
MicroPython code, which is after this function, is not executed, as wakeup will restart MicroPython.
Enables as wakeup source, the accelerometer INT pin (PIC - RA5). The boolean parameters will indicate rising edge (activity detection) and/or falling edge (inactivity detection) is configured.
The accelerometer (class LIS2HH12
) has to be also configured for a certain acceleration threshold and duration. Code snippet:
Enables as wakeup source, the INT pic (PIC - RC1, pin#6 on External IO Header). Either rising or falling edge has to be set, by default it's rising edge.
Sets the sleep interval, specified in seconds. The actual sleep will be started by calling go_to_sleep()
method.
Please note that more functionality is being added weekly to these libraries. If a required feature is not available, feel free to contribute with a pull request at the