Author Topic: Sending GNSS data over Sigfox  (Read 578 times)

jflores

  • Newbie
  • *
  • Posts: 27
    • View Profile
Sending GNSS data over Sigfox
« on: November 30, 2016, 11:10:14 am »
I'm trying to send the location of the device through Sigfox using the Product specification samples.
I don't understand exactly where the Lat and Long are being stored, nor displayed (Is there a print option?).
I'd like to set them as a list of bytes to do this as in the Sigfox sample, or a recommended way I don't know :p
Thanks in advance.

Share on Facebook Share on Twitter


mc-John

  • Global Moderator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #1 on: November 30, 2016, 05:54:28 pm »
Page 11, figure 3-1 describes sigfox and Page 12, figure 3-2 describes GNSS. In line 11 the GPS is started. When the GPS has found a location or times out the event LocationDelivery is activated in line 14. Then the lat/long are retrieved in line 18 and 21. So after that you can send them over sigfox. You can set a breakpoint when LED2 is switched off, in line 29 and just read the value out by hovering over the variables lat and lon.
To add them to a list of byte just use the method AddFloat

jflores

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #2 on: November 30, 2016, 06:41:46 pm »
Thanks, setting the breakpoint is what I was missing as well as the AddFloat. I'll check this and let you know.

I'm trying to build a use case that requires storing this GPS lat/long. I'm wondering if there is a way to storing this in the board itself. I found that a sd memory can be used via SPI, but I need to know how many Mb can I use and a reference to connect it, I found a case in the McScript which uses 2 8Mb cards, but it's not specific for which board it works.

Thanks a lot for the help!

mc-John

  • Global Moderator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #3 on: November 30, 2016, 08:23:36 pm »
As far as I know the board itself has a lot of persistent (flash) memory that can be used to store data. You can read that data later and send it over mcAir to the cloud. Not all software is in place and it depends what you want to do.
Let me know what you want to store, how often and how much, when you want to read it and other information and maybe we can help you with it.

jflores

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #4 on: December 01, 2016, 09:28:16 am »
We have a script that checks the base stations that received the message from the device and traces them in a map downloading a .xls file from sigfox.
We want the device to be sending the GPS location through Sigfox and also to keep it storing those locations in case the message is not sent, that's the reason for the memory. We'd like it to do this every 10 min~, and then download the data to compare this files.
I don't think this requires a lot of memory, but I'm not sure the amount this demo has, maybe you can help me with this. Tell me if I'm missing some other information please.

jflores

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #5 on: December 01, 2016, 09:56:49 am »
I'm having some trouble with the GNSS file, not sure if I'm doing something wrong. I set a breakpoint as you said, ran the code and paused to check lat/long but value is empty. When I don't do this and just run the code, timeout doesn't seem to be working properly. Led2 stays turned on forever, need to restart device to try compile again.

mc-Josh

  • Global Moderator
  • Newbie
  • *****
  • Posts: 27
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #6 on: December 01, 2016, 03:45:03 pm »
@jflores:
Please post the entire mcSript project so we can look into this problem? Also, you are using an mcDemo205, correct?

Thanks,

Josh

jflores

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #7 on: December 01, 2016, 11:19:37 pm »
Yes, I'm running the GNSS code from the product specification, atm I'd just like to get the lat and lon sent through sigfox and see the memory available from the device. The code is this one.

Code: [Select]
01 Class GNSSDemo
02
03 'GNSS Configuration Constants
04 Const GNSS_TIMEOUT_uS As Integer = 120000000 'GNSS Timeout = 120s
05 Const GNSS_MIN_SAT_COUNT As Integer = 3 'GNSS minimum sats = 3
06
07 'initiate GNSS acquisition on Button 1 press
08 Shared Event SW1FallingEdge()
09 'turn on LED2 to indicate GNSS acquisition started
10 LED2 = True
11 Device.StartGPS(GNSS_TIMEOUT_uS, GNSS_MIN_SAT_COUNT)
12 End Event
13
14 Shared Event LocationDelivery()
15 'Called when GNSS location acquired or timeout occurred
16
17 'Get latitude
18 Dim Lat As Float = Device.GetLatitude()
19
20 'Get longitude
21 Dim Lon As Float = Device.GetLongitude()
22
23 'Get GNSS fix time
24 Dim Time As Integer = Device.GetGpsFixTime()
25
26 'Do something with GNSS data (send over Sigfox, etc)
27
28 'turn off LED2 to indicate GNSS acquisition complete
29 LED2 = False
30 End Event
31
32 End Class

