mei 142017
 

At AliExpress they sell a number of cheap GPS modules that you can use for Arduino. I ordered one (this one) GY-NEO6MV2 for €6,82 incl. free shipping (the seller doesn’t offer free shipping anymore so you might want to shop around a bit) and wanted to try it out on the LoPy. Now, I wanted to say that using it is really easy, it is, but then again there were more than enough bumps in the road to get it to work the way I wanted it. But hey, what is life without some challenges?

First things first: the GPS module is easy to use. It use UART to connect to it. As soon as you have got something that is willing to listen to it, power it (it worked using 3.3V), it start sending you GPS data that you only need to interpret. I soldered 4 header pins to the module, connected the VCC to the 3.3V, GND to GND on the Pyboard, the TX line to “P11” and the RX line to “P12”.

As soon as you connect power to the LoPy, the GPS unit is powered. The red light blinking means that the unit is working and sending data. You just need to listen to it.  The code to do that is available here on GitHub.

To start listening:  com = UART(1,pins=(config.TX, config.RX), baudrate=9600)

To interpret the data coming from the module, I use the MicropyGPS module. It is initialized using my_gps = MicropyGPS().

After that it is a matter of checking if there is any data available, and then feed it character by character to the module:

if com.any():
    my_sentence = com.readline()
    for x in my_sentence:
        my_gps.update(chr(x))

 

So far so good. Next challenge was how to encode the coordinates in a way that makes the data usage optimal. I found a post at The Things Network forum about it and used that to create a function that does that in microPython:

You can find it in the tools.py file. It handles both negative and positive coordinates (by adding +90 / + 180) and multiply by 10000 to make sure we have an integer with all the wanted details intact. Of course, by the time the data is received by the TTN server, we need to reverse that. For that, I use the payload decoder:

And that is it. LOL, writing it down, it all seems so easy.

I did want to combine sending the data to TTN with writing it to a log file on the SD card. Writing to the card was easy, but for it I needed/wanted a valid date / time to write along with the coordinates. I tried getting it from the GPS, but that didn’t work reliable enough. Then I tried RTC() combined with a connection to a NTP time server, but that failed at first also. It is possible that there is a problem combined with using a static IP address, but to be sure about that, I would have to upgrade the firmware to the most recent.

Next up is connecting the module to the Marvin module. Should work also, but then with a different connector (grove) and of course a different module (TinyGPS++) to interpret the data. And of course, the logging option still needs to be completed.

 

Deel dit bericht:

  5 reacties aan “LoPy + GPS receiver on The Things Networks”

Reacties (3) Trackbacks (2)
  1. I’m interested to see how you get on with this. Are you logging because sometimes the LoRa/GPS will be out of range of a Gateway? If so, do you intend to store and then resend when the (any) Gateway comes back into view?

    This functionality is missing from all the LoRa/GPS solutions being offered for sale, well, up to now anyway.

    Do keep posting. Thanks. Paul.

    • No, I would probably not send it over LoRaWAN in that case. I don’t think (in a moving situation) that LoRa is the best option if you want 100% of the data to be received.
      But, say you take the container on a truck example. If you receive a location (+ temperature in case it is load that needs to be cooled) about every 5 minutes, that would be enough to keep track of it and to be alerted if temperature increases too much.
      Then you might have the node transmit the daily logs only when it gets into wifi range, say when the truck is back in the parking lot again at night.

      In my case, I would be useful for experiments like taking them on a train ride making it more easy to get an idea for the amount of packets lost while traveling.

  2. If you have a WiFi module, it is often possible to join open captive portals and transfer data through DNS lookups. A time_lat_lon.log.yourdomain.com request would be very easy to extract just from logs.

Sorry, het reactieformulier is momenteel gesloten.