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

    How to make sense of gps data sent to sigfox

    Scheduled Pinned Locked Moved SiPy
    gpssipylopysigfox
    4 Posts 2 Posters 1.1k Views 2 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
      james.matthews
      last edited by james.matthews

      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

      0_1532038226098_Screen Shot 2018-07-19 at 23.07.56.png

      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

      1 Reply Last reply Reply Quote 0
      • E Offline
        Eric73
        last edited by Eric73

        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 ?

        https://www.google.fr/maps/place/51°45'13.5"N+1°15'09.1"W/@51.7539049,-1.254124,17.42z/data=!4m5!3m4!1s0x0:0x0!8m2!3d51.7537422!4d-1.252524

        J 1 Reply Last reply Reply Quote 0
        • J Offline
          james.matthews @Eric73
          last edited by

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

          E 1 Reply Last reply Reply Quote 0
          • E Offline
            Eric73 @james.matthews
            last edited by

            @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

            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