geo logger
DESCRIPTION
geo logger project from instructables. uses accelerometer and GPS.TRANSCRIPT
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 1/20
Geo Data Logger: Arduino+GPS+SD+Accelerometer to Log,Time-stamp and Geo-tag Sensor Data
by techbitar
PDATES
Oct 17, 2013: I have published a guide on using your Android phone to accomplish a similar task byleveraging your Android device's built in GPS and sensors.Feb 6, 2013: Featured on GeoAwesomeness http://geoawesomeness.com/?p=3388 Nov 24, 2012: Featured on Hackaday http://goo.gl/XX9oy Nov 21, 2012: Featured by John Boxall @ Freetronics http://goo.gl/OvnNC Nov 20, 2012: Featured on Dangerous Prototypes http://goo.gl/ve6Eu
TRODUCTION
I thought it would be educational to build a prototype that I can take on the road to log, geo-tag, and
amp sensor data to be analyzed later with mapping and/or data analysis applications. So I figured why noh a gadget that can log road conditions. This prototype, the Bump-O-Meter, measures road conditions by usiduino, a GPS receiver, an SD card, and an accelerometer sensor.
This prototype is a generic sensor logging/geo-tagging gadget which means the accelerometer cplaced with any other sensor(s) to log and map anything anywhere.
As a matter or fact my next adventure with this logger is to replace the accelerometer with a pollution svisualize levels of air quality around town.
ROJECT SECTIONS
is guide is divided into the following sections:
Overview & BackgroundHardware & Software ComponentsWiring the PrototypeLogging data to the LC STUDIO SD CardGeo-Tagging & Time-Stamping With the LS20031 GPS ReceiverMeasuring Road Condition with an ADXL335 AccelerometerPROGRAM: The Arduino Program That Pulls It All TogetherPROGRAM: A Plain GPS Logger To Interface With Google EarthScrubbing & Formatting Data with a Spreadsheet
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 2/20
Plotting and Color-coding Road Condition Data with GPSvisualizer.com
Formatting GPS Date/time Output For Stamping Data Speed vs. Logging Accuracy
ROJECT OVERVIEW
The Bump-O-Meter uses an Arduino to capture the X,Y,Z motion data generated by the ADXcelerometer. In this case, we are measuring road "shakiness" as a result of road condition. Poor road condd uneven road surfaces generate lots of sudden acceleration in the car body up and down (z-axis). But befor
ta is saved to the SD card, it's tagged with location information from the LS20031 GPS receiver and also dateamped in real-time using the GPS satellites' atomic clock. More on this later.
We want to capture and analyze the z-axis acceleration information visually to determine which road stree poorer and need attention. We can repeat this and compare our data over time. The possibilities are ent just for road condition scanning, but for any sort of environmental geo data logging.
OW TO USE
We can use this gadget by placing it in a car and driving over a given road stretch to assess its conditionn even attach this prototype to a bike or skateboard to identify irregular and rough stretches of tracks.
We can substitute the ADXL335 accelerometer sensor with any other sensor(s) such as temperatulution sensors with simple code modification.
The data on the SD card can then be imported it into a spreadsheet for scrubbing, sub-setting, reformaalysis, and visualizing.
We will also make use of a wonderful website GPSvisualizer.com to plot our data over a map using intelarkers that change shape and color according to magnitude of road shakiness so we can visually detectnditions in need of further inspection.
I have published a guide titled "Connect your LS20031 GPS receiver to Google Earth via PC" explainingconfigure the LS20031 GPS receiver. You can refer to it for more details on how to use the LS20031ceiver.
ARDWARE & SOFTWARE COMPONENTS
ARDWARE
Arduino Uno or Leonardo*: $25 (Arduino.cc, Seeedstudio.com)LS20031 GPS receiver: $50 (Ebay, Pololu, Adafruit, Sparkfun)ADXL335 or ADXL345 Accelerometer (or any other sensor): $7 (Ebay.com)
SN74AHC125 as level shifter from 5V to 3.3V**: $1 (Mouser.com, Futurlec.com)SD reader socket. The LC STUDIO: $2.50 (Ebay.com)SD memory card. $5 for 4GB.LED: $0.1Resistor 1K Ohm: $0.1Breadboard: $5Jumper wires: $2Male headers 2.45mm (0.1") - straight and right angle: $1 (Ebay.com)Any battery or power source that can provide 7-12V and a minimum of 500mA.
* I have not tried this prototype with the Arduino Leonardo because of some known issues with the SD lib
But according to the release notes of the Arduino IDE 1.02 software these issues have been addressed.
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 3/20
** In the future, I am phasing out the SN74AHC125 level-shifter (5V to 3.3V converter) in favor of the CD40HEX Non-Inverting Buffer/Converter simply because it's more readily and cheaply available on Ebay.cpurchased 10 ICs for $4.0. That's $0.4 per IC. The CD4050 is not pin compatible with the SN74AHC125 butare plenty of examples on the net.
OFTWARE
Arduino IDE 1.02MiniGPS 1.4: This is a nifty utility to configure the LS20031 GPS receiver.GPSvisualizer.com: This amazing website will help us plot logged sensor data along with the GPS coordinat
using color schemes to indicate road conditions.MS Excel or comparable spreadsheet: We will use a spreadsheet to scrub the logged data, to removegarbage, to make sub-selections of our logged, and to format it in a manner that can be read by applications and websites such as GPSvisualizer.com and Google Earth.SD Arduino library (bundled with Arduino IDE)
DEO OF IMPORTING/REFORMATTING LOG FILE
SCLAIMER
is is a prototype and prototypes by definition are drafts of products not finished yet. Your feedback is apprecia
ONTACT
zim Bitar (techbitar)
chbitar at gmail dot com
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 4/20
TEP#1: WIRING THE GEO-LOGGER
RING THE ARDUINO
ND GND rail of the breadboard (usually the blue row)
To 5V VIN of the SD card
3V To the positive rail (red-lined row) of the breadboard
N13 PIN5 (2A) of the SN74AHC125 IC
N12 SD MISO PIN
N11 PIN2 (1A) of the SN74AHC125 ICN8 LED POSITIVE
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 5/20
N4 PIN12 (4A) of the SN74AHC125 IC
N1(TX) PIN9 (3A) of the SN74AHC125 IC
N0(RX) PIN TX of the LS20031 GPS Receiver
NALOG0 PIN X of the ADXL335 (or any analog sensor output)
NALOG1 PIN Y of the ADXL335 (or any analog sensor output)
NALOG2 PIN Z of the ADXL335 (or any analog sensor output)
ND (bottom) GND rail bottom of the breadboard
RING THE SN74AHC125 IC
N1 (10E) GND rail of breadboard
N2 (1A) Arduino PIN11
N3 (1Y) SD MOSI PIN
N4 (20E) GND rail of breadboard
N5 (2A) Arduino PIN13
N6 (2Y) SD SCK PIN
N7 GND GND rail of breadboard
N9 (3A) Arduino TX PIN1
N8 (3Y) GPS RX PIN
N10 (30E) GND rail of breadboardN12 (4A) Arduino PIN4
N11 (4Y) SD CS PIN
N13 (40E) GND rail of breadboard
N14 (VCC) Arduino 3.3V pin
RING THE SD CARD SOCKET
ND GND rail of breadboard
3V No connection
Arduino 5V pinS PIN11 (4Y) of the SN74AHC125 IC
OSI PIN3 (1Y) of the SN74AHC125 IC
CK PIN6 (2Y) of the SN74AHC125 IC
SO Arduino PIN12
ND GND rail of breadboard
RING THE LS20031 GPS RECEIVER
ND GND rail of breadboard
ND GND rail of breadboardArduino PIN0 (RX)
X PIN8 (3Y) of the SN74AHC125 IC
CC 3.3V rail of the breadboard
RING THE ADXL335 ACCELEROMETER
ND GND rail of breadboard
Arduino ANALOG2
Arduino ANALOG1
Arduino ANALOG0
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 6/20
3V 3.3V rail of breadboard
No connection.
TEP#2: THE SD CARD
OGGING TO THE SD CARD
The SD card, or Secure Digital card, is a non-volatile solid-state flash memory. Meaning if we disco
wer, it will retain its data. With an SD card we can expand Arduino's permanent storage by gigabytes. T
eful for applications that store large amounts of data such as data loggers. A 4GB SD card can be had for onl
OWERING THE SD CARD
The LC STUDIO SD card socket used in this project can be powered with 5V or 3.3V power sources. Th
LM1117 3.3V regulator on board which can handle 800mA of current. The Arduino can provide 3.3V direct
limited to 50mA. That's not enough to power the SD card. So I powered the SD card socket from the Ard
o's 5V pin which can handle over 500mA of current. The 5V pin on the SD card socket will pass throug
M1117 regulator and come out a 3.3V with a current ceiling of 800mAh.
Just because this SD card socket can be powered with 5V or 3.3V, we still can't connect 5V Ar
ns to the SD card socket's pins. We have to level-shift the Arduino's 5V signals to 3.3V before we can coem to the SD card.
This is where the SN74AHC125 IC comes in handy. This IC can convert (level-shift) a total of 4 signals
to 3.3V. This is perfect because for this project, I only need to convert 4 Arduino pins from 5V to 3.3V: th
e SD card socket and one to the LGS20031 GPS receiver which is also a 3.3V module.
LTERNATIVES TO THE SN74AHC125
You can replace the SN74AHC125 with the more available CD4050. I recently bought 10 of those from
about $0.40 a piece. The CD4050 is not pin compatible with the SN74AHC125 but it's easy to use. You wi
any useful wiring examples for the CD4050 on the web.
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 7/20
E ARDUINO SD LIBRARY
The Arduino IDE comes bundled with an SD library that's easy to use. You can include the SD library in
duino program by selecting from the main menu:Sketch\Import Library\SD
The library also comes with ready to use example programs to get you up and running. You can open
ample programs from main menu:File\Examples\SD then pick any of the 6 example sketches. If you have th
rd socket connected and an SD card inserted, those examples will work on the spot.
For this prototype, I am using an old XTREME MiniSD 1GB SD1 card with a standard SD adapter s
cause I have one available. I did not run into any performance issues with this class and model. Most merds sold today are the faster SDHC variety.
D CARD I/O STATUS LED
Since the SD card socket has no LED indicators, I have added a status LED wired to Arduino PIN8, via
ms resistor in series. This LED stays on so long as the SD card is working properly. I wrote the Arduino cod
at when a write or read of the SD card fails, the LED is turned off. This way we can just look at the prototyp
if something is wrong, along with other Arduino and GPS receiver LED indicators.
ORMATTING THE SD CARD
Using my Windows 7 computer I fully formatted the SD card as FAT16 once. Then, I quick format the SD
er every trial just to be on the safe side.
TEP#3: GEO-TAGGING DATA: THE LS20031 GPS RECEIVER
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 8/20
20031 GPS RECEIVER SPECIFICATIONS
I am using the LS20031 GPS receiver in this prototype to tag logged data with both geographic locatio
te/time stamp. The LS20031 is a bread and butter GPS receiver. It's very simple to operate. This receiver is
LOCOSYS Technology. I have attached the LS20031 datasheet to this section for those interest
ore detailed specifications.
Model: LS20031Chip: MediaTek MT3329Voltage: 3.3V
Frequency: L1 1575.42MHz, C/A codeChannels: Support 66 channels (22 Tracking, 66 Acquisition)Update rate: 1Hz default, up to 10HzHot start: (Open Sky) < 2 seconds (typical)Acquisition Time: Cold Start (Open Sky) 35 second (typical)Autonomous 3m (2D RMS)Position Accuracy: SBAS 2.5m (depends on accuracy of correction data)Datum: WGS-84 (default)Max. Operating Altitude: < 18 KmMax. Operating Velocity: < 515 m/s
PS RECEIVERS & NMEA SENTENCES
When the GPS receiver is powered up, it will start transmitting information via it serial (TX) pin in thestandardized comma-delimited text lines. These standardized text messages are called Nntences containing latitude, longitude, date/time, among other useful data.
NMEA stands for National Marine Electronics Association. This is the industry body that comes upandardized message formats for GPS receivers to simplify using this technology.
NMEA sentences start with GP + a three-letter identifier that tells us what sort of data is contained iMEA sentence being transmitted by the GPS receiver.
e LS20031 sends out the following NMEA sentences.
GGA Global positioning system fixed dataGLL Geographic position - latitude/longitudeGSA GNSS DOP and active satellitesGSV GNSS satellites in viewRMC Recommended minimum specific GNSS dataVTG Course over ground and ground speed
The one I find useful for this project is the RMC ($GPRMC). Here's a sample RMC sentence anplanation of each element:
GPRMC,053740.000,A,2503.6319,N,12136.0099,E,2.69,79.65,100106,,,A*53
Message ID: $GPRMC RMC protocol headerUTC Time: 053740.000 hhmmss.sssStatus A: A=data valid or V=data not validLatitude: 2503.6319 ddmm.mmmmN/S: Indicator N N=north or S=southLongitude: 12136.0099 dddmm.mmmmE/W Indicator: E E=east or W=westSpeed over ground: 2.69 knots True
Course over ground: 79.65 degrees
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 9/20
Date: 100106 ddmmyyMagnetic variation: degreesVariation sense: E=east or W=west (Not shown)Mode A: A=autonomous, D=DGPS, E=DRChecksum: *53End of message termination
OWERING AND WIRING THE LS20031
I mentioned earlier that I had published a guide to help configure the LS20031 GPS receiver. The LS200
3.3V module which means it's powered by a 3.3V source. This also means we cannot connect the Ardtput pins, such as the TX pin (5V), to the LS20031 RX pin (3.3V) without converting from 5V to 3.3V.
In this prototype, I use the SN74AHC125 as level-shifter from 5V to 3.3V. We should be able to tak20031 GPS serial output pin, the TX pin (3.3V), and wire it directly to the Arduino's serial RX receive PIN1 e Arduino's 5V pins can handle a 3.3V signal and will treat it as a logical high.
ONFIGURING THE LS20031
r this prototype I used MiniGPS 1.4 to configure the LS20031 GPS receiver as follow:
Baud rate: 4800Fix Update Rate: 5/secNMEA outputs: RMC output set to 1 while all other NMEA outputs set to zero (0). At 5Hz, this means 5 messages per second.
I know this may sound confusing to some of you but please stick to my settings. Once you get your prot
and running you can change the parameters.
TEP# 4: FEELING THE ROAD: THE ADXL335 ACCELEROMETER
The ADXL335 is a 3-axis analog acceleration measurement sensor. That's a mouthful. Basically, this g
n detect speed of movement, also known as g-force, in three directions: up/down (z), forward/backward (x)
eways (y). The axis directions change depending on how we position the sensor IC.
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 10/20
The ADXL335 has a measurement range of ±3 g minimum for each axis. When you are standing sti
rth exerts a gravitation force of 1g. This sensor outputs signals in the form of voltage changes ranging from
3V. At zero gravity, the voltage value of the Z pin is right in the middle between 0V and 3.3V = 1.65V.
The accelerometer can measure the static acceleration of gravity (1g) as well as tilt-sensing application
o dynamic acceleration resulting from motion, shock, or vibration. Which axis of the ADXL335 reports
pendent on how you position the chip.
E ADXL335 GOES MOBILE
I drive a Toyota Yaris, a good car as far as reliability and fuel economy but not known for its lspension system. This is perfect for my purposes. A high-end suspension system may dampen road bump
ssibly generating weaker and inconclusive ADXL335 sensor readings.
OWERING THE ADXL335
This particular ADXL335 breakout board must be powered by a 3.3V source. It's also configured to pr
dates 50 times per second. That's plenty of resolution for our road condition sensing device.
Since the Arduino Uno can handle reading 3.3V signals without conversion, we can wire the ADXL
Y,Z outputs pins (3.3V) to Arduino Uno's analog input pins (5V) directly.
DXL335 DATASHEET
TEP#5: THE ARDUINO PROGRAM THAT PULLS IT ALL TOGETHER
This program reads the LS20031 GPS receiver and saves the NMEA sent
generated by the receiver as-is to the SD card. The program also reads the X, Y, Z p
the ADXL335 accelerometer and saves them with each NMEA line saved.
The Arduino program I developed for this prototype uses the SD library. I a
using TinyGPS to interact with the GPS receiver or SoftwareSerial. I did not need Tin
for this project since I am saving raw NMEA messages to the SD card. A
the SoftwareSerial library, after I ran into a few issues which were time consuming to re
ecided to stick to the default Arduino serial library.
The downside of not using SoftwareSerial in this project is that the GPS Receiver will be usin
duino's RX/TX pins to read configuration commands and to send GPS data to the Arduino. This mea
n't have the Arduino Serial Monitor available for debugging.
More importantly, we will have to disconnect the Arduino Uno's PIN0 (RX) from the GPS receive
n before uploading an Arduino program. If we don't disconnect Arduino's PIN0 (RX) from the GPS rec
will most likely fail to upload the Arduino program from the PC to the Arduino because of serial con
und this to be a small price for the gains in coding compactness and shortened development cycle.
The data saved by this program to the SD will look like the list below. Theoretically, five lines of GPS
nsor data will be generated per second. This log can be imported as a comma-delimited file into a h
plications such as spreadsheets or databases for scrubbing, analysis, and charting:
446,425,542,GPRMC,093116.200,A,3158.0155,N,03551.5032,E,18.78,291.56,111112,,,A*54
443,442,542,GPRMC,093116.400,A,3158.0159,N,03551.5020,E,18.78,291.79,111112,,,A*50
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 11/20
444,435,523,GPRMC,093116.600,A,3158.0163,N,03551.5009,E,18.77,292.32,111112,,,A*53444,432,525,PRMC,093116.800,A,3158.0167,N,03551.4998,E,18.75,292.88,111112,,,A*5A
====================== START PROGRAM ==========================
ROJECT: Bump-O-Meter (Geo Data Logger for Sensors )
EVELOPER: Hazim Bitar (techbitar at gmail dot com)
ESCRIPTION: This program reads the ADXL335 accelerometer sensor data (X,Y,Z) or any
nsor data then saves this data to an SD card along with geo-location and a date/time stamp
nerated by the LS20031 GPS receiver
CENSE: I am placing this code in the public domain
ATE: NOV 16, 2012
nclude
efine LED 8 // status LED for SD operations
efine BUFF_MAX 100 // size of GPS & SD buffers
e GPSlog;
id setup()
erial.begin(4800); // The LS20031 GPS receiver must be set to 4800 for program to work
You can use the statements below to send configuration commands to the LS20031 GPS.
But for this to work, the baud rate must be set on the LS20031 GPS receiver to 4800.
You can use the MiniGPS 1.4 utility to configure or query the LS20031 GPS receiver.
LS20031 COMMANDS:
Serial.print("$PMTK251,4800*27\r\n"); // Set GPS baud rate
Serial.print("$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*2C\r\n"); // Set RMC to 5 fixes/second.
Serial.print("$PMTK220,200*2C\r\n"); // GPS update rate at 5Hz
inMode(10, OUTPUT); // Per SD library notes, pin 10 must be set to output
inMode(LED, OUTPUT);
(!SD.begin(4)) { // SD card detected?
digitalWrite(LED,LOW); // turn off status LED if SD detection fails
return;
se digitalWrite(LED, HIGH); // turn on LED if SD detection is OK
PSlog = SD.open("GPS.log", O_CREAT | O_WRITE); // open/append to a file GPS.log
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 12/20
(!GPSlog) { // test if file can be opened
digitalWrite(LED,LOW); // turn off status LED if file open fails
return;
se digitalWrite(LED, HIGH); // turn on status LED if file open is OK
id loop()
har inBuffer[BUFF_MAX]; // buffer used to read NMEA lines from GPS
yte outBuffer[BUFF_MAX]; // buffer used to write NMEA lines to SD card
nt sizeBuffer = 0; // counter of how many chars per line
HERE WE DECLARE MORE OR LESS ANALOG SENSOR VARIABLES
har an0[4], an1[4], an2[4]; // char variables to store analog pin values. Total 6 pins from 0-5
hile (Serial.available()>0) // if serial data available from GPS
sizeBuffer = Serial.readBytesUntil('\n', inBuffer, BUFF_MAX); // read one NMEA line from GPS until end of line
THIS IS WHERE WE READ SENSOR VALUES
itoa (analogRead(A0), an0, 10); // X read and convert numeric analog pin to char
itoa (analogRead(A1), an1, 10); // Y ..
itoa (analogRead(A2), an2, 10); // Z ..
for (int i = 0; i < BUFF_MAX; i++) outBuffer[i] = inBuffer[i]; // create CSV file on SD
int j = 0;
// THIS IS WHERE WE WRITE SENSOR DATA TO THE SD FILE
if (GPSlog) {GPSlog.print(an0); // write ANALOG0 (X) to SD
GPSlog.print(" , ");
GPSlog.print(an1); // write ANALOG1 (Y) to SD
GPSlog.print(" , ");
GPSlog.print(an2); // write ANALOG2 (Z) to SD
GPSlog.print(" , ");
// If you only want NMEA output logged, comment out all above GPSlog.print statements
GPSlog.write(outBuffer, sizeBuffer); // write GPS NMEA output to SD
GPSlog.print("\r\n");
GPSlog.flush();
digitalWrite(LED, HIGH); // Keep LED on so long as SD logging is working.
}
else {
// if the file didn't open, turn LED off
digitalWrite(LED, LOW); // turn LED off if writing to file fails
}
================ END PROGRAM =====================
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 13/20
OW TO ADD/REMOVE SENSORS TO THE GEO DATA LOGGER
is program will read up to 6 analog sensors and save their values to the SD card. There are two places in the progra
ere you need to make changes to suit your needs:
DECLARING SENSOR VARIABLES
the declaration section, we create text variables that will hold the converted numeric values of the sensors before we
ite them to the SD card. Here, we are declaring for a maximum of 6 analog sensors. Reduce as needed.
ar an0[4], an1[4], an2[4]; an3[4]; an4[4]; an5[4];
READING SENSORS
this part of the program, we convert the numeric sensor readings to text before we write them to the SD card. Chan
xt code segment in the program to add/remove sensors as needed. You can have up to 6 analog sensors read in this
ogram:
itoa (analogRead(A0), an0, 10);itoa (analogRead(A1), an1, 10);
itoa (analogRead(A2), an2, 10);
itoa (analogRead(A3), an0, 10);
itoa (analogRead(A4), an1, 10);
itoa (analogRead(A5), an2, 10);
WRITING SENSORS VALUES TO THE SD CARD
ter we read the sensor(s) above, we write their text values to the SD card. In the code segment below, we are adding
mma between each sensor value written to the SD card so we can separate them. This makes it easier to import thempreadsheet program as comma-delimited text:
GPSlog.print(an0); // write ANALOG0 to SD card
GPSlog.print(" , ");
GPSlog.print(an1); // write ANALOG1 to SD card
GPSlog.print(" , ");
GPSlog.print(an2); // write ANALOG2 to SD card
GPSlog.print(" , ");
GPSlog.print(an0); // write ANALOG3 to SD card
GPSlog.print(" , ");
GPSlog.print(an1); // write ANALOG4 to SD card
GPSlog.print(" , ");
GPSlog.print(an2); // write ANALOG5 to SD card
GPSlog.print(" , ");
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 14/20
TEP#6: A PLAIN GPS LOGGER TO INTERFACE WITH GOOGLE EARTH
For those who want to use this prototype as a generic GPS logger, to track your
just upload the Arduino code below. This program will generate raw NMEA RMC sent
to file GPS.LOG on the SD card without any sensor data.
We can then Import the GPS.LOG file into Google Earth and gen
maps overlaid with your logged track points. Please refer to my LS20031 GPStutor
how to import a raw GPS NMEA log files into Google Earth.
You can also import this NMEA log file into Excel as a comma-delimited text file and reformat it forPSvisualizer.com to draw maps with track points and more. More on this in the next sections.
================ START PROGRAM =====================
ROJECT: A Plain GPS Logger
EVELOPER: Hazim Bitar (techbitar at gmail dot com)
ESCRIPTION: This program logs GPS location information wherever you go and saves to the SD card as raw
MEA data to be imported into Google Earth.
CENSE: I am placing this code in the public domain
ATE: NOV 17, 2012
clude <SD.h>
efine LED 8 // status LED for SD operationsefine BUFF_MAX 100 // size of GPS & SD buffers
e GPSlog;
d setup()
erial.begin(4800); // The LS20031 GPS receiver must be set to 4800 for program to work
nMode(10, OUTPUT); // Per SD library notes, pin 10 must be set to output
nMode(LED, OUTPUT);
(!SD.begin(4)) { // SD card detected?
digitalWrite(LED,LOW); // turn off staus LED if SD detection fails
return;
se digitalWrite(LED, HIGH); // turn on LED if SD detection is OK
PSlog = SD.open("GPS.log", O_CREAT | O_WRITE); // open/append to a file GPS.log
(!GPSlog) { // test if file can be opened
digitalWrite(LED,LOW); // turn off status LED if file open fails
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 15/20
return;
se digitalWrite(LED, HIGH); // turn on status LED if file open is OK
d loop()
har inBuffer[BUFF_MAX]; // buffer used to read NMEA lines from GPS
yte outBuffer[BUFF_MAX]; // buffer used to write NMEA lines to SD card
t sizeBuffer = 0; // counter of how many chars per line
hile (Serial.available()>0) // if serial data available from GPS
sizeBuffer = Serial.readBytesUntil('\n', inBuffer, BUFF_MAX); // read one NMEA line from GPS until end of li
for (int i = 0; i < BUFF_MAX; i++) outBuffer[i] = inBuffer[i]; // create CSV file on SD
nt j = 0;
f (GPSlog) {
GPSlog.write(outBuffer, sizeBuffer); // write GPS NMEA output to SD
GPSlog.print("\r\n");
GPSlog.flush();digitalWrite(LED, HIGH); // Keep LED on so long as SD logging is working.
}
else {
// if the file didn't open, turn LED off
digitalWrite(LED, LOW); // turn LED off if writing to file fails
}
================ END PROGRAM =====================
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 16/20
TEP#7: SCRUBBING & FORMATTING DATA WITH A SPREADSHEET
With enough road data captured on the SD card, we now start the data scrubbing and re-formatteparation for analysis and visualization in Excel, GPSvisualizer, or our favorite data analysis and charting too
Remove the SD card from the socket and insert into PC SD card reader. Copy the GPS.log file to yod Run Excel (or your favorite spreadsheet application). The steps below are for Excel 2007:
STEP 1: From Excel, File/Open and select GPS.log. Make sure you select File Type All Files (*.*) else yonot see the file GPS.log listed. Open file. This will launch the Text Import Wizard. STEP 2: Select Delimited radio button. Click Next.STEP 3: Select Comma check box only. Cick Next.SETP 4: Excel will import the GPS.log file into columns and rows. The columns are ordered in this mannerZ, NMEA output type, UTC Time, Status A: A=data valid or V=data not valid, Latitude, N/S: Indicator N N=noS=south, Longitude, E/W Indicator: E E=east or W=west, Speed over ground, Course over ground, Magnetic variation, Variation sense: E=east or W=west, Mode A: A=autonomous, D=DGPS, E=DR, ChecksuSTEP 5,6: In column 'F' you will see one letter either A or V. A means valid fix. V means invalid data. So dall rows that are invalid.STEP 7: Also, delete jumbled lines.STEP 8: Keep columns C (z-axis), G (Latitude), and I (Longitude) but hide other imported columns.STEP 9: Add header labels to the top of the remaining three columns: N, Latitude, Longitude.STEP 10: Now select and copy to clipboard the range of rows you wish to map in GPSvisualizer and don't
to also copy the columns header labels.
With the selected data in the clipboard, we are ready to paste it into GPSvisualizer so we can map
alyze our logged data.
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 17/20
TEP#8: PLOTTING AND COLOR-CODING ROAD CONDITION DATAWITH GPSVISUALIZER.COM
st, let's open GPSvisualizer and open the "Plot data points" page:
tp://www.gpsvisualizer.com/map_input?form=data
EP 1: Find the scroll box titled "Or paste your data here" and delete everything in it then paste the dat
ve copied from Excel into it. You should get a clean three column content with the headers N Latitude Long
ake sure you don't change the headers in any way after you paste them and don't add commas or tatween. Just a straight paste from Excel.
EP 2: You can skip this step for now or you can make changes to "Data point options" to follow my se
shown in the figure.
EP 3: Click "Draw the map" button and watch the magic.
OW TO READ THE MAP
A Google Map will be displayed and overlaid with the route points captured by our geo data logger.
se, I have selected stars as the icons for the data points. The larger and more blueish the data point or the sme more reddish the bigger the road bump or pothole.
By clicking on a star, a balloon will pop up with the z-axis value read by the ADXL335 accelerom
ng road stretches of comparable greenish colors and values (typically 520 in my case) mean the ro
moother.
We can change the icon shapes, their minimum and maximum sizes, and other parameters from the
nt options" section.
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 18/20
RANSLATING SENSOR DATA INTO ROAD CONDITION INFO
I have simplified this part so almost no math will be needed to assess road conditions using the
nerated by the ADXL335 sensor. So there will be no translation from raw accelerometer sensor outputs
ues. The whole trick wrests in road condition profiling and sensor data comparison.
ROFILING ROAD DATA
Different geo data loggers may produce different readings than mine for various reasons having to do
nsor type if a different accelerometer is used, suspension system differences from one car to another, orien
the geo data logger, etc. So we need to profile normal road conditions and abnormal road condition before wake sense of our data using your geo data logger in your particular environment.
Profiling road conditions is simple. We record senor data generated by the ADXL335 sensor while we
er a good road stretch then do the same with sensor data generated when we drive over a rough road stretch
bump or pothole.
In my case, I get an average of 520 for the z-axis on a good road stretch. I can use this as a fram
erence so if I get sample data of 520 plus or minus a few notches (you decide what's the acceptable range)
s is a good road. So 520 +/- some value of your choosing is the profile of a good road condition. But if I drive
bump or pothole, I get sensor z-axis readings that hover around 500 on the low end and 535 on the high end
l be my profile of a rough road.
The basic assumption here is that I am using the same car, with the sensor placed in the same s
e car, and driving at the same speed every time I profile the road with my geo data logger.
In the "Data point options" by assigning the "Min" color field my my lower z-axis number and "Max" fie
h z-axis number, now I can use GPSvisualizer.com to determine visually, by color or size of marker, where t
or road stretches, potholes, and bumps.
NALYZING SENSOR DATA AND ROAD CONDITIONS
When it comes to analyzing the sensor data, sometimes bumps my look like potholes and vice versssible to log what seems like a pothole condition when in reality we are just dropping back to normal street
ht after a road bump. It's also possible to get a sensor reading the resembles that of a bump when th
arts climbing out of the pothole.
We look for small or large z-axis readings, based on the min/max values withing the range of captured
identify abnormal road conditions. But classifying these road conditions might require more analysis. We
ways play around with GPSvisualizer settings until we get the visual representation we need.
The important thing is to record presence of a road condition in need of attention or to avoid it next tim
e on the same road.
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 19/20
TEP#9: FORMATTING GPS DATE/TIME OUTPUT FOR STAMPING DATA
Since time-stamping logged data is important for many projects
explain how to extract and format the GPS generated time/date data.
In this project, we hid all data columns in Excel except col
containing z-axis data, latitude, and longitude. If we wish to keep a date
stamp to map and visualize along with the rest of the retained senso
GPS data columns, we simply don't hide column E (time) and colum
(date).
The LS20031 GPS receiver, as with other GPS receivers of its
updates its internal clock to sync with the GPS satellites' internal atomic
ich is accurate to 1 billionth of a second.
The GPS receiver sends date/time stamped location fixes via a variety of NMEA text sentences. We
osen the RMC NMEA message for this project. This is how an RMC sentence looks like.
PRMC,093025.600,A,3157.8299,N,03551.5057,E,18.18,37.45,111112,,,A*6C
The boldfaced number from the left end of the NMEA sentence is the UTC Time. It's interpreted accord
s format string: hhmmss.sss. So 093025.600 can be displayed as: 09:30:25.
The second boldfaced number from the left is the date. It's interpreted according to this f
ng: ddmmyy. So 111112 can be displayed as 11-November-2012
UTC Time (Zulu) is Coordinated Universal Time. You can calculate your local time as needed by addi
btracting hours and minutes before or after UTC time.
TEP#10: SPEED VS LOGGING ACCURACY
OTE: I have oversimplified the concepts in this section to keep this guide short and accessible. For those wherested in a more detailed explanation, there are many helpful references on the web.
e accuracy and resolution of the geo data logger will depend on many facors such as:
The speed by which we are moving with the geo data logger.The frequency by which sensors can generate fresh readings.The frequency by which the GPS receiver can generate location fixes to tag sensor data with.
The SD card read/write performance.
7/21/2019 Geo Logger
http://slidepdf.com/reader/full/geo-logger 20/20
The speed of the microcontroller, for number crunching and formatting.
for our Bump-O-Meter, we have the following specs to work with:
The LS20031 GPS receiver can report a location "fix" 5 times a second (datasheet says 10Hz butfield experience shows 5Hz is reliable)The ADXL335 Accelerometer generates motion data at a rate 50 times per second.SD cards have an average latency of 100 ms even though the specs allow for 200 ms. Some old SD cards chandle 150KB/Sec to 200KB/Sec. More than enough for our data logger.The ATmega328p runs at a cool 16Mhz.
ATH FOR FUN (No such thing)
the bottleneck for our Bump-O-Meter will be the GPS receiver, at 5 updates per second (5Hz). Let's assume e driving at 60 Km/h and the GPS is reporting 5 location fixes per second.
60 kilometers per hour = 1 Km per minute.1 kilometer per minute = 16.6 meters per second.Since the LS20031 GPS receiver provides 5 fixes per second that's a fix every 3.3 meters. Keep in mind thisreceiver is accurate within 2.5 meters.
30 kilometers per hour, we can double the accuracy of our logger and so on. At 15...and so forth.
The key thing is to record a road bump or pothole even if we don't have its exact location. Because so lo
capture the bump's existence on our logger, we can find it if we go searching for it within +/- 2.5 meters
curacy) of the location reported by the logger.
For smoother data such as the ones generated by outdoors temperature and humidity sensors, we can
e of fairly simple techniques for guessing in-between data, such as interpolation.
TERPOLATION OF MISSING DATA
Interpolation is a method of guessing a mid data point within two recorded sensor data points. For exam
we drive down the highway while logging temperatures, if our geo data logger is capturing tempe
adings every 100 meters, it might be possible to interpolate (guess) the in-between temperature every 50 m
e change in outdoors weather temperature within 100 meters is not typically abrupt but tend to be gradual.
log 32 degrees F at 0 meters and 33 degrees F at 100 meters. We can make a reasonable guess that
eters or somewhere in between the temperature can be 32.5 degrees F. This is the simplified version of
erpolation.
Some interpolation might be possible and meaningful between two logged temperature points over a c
tance. Interpolating road conditions, on the other hand, may not be as simple.
Potholes and road bumps don't lend themselves to interpolation. Unlike the gradual change in
vironmental conditions, potholes tend to be sudden. Potholes are not typically preceded by increasingly
tholes. And they are not followed by increasingly smaller pot holes. For detecting pot holes, we have to
wer to give our geo data logger time to catch those (<15 Km/h). Also, we can slow down when we s
proaching pothole or a road bump to make sure our geo data logger catches it. In real world situations, we te
w down anyway as we approach a bump or pothole so that works well for our purposes.
OURCE: http://www.instructables.com/id/Geo-Data-Logger-ArduinoGPSSDAccelerometer-to-l/