Arduino: build GPS tracker - how it works
In this practical tip we explain how you can easily build a GPS tracker with the Arduino.
Step 1 - connect GPS module to Arduino
We are using a NEO-6M GPS module at this point.
- First connect VCC to 5V and GND to the ground.
- Then RX is connected to pin 4 and TX to pin 3 on the Arduino.
Step 2 - program the GPS module
To be able to use the module, you must first ensure that you have already installed the "TinyGPS" library.
- First import them with the "#include" command. You also need the SoftwareSerial library: "#include"
- First create with the command "SoftwareSerial gpsSerial (3, 4);" a new SoftwareSerial object and with the command "TinyGPS gps;" an instance of TinyGPS.
- In the setup method, the serial connection to the GPS module ("gpsSerial.begin (9600);") and the serial monitor ("Serial.begin (9600);") for data output are started.
- In the loop method, a while loop is first inserted, which checks whether the GPS module can be reached: "while (gpsSerial.available ()) {}"
- In the curly brackets there is an if statement that checks whether data has been received: "if (gps.encode (gpsSerial.read ())) {}".
- If so, you can use the command "gps.f_get_position (& lat, & lon);" can be called up and output, for example, with "Serial.println (String (lat) +" "+ String (lon))" in the serial monitor.
In the next article, we'll explain how to set up a GSM module on the Arduino. You can also easily connect to the mobile network and send SMS, for example.