GPS Module
GPS devices are getting very small and very cheap, and they pretty much all use the NMEA standard. This transfers simple human-readable serial data at 9600 baud.
To use a GPS module, just wire it up as follows. I'm using the Ublox NEO6MV2 module:
GPS | Espruino |
---|---|
VCC | Bat |
RX | C10 |
TX | C11 |
GND | GND |
Note: The Ublox NEO6MV2 has a voltage regulator on board - however if you have a different module then it might need a 3.3v supply.
For software, just do something like the following:
Serial4.setup(9600,{tx:C10,rx:C11});
var gps = require("GPS").connect(Serial4, function(data) {
console.log(data);
});
This will return data every second that looks a lot like:
...
{ "time":"16:35:29", "lat":53.068403, "lon":-4.076282,
"fix":1, "satellites":7, "altitude":1085.0 }
...
The latitude and longitude are in degrees North and East respectively, and altitude is in meters.
Not getting anything? GPS devices often take several minutes to get a GPS lock and some may not output data until they have it. Mobile phones get a lock much faster because they have rough time and location information from the mobile phone mast to help with the fix.
There's a lot more data available from the GPS (such as velocity).
To hook onto this you can use the line
event which is called every time a
line of data is received from the GPS:
Serial4.setup(9600,{tx:C10,rx:C11});
var gps = require("GPS").connect(Serial4);
gps.on('line', function(line) {
console.log(line);
});
You can also use the method above to help to debug if you're not receiving a callback from the GPS module.
Using
Buying
This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.