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

    board goes to sleep befote it sends out data to pybytes

    Scheduled Pinned Locked Moved Pybytes IoT platform
    1 Posts 1 Posters 21 Views 1 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.
    • J Offline
      j_mor
      last edited by

      Hi all,

      I've run into an issue using pybytes on my LoPy4 with Pysense shield.
      I would like to get data from sensors, send them to Pybytes and go to deepsleep.
      I do have sepadate funcions to get the data from sensors and to send the data.
      Simplified code without any definitions and library imports:

      sensorData = getSensorData()
      sendData(sensorData)
      py.setup_sleep(sleepTime)
      py.go_to_sleep()
      

      The getSensorData() returns JSON dictionary with all the sensor data.
      The sendData() looks like this:

      def sendData(data):
          pybytes.send_signal(1, data['batt'])
          pybytes.send_signal(2, data['temp1'])
          pybytes.send_signal(3, data['press'])
          .
          .
      

      (two dots represent more lines in the function, 9 values are being sent, wanted to save some space :) )
      The problem is that calling sendData() jumps out immediately and the actual data sending process takes on later. From what I understand pybytes.send_signal() sets up a new thread with given arguments and is done.

      So when I run the code, LoPy goes to deepsleep before it actually sends out any data to Pybytes.

      Is there any flag or variable I could check to see if my Lopy board is still sending out the data and in that case wait before going to deepsleep??

      Something like:

      sensorData = getSensorData()
      sendData(sensorData)
      while(True):
          if not "pybytes_still_sending_data":
              py.setup_sleep(sleepTime)
              py.go_to_sleep()
      

      Possible workaround may be to put time.sleep() for like 20 sec before the deepsleep, but I would like to avoid this "solution".

      Thank you,
      j_mor

      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