Accelerometer wake-up features added to Pytrack and Pysense
-
Hello everyone,
We have updated the libraries to enable accelerometer wake-ups on Pysense and Pytrack.
The relevant commit is the following one:
https://github.com/pycom/pycom-libraries/commit/a355ecec8f0bf021aa35a0d6f1b2d9cf85ef38fdAnd here's an example of usage:
https://github.com/pycom/pycom-libraries/blob/master/examples/accelerometer_wake/main.pyI hope that you can find this feature useful. All kinds of feedback are very much welcome!
Cheers,
Daniel -
Awesome! This will help me out a lot!
-
Hello @daniel what are the impacts on deep sleep power consumption?
-
@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
-
Nice! That will be helpful.
-
Hello @daniel,
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. -
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.
-
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?
-
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.
-
@catalin said in Accelerometer wake-up features added to Pytrack and Pysense:
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.
-
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...
-
@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") -
@catalin said in Accelerometer wake-up features added to Pytrack and Pysense:
@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!
-
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.
-
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 -
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.
-
@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. -
@catalin
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. -
@thomasp
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.
-
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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login