Data format for Sigfox transmission
-
Hi Folks,
I'm stepping out of my comfort zone here and I'm sure I'm struggling on a simple task but I hope you can help.
I've successfully integrated a Sipy into a 3rd party monitoring platform via Azure, works beautifully.
However my test has involved simply sending example text eg
s.send("23005000") #send 23.00°C and 50.00%rhNow I want to obviously use a variable to insert the real temp and humidity (for example), I feel I have tried a million permutations of hex, bytes etc etc and always get a error or the data is not received correctly on the Sigfox backend.
Can anyone give me a steer here on the correct approach (using micropython) or point me to some suitable documentation
Out simply eg the below is clearly wrong, so how do you process a float for transmission?
temp = 23.00 hum = 50.00 s.send(temp+hum)Thanks
-
-
Ok... so can you explain how do you create a list of bytes from a int or float for example? Would you just chop it up into individual characters or use hex?
-
@jez You can use the ustruct module to get a packed byte string. See https://docs.pycom.io/firmwareapi/micropython/ustruct/. If you prefer readable content, you can use one of the two format methods: % operator or str.format(). The result is a str, which you may have to convert to a bytes object with str.encode().
Both is pretty much standard Python.
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