How to wake up the lopy with the accelerometer
-
This post is deleted! -
@jcaron For now I received a 2000 mAh battery but it's only for testing I know it won't be enough for my application.
I will study the possibility to use the ULP co-processor, maybe it is the only way for me to achieve my project, I'll check the LIS2HH12's datasheet in details, maybe there is something interesting I didn't see.Something I don't understand is the machine.sleep(), when I use it, the program stop working during the time of the sleep then it wake up and execute the rest of the program so I'm not able to let it do something during the machine.sleep.
Furthermore, with @railmonitor's code, interruptions works only with the button but not with the accelerometer, I don't know why...And during the lightsleep, when I push the putton, the wake-up reason is (0,none)
-
@CeylordZ I've never used light sleep, so I don't really know how it interacts with the rest (i.e. if
machine.pin_sleep_wakeupactually affects getting out of light sleep or not).BTW, going very very quickly through the
pin_sleep_wakeupsource and the Espressif docs, I believe the code from @railmonitor above has an issue: it seems to me that each call topin_sleep_wakeupwill "replace" all previous settings, so you need to have all pins in the array in the same call, and they should all use the same mode.I did not actually check or test it, but that's my understanding from a quick glance through the code and docs.
As for the wakeup reason, another quick glance through the source also makes me think it is only initialised (in the firmware) during the boot process, so only after a deep sleep, not a light sleep. This one should be easily fixable in the firmware (adding another separate call I would think, there's probably a reason the value is stored rather than returned directly from the ESP-IDF in the current function).
-
@jcaron @CeylordZ
I think I agree with your analysis that the call to machine.pin_sleep_wakeup overwrites previous settings.
I'm experimenting also using the example code of the accelerometer.
As provided, the code reliably wakes on button press. But doesn't wake on movement.
If the line for setting up the wakeup for the button P13 is removed. the accellerometer does now wake up!I'm continuing to work on this and if/when I get reliable code I'll post it.
-
@johnmcdnz Hi, have you achieved any progress with the accelerometer?
-
@Flavio-Frattini Yes I did (sorry for delay in replying)
as said before the code should only call machine.pin_sleep_wakeup once with the setup. Therefore it can either be used to wakeup with the button or the accellerometer, but can't use both.#Enable interrupts from accelerometer (P13) and button (P14) JMCD: bug report, only use one of these lines, subsequent calls overwrite earlier setup machine.pin_sleep_wakeup(['P13'], mode=machine.WAKEUP_ANY_HIGH, enable_pull = False) # enable activity and disable inactivity interrupts, using the default callback handler py.setup_int_wake_up(True, False) # set the acceleration threshold to 500mG (0.5G) and the min duration to 200ms acc.enable_activity_interrupt(500, 200) -
Any chance that you got further with this code and are willing to share?
-
The latest example is available here: https://docs.pycom.io/tutorials/expansionboards/sleep/, for use with the latest pycom libraries.
-
@Gijs Hi thank you. i did see this earlier, but i could not find anything about recording that wake up value. I assume once the unit wakes up i could take a reading, but that reading that caused the wake up would be missed correct?
-
Yes, as the reading is only caught on the interrupt, before the microcontroller wakes up, we cannot see the data
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