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:
my_sentence = com.readline()
for x in my_sentence: