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

    Use accelerometer to put module to sleep.

    Scheduled Pinned Locked Moved GPy
    4 Posts 2 Posters 44 Views 2 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.
    • S Offline
      Steven Owen
      last edited by

      I think this may just be my not correctly understanding the inactivity function of the accelerometer on pytrack/pysense, but I can't find an explanation anywhere.

      I have a tracking app in development that determines the gps coordinates of my caravan using a GPy/Pytrack combination, and sends the data to io.adafruit.com via Cat M1...works great.

      The unit is powered by a battery, which is recharged by a small solar panel incorporated in the case, so power is not really an issue but I want to stop sending data when the caravan is stopped for a predetermined period of time, say 10 minutes. I'd like to use the accelerometer to determine when the caravan is stopped and then use the go_to_sleep function to power down.

      Any assistance appreciated.

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

        Hi,
        Going to sleep on no movement could depend on some factors, like the wait time and acceleration duration. You could use an interrupt to detect activity, and then sleep if you did not notice any movement in 10 minutes? There's an example here: https://github.com/pycom/pycom-libraries/issues/132#issuecomment-769904878 (sorry for the obscure location, we're still finalising the documentation)

        On the Pytrack 2 / Pysense 2 we do have an issue with waking up from the interrupt in the go_to_sleep function, as explained in the thread. The v16 firmware provides a software workaround there. To upload it to your Pytrack2, have a look at this page: https://docs.pycom.io/updatefirmware/expansionboard/

        Best,
        Gijs

        S 1 Reply Last reply Reply Quote 0
        • S Offline
          Steven Owen @Gijs
          last edited by

          @Gijs thanks for the response. I can get the Pytrack (1 not 2) to wake on activity, that's simple...I still don't understand the code sequence to have it wait for 10 minutes for inactivity before going to sleep, unless that is simply a loop.

          The Pytrack is still measuring gps coordinates during the 10 minute window.

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

            What happens after you call py.go_to_sleep(), is the Pytrack coprocessor cuts off the supply power to the microcontroller. This is the lowest power sleep state available. On the accelerometer wake, the coprocossor switches the power back on, meaning the Gpy will boot up as if it was just plugged in (starting with boot.py and continuing in main.py). If you have a pytrack 1, you do not have to use the workaround provided in the link I posted.

            The suggestion to wait 10 minutes is because sometimes you have to wait for traffic lights and such, where you do not want to turn off the tracker. I would take the inactivity interrupt (which follows the activity interrupt, when the movement is on the falling edge) from the accelerometer, and note down the time. Then, in the main loop check that time against the current time and see if the 10 minutes have passed. If so, go to sleep and make it wake on accelerometer. You'll have to set the sensitivity just correct that it does not wake up on small movements of entering and exiting the caravan, but that it does trigger on driving it on the road I presume.

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

            Pycom on Twitter

            Pycom