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
-
@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
-
@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,
-
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 ?