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. LoPy + cheap GPS receiver on The Things Networks @pycomIOT @thethingsntwrk #GPS #MicroPython… https://t.co/OnFHiwMlqg

  2. LoPy + GPS receiver on The Things Networks https://t.co/gVv7xIOtBE @pycomIOT. New Story on Labs by @PeterMcAllister… https://t.co/qKJaizvS14

Sorry, het reactieformulier is momenteel gesloten.