The Global Positioning System (GPS), is a satellite-based navigation system that allows users to determine their precise location on Earth. It was developed and is maintained by the United States Department of Defense. GPS consists of a network of satellites orbiting the Earth, ground-based control stations, and GPS receivers.
The GPS system works by using a process called trilateration. The satellites in the GPS constellation continuously transmit signals that contain information about their location and the precise time the signals were transmitted. GPS receivers on the ground pick up these signals and use the time it takes for the signals to reach them to calculate the distance between the receiver and each satellite.
Each satellite defines a sphere with a radius equal to the distance from the receiver. By receiving signals from multiple satellites, usually a minimum of four, the GPS receiver can determine its exact location by intersecting the spheres centered on each satellite. This intersection point represents the receiver's position on the Earth's surface. GPS receivers can also provide information about altitude, speed, and direction of movement.
This project shows you how to build a simple GPS logger, programmed using the visual language, XOD. If you haven't used XOD before, I recommend taking a look at the following resources:
GPS moduleA NEO6MV2 GPS module was used in this project, but you can substitute any GPS module that uses the NMEA 0183 standard for sending messages via UART. NMEA stands for National Marine Electronics Association. It is an industry standard communication protocol used in marine and land-based navigation systems to exchange data between different electronic devices.
The NMEA standard defines a specific format for the messages or sentences that are exchanged between devices such as GPS receivers, chart plotters, autopilots, and other navigation equipment. These messages contain information about various aspects of navigation, including latitude, longitude, speed over ground, course over ground, time, depth, and more. NMEA 0183 was introduced in 1983 and is the most widely used version of the NMEA standard.
Hardware assemblyFind a suitable box for housing your device. The GPS antenna is mounted on the outside of the box and all other components are located inside. Here double-sided adhesive tape has been used to fix the components to the box:
N.B. Don't connect the battery to the Arduino Mega until you are ready to start recording.
The GPS module is wired to the Arduino Mega as follows:
- VCC on the GPS module is connected to the 5V power supply of the Arduino Mega.
- GND is connected to GND (common ground).
- RX is connected to TX1 (digital pin 18 on the Arduino Mega).
- TX is connected to RX1 (digital pin 19 on the Arduino Mega).
N.B. the GPS module is connected to the 2nd UART interface on the Arduino Mega (UART1), leaving UART0 free for programming the Arduino Mega. If you have a board with a single UART interface, you will need to disconnect the GPS module when uploading a program.
The microSD module communicates with the Arduino Mega via Serial Peripheral Interface (SPI). Physical connections are as follows:
- VCC on the microSD module is connected to the 5V power supply of the Arduino Mega.
- GND is connected to GND (common ground).
- CS is connected to digital pin 10 on the Arduino Mega.
- MOSI is connected to digital pin 11 on the Arduino Mega.
- MISO is connected to digital pin 12 on the Arduino Mega.
- SCK is connected to digital pin 13 on the Arduino Mega.
The microSD card should be formatted as FAT16. Tools for formatting the microSD card can be found here:
Once formatted, the microSD card can be inserted into the microSD module.
SoftwareYou will need to install the XOD GPS library: wayland/gps. Use the File → Add Library menu item in the XOD IDE. See Using libraries for more information.
In the library there are three example patches, demonstrating how to use the available nodes. The second example patch 02-example
provides everything needed for this project:
The functions of the nodes in the patch above are as follows:
- 1 - Creates a new GPS device.
- 2 - Initializes the 2nd UART interface (UART-1) on the Arduino Mega which is used to receive messages from the GPS module.
- 3 - Parses the messages received from the GPS module.
- 4 - Reads datetime.
- 5 - Transforms a datetime into a string timestamp in the form "2018-03-25 23:35:04".
- 6 - Gets number of satellites currently being used for trilateration.
- 7 - Gets latitude and longitude.
- 8 - Formats latitude/longitude to six decimal places.
- 9 - Combines current datetime, number of satellites, latitude and longitude into a string, with each value separated by a comma (i.e. csv format).
- 10 - Writes the line generated in the step above to a file (GPS_LOG.CSV) on the micro SD card.
Upload the patch to the Arduino Mega. From the Deploy menu of the XOD desktop IDE, select Upload to Arduino... Then hit the Upload button:
When you are ready to start recording, simply connect the 9V battery to the Arduino Mega. Disconnect the battery to stop the recording.
View logOnce you have finished recording and the Arduino Mega has been powered down by disconnecting the battery you can remove the micro SD card from the micro SD module. Place the micro SD card in the card reader of your computer (you may need an adapter) and open the log file (GPS_LOG.CSV) in a spreadsheet program. Most spreadsheet programs will recognise the csv (comma separated value) format and place each variable in a separate column:
You will notice in the above example that GPS coordinates were not recorded at the first timepoint, because the GPS module hadn't found any satellites. This timepoint can be deleted. Add a header to identify each column (datetime, number of satellites, latitude and longitude):
Save the spreadsheet as a CSV file.
Plot route on mapYou can plot the data you have recorded using the MyMaps feature in Google Maps. Open https://mymaps.google.com/ in your browser. From the menu select Create a new map or click the +
icon in the bottom right corner of the window:
You will be prompted to choose a file to import:
Select your CSV file.
Next you will be asked to identify the columns in your file that contain the GPS coordinates:
The final stage of the import process is to select the column that will provide a title for your map markers. Datetime is probably a good choice:
A marker for each set of measurements will appear on the map. You can select a different base map if you wish:
Here markers are plotted on a satellite map.
Click on a marker to view the data recorded at that location:
Maps created using MyMaps can be shared with friends, colleagues, or the public.
SummaryThis project describes how to build a simple GPS logger and demonstrates some of the functionality of the XOD GPS library. It could easily be extended to incorporate sensor modules, allowing environmental measurements (e.g. temperature, humidity, etc) to be tagged with GPS coordinates and a date and timestamp.
Comments