Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    How to wake up the lopy with the accelerometer

    Scheduled Pinned Locked Moved Discussion
    23 Posts 7 Posters 637 Views 8 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      CeylordZ @jcaron
      last edited by

      This post is deleted!
      1 Reply Last reply Reply Quote 0
      • C Offline
        CeylordZ @jcaron
        last edited by CeylordZ

        @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)

        J 1 Reply Last reply Reply Quote 0
        • J Offline
          jcaron @CeylordZ
          last edited by

          @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_wakeup actually affects getting out of light sleep or not).

          BTW, going very very quickly through the pin_sleep_wakeup source and the Espressif docs, I believe the code from @railmonitor above has an issue: it seems to me that each call to pin_sleep_wakeup will "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).

          J 1 Reply Last reply Reply Quote 2
          • J Offline
            johnmcdnz @jcaron
            last edited by

            @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.

            F 1 Reply Last reply Reply Quote 0
            • F Offline
              Flavio Frattini @johnmcdnz
              last edited by

              @johnmcdnz Hi, have you achieved any progress with the accelerometer?

              J 1 Reply Last reply Reply Quote 0
              • J Offline
                johnmcdnz @Flavio Frattini
                last edited by

                @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)
                
                
                1 Reply Last reply Reply Quote 2
                • B Offline
                  Bryan Hom
                  last edited by

                  @johnmcdnz

                  Any chance that you got further with this code and are willing to share?

                  1 Reply Last reply Reply Quote 1
                  • G Offline
                    Gijs
                    last edited by

                    The latest example is available here: https://docs.pycom.io/tutorials/expansionboards/sleep/, for use with the latest pycom libraries.

                    B 1 Reply Last reply Reply Quote 0
                    • B Offline
                      Bryan Hom @Gijs
                      last edited by

                      @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?

                      1 Reply Last reply Reply Quote 0
                      • G Offline
                        Gijs
                        last edited by

                        Yes, as the reading is only caught on the interrupt, before the microcontroller wakes up, we cannot see the data

                        1 Reply Last reply Reply Quote 0

                        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
                        • 1
                        • 2
                        • 2 / 2
                        • First post
                          Last post

                        Pycom on Twitter

                        Pycom