How to make sense of gps data sent to sigfox
-
Hi all,
I'm trying to send latitude and longitude from the Pytrack to sigfox. The code I am using to do this is this:
print(str(latitude), ":", str(longitude)) s.send(struct.pack('f',float(latitude)) + struct.pack('f',float(longitude)))The print command gives me this:
51.753743 : -1.252524
but in Sigfox I see this:
d5034f42b552a0bf
ASCII: ..OB.R...You can see this in the attached image

I've also tried this:
s.send(str(latitude), ':',str(longitude))but it wasn't helpful. Can anyone help make this text something useful?
Eventually I'd like to be able to automatically view this on a map. Could anyone help with that? would AWS be helpful here?
Thanks
-
lat=b'\xd5\x03\x4f\x42
struct.unpack('f',lat)
(51.75374221801758,)lon=b'\xb5\x52\xa0\xbf'
struct.unpack('f',lon)
(-1.2525240182876587,)It's seem your sensor will to be near oxford isn't it ?
-
@eric73 said in How to make sense of gps data sent to sigfox:
struct.unpack('f',lat)
That's awesome, thanks!
However, I do not understand what you did. How (and why) did you know to write it like this:
lat=b'\xd5\x03\x4f\x42
Thanks,
-
@james-matthews struct.unpack work with "byte" objet. As we have to unpack a float this "byte" object must have a size of 4 bytes. [https://docs.python.org/2/library/struct.html]
This float , have been packed in a binary form
'''s.send(struct.pack('f',float(latitude)) + struct.pack('f',float(longitude)))'''
then sent to sigfox backend data and showed in hexadecimal
'''d5034f42b552a0bf'''
so, to have original value you just have to unpack it from hexadecimal to float
''' lat=b'\xd5\x03\x4f\x42' '''this is the way to create and assign hexadecimal value to a 'python byte object' with len=4
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