board goes to sleep befote it sends out data to pybytes
-
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
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