jflores

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #8 on: December 06, 2016, 05:43:48 pm »
UPDATE: It doesn't seem to be a problem with the code, setting breakpoints on different codes worked fine. Idk why it wasn't reaching the timeout, but now it does.

Right now I'm receiving NaN value from both lat - lon, I thought that doing it indoors was being the problem, but doing it outside isn't giving me values either. Is there some configuration I need to set for the current country or any other idea?

mc-John

  • Global Moderator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #9 on: December 06, 2016, 09:20:34 pm »
You get NaN if it can't find a position. You have to be away from a building (20 meter) and you have to have the antenna pointing to the sky. The antenna is the yellow/white block above the Sigfox and mcThings logo

jflores

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #10 on: December 12, 2016, 02:05:58 pm »
Thanks, it was a problem with the place I was doing the tests. I'm getting all the expected data with the breakpoints. Now I'd just like to understand how is this set of bytes coded/ordered.

E.g. This the last message I received from sigfox: 06a2479b41b357c6c2193f00 and the attached image are the values after sending the data through sigfox.

Short story, the code looks like this, I just want to know the lat and lon codification which belong to a2479b41 and b357c6c2 respectively.
Code: [Select]

Shared Event LocationDelivery()
        Dim Lat As Float = Device.GetLatitude()
        Dim Lon As Float = Device.GetLongitude()
        Dim msg As ListOfByte = New ListOfByte()
End Event

Shared Event Message()
   msg.AddFloat(Lat)
   msg.AddFloat(Lon)

   Lplan.Sigfox(msg)
End Event
« Last Edit: December 12, 2016, 04:10:05 pm by jflores »

mc-Abe

  • Full Member
  • ***
  • Posts: 167
    • View Profile
    • mc-Things
Re: Sending GNSS data over Sigfox
« Reply #11 on: December 13, 2016, 11:00:02 am »
The data that you place in the message structure using AddFloat is in Little Endian Float format so 0xa2479b41 equates to 19.41 in float.

You can use a tool like this: https://gregstoll.dyndns.org/~gregstoll/floattohex/ to see the conversion. Note that you have to flip the bytes since the tool is expecting data in Big Endian. So use 0x419b47a2 when you use this tool.

Add float placed data in using Little Endian by default as it is the native format of the processor. You can use an overloaded version of AddFloat to place the data in, in Big Endian format if you prefer.

Also the Sigfox backend has the ability to parse bytes into meaningful data but you need to look at their documentation for that.

jflores

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #12 on: December 14, 2016, 06:15:14 pm »
I wasn't understanding how those worked, for the record I used a custom parse in sigfox backend to display that data. Just 2 things to end this topic.

1. If I wanted to set them as Big Endian, which would be the function?

2. I'm still pending the data stored in the mcdemo205. At the moment I wrote something like this:
Code: [Select]
Dim LatList as ListofByte = New ListofByte()
Dim LonList as ListofByte = New ListofByte()

If lat <> 0 then
   Lplan.Sigfox(msg)
   LatList.Add(Lat)
   LonList.Add(Lon)
End If
My doubt is if this works and how could I retrieve this info from the demo? I see this can be done through McAir but I don't get how :P Have you got a reference to use it?

jflores

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Sending GNSS data over Sigfox
« Reply #13 on: December 22, 2016, 12:24:54 pm »
Is there a guide to use the gateway? I want to do something like this:
Code: [Select]
Do
 //Search for available gateway
 Continue Do
 Lplan.latList(#Send through Gateway)
 Lplan.lonList(#Send through Gateway)
 [Exit Do]
While
//Lplan.latList(#sent) = True
Lplan.lonlist(#sent) = True

I want to send the GNSS data through sigfox and confirm the locations that were sent by storing this data and downloading after I reach 50~ locations. Could I get some help on this topic?