Accelerometer wake-up features added to Pytrack and Pysense
daniel last edited by
We have updated the libraries to enable accelerometer wake-ups on Pysense and Pytrack.
The relevant commit is the following one:
And here's an example of usage:
I hope that you can find this feature useful. All kinds of feedback are very much welcome!
seb last edited by
Could you create a new forum thread for the issues you are facing and I will help you get your board set up and running.
I can now run a simple program but I can't use pycom.rgbled().
It says : "OSError: the requested operation is not possible"
And sometimes I get : "An error occurred: Not enough memory available on the board.
Upload failed. Please reboot your device manually."
But I tried all the reboot and reset but It doesnt work.
So I used the command to Reset the Filesystems but still the same errors appears.
I updated firmware just in case but no result.
The led is flashing blue every 4 seconds.
Yes, it seems the script keeps on re-executing quickly after wakeup.
Try safe-boot procedure; if you don't have Expander board, could be tricky: https://docs.pycom.io/chapter/toolsandfeatures/bootmodes.html
On Windows platform, maybe Realterm can catch the serial https://realterm.sourceforge.io; on linux+mac that would be minicom and allow you to give Ctrl+C to stop the scripts.
Yes I'm using Atom with pymark as recommanded. How do I wake up my board ? I'm pressing the restart button and shaking it but I can't connect it.
It never stops connecting and disconnecting it.
catalin last edited by catalin
@thomasp There seems to be a problem with COM port (serial port). What program are you using to connect/upload scripts? Atom with pymakr plugin?
Once the go_to_sleep() is executed, the serial connection is disconnected, and it comes back after the Pysense is awaken; and next, the script is executed again. This situation loops, and becomes difficult to catch the serial COM ready for connection.
So, for development purpose, maybe you should not have go_to_sleep() in the script, but execute it manually, on the REPL console (>>>).
The script can be stopped with Ctrl+C.
Well I tried and It doesn't work. Now I can't connect my board anymore. It says "Failed to connect (Error : Port is not open)." or "Failed to connect (Error: Writing to COM port (WriteFile): Unknown error code 22)."
Each time I run the script with these commands, the program doesn't execute the line. I mean it starts looping but stay at the same line and I can't do anything. I have to unplug the board to be able to restart the script.
Hi @thomasp, on the first call, the return value could have some garbage; but the valid values are (1, 2, 4 or 8).
Could you put it to sleep: py.go_to_sleep() and wake it up immediately pressing the Reset button (from the Pysense)? You should obtain value 2, of the py.get_wake_reason()
Here are the Sleep functions explained: https://docs.pycom.io/chapter/pytrackpysense/apireference/sleep.html
Hi @catalin, I'm new in programming and it looks like I've missed something.
When I try this script it returns 96 as a Wakeup reason. The red led is on all the time.
What should I do ? I'm using Pysense board and everything is updated.
@meirssv, Ok, great!
you could use the wakeup reason to verify if the accelerometer awoke the system
Yes, I already figured that one out. You could even check the remaining seconds < 1s... Thanks!
@meirssv, Ok, great!
While we fix that, you could use the wakeup reason, to verify if the accelerometer awoke the system
# display the reset reason code and the sleep remaining in seconds # possible values of wakeup reason are: # WAKE_REASON_ACCELEROMETER = 1 # WAKE_REASON_PUSH_BUTTON = 2 # WAKE_REASON_TIMER = 4 # WAKE_REASON_INT_PIN = 8 print("Wakeup reason: " + str(py.get_wake_reason()) + "; Aproximate sleep remaining: " + str(py.get_sleep_remaining()) + " sec")
Well, it seems like I missed the latest DFU upgrade for PyTrack as I was still on 0.0.7. After upgrading to 0.0.8 it now wakes up! activity() like you mentioned however always returns true...
Just shake the board harder, or decrease the threshold and/or duration to make it more sensitive to movement
Tried that already... did not help. But I now just spotted an item on the forum referring to DFU update 0.0.8... that is only 9 days ago. I am beginning to wonder if I have 0.0.8... Will check it out and report back.
Hi @meirssv, I've tried on several boards and the wakeup is done every time. Just shake the board harder, or decrease the threshold and/or duration to make it more sensitive to movement:
# enable the activity/inactivity interrupts # set the acceleration threshold to 2000mG (2G) and the min duration to 200ms acc.enable_activity_interrupt(2000, 200)
On the other hand, the led flashes red every time, even if the wakeup was done by reset, or timeout. Here more investigation will be done.
I tried the example, everything has the latest firmware, I used the latest lib's (with the new pycoproc.py lib) but I cannot make this example script work.
I tried with 2 different PyTrack-boards (all flashed with latest firmware) and tried it with a LoPy and a SiPy, both having the latest firmware. The device NEVER wakes up from movement. And it ALWAYS shows a red led flash, indicating activity...
I assume this example script will:
- wake up after 5 minutes if no movement detected
- wake up when movement detected
- will flash red when activity detected
- will flash green when no activity detected
Am I correct about my assumptions? If so, did I forget something obvious because it doesn't work?
seb last edited by
The board only features a 3 axis accelerometer. Without either a gyroscope or a magnetometer it is not possible to detect the yaw of the board.
han last edited by
In the new library file for the LIS2HH12 is the part for the yaw function missing.
Is there a reason for?
Because in the previous code the yaw function was well included.
ledbelly2142 last edited by
Nice! That will be helpful.
joeri last edited by
@cfaessler the method Daniel has used automatically switches the accelerometer to a lower refresh rate (10Hz) for which the power consumption is about 0.05mA. Very minimal impact. http://www.st.com/content/ccc/resource/technical/document/datasheet/c9/16/f2/79/ca/31/47/89/DM00096789.pdf/files/DM00096789.pdf/jcr:content/translations/en.DM00096789.pdf#page11
cfaessler last edited by
Hello @daniel what are the impacts on deep sleep power consumption?