Using the data in Google Maps
The data on the SD card is interesting, but its nice to do something more visual with it (you could also put it into a spreadsheet and use it in other ways)
SO, we've set up a process where you can import the data into a Google Map which will then show your route and other info.
This uses a sketch in another language called Processing to grab the data sent by the Arduino and convert it into JSON format so it can be used in an HTML page which sets up a Google Map.
Most of this page relates to Windows XP explicitly, but Processing works on Mac OS X, Linux etc so the basics are very similar.
The Processing sketch works by looking for serial data and writing this to a text file called arduino_data.js - the .js suffix means that the html file can import it as JSON data). The Arduino sketch sends "filesize: xxx" where xxx is the number of bytes in the data file. The Processing sketch looks for this text and assumes this is the end of the serial data.
As it reads the serial data the Processing sketch also reformats it into JSON data and stores it as a txt file so that it can easily be read by javascript in the html file. The sketch also prints to a Processing window so that we can see that something is happening.
The html file starts a google map, imports the coordinate data from the text file using javascript to loop through the data and add each coordinate point to the map, drawing a polyline between the coordinates.
Processing related files: read_com_write_json
Unzip this into your Processing sketches folder. It includes the Processing sketch and the map html page along with test data - arduino_data_test.jsĀ (this must be renamed to arduino_data.js)
Step 1:
Set up Processing
1) Download the latest Processing software [http://processing.org/] - get the version for your operating system.
2) On Windows, run the exe file to install Processing - you'll notice it looks very similar to the Arduino environment.
3) You can have a play with the environment - its generally a visual environment so will open a window in which the sketch will make things happen.
Step 2:
Try the upload sketch
NOTE - The sketch has the Arduino comm port hard coded in the 'setup' routine - myPort = new Serial(this, "comm4", 57600);
You will need to update this with the actual comm port that has been assigned to the Arduino you connected. You can find this in Device Manager (or equiv) under Ports.
1) now, run our Processing sketch - read_com_write_json.pde - a window will open with some text - 'Starting'.
2) With it running, and the Arduino connected by USB, put the unit into Mode 3 - Uploading. The window should show rapid text happening.
3) The Processing window will indicate when uploading is finished, giving the amount of bytes transmitted. In the background Processing is reading from the serial port and writing to a file.
4) When finished, a text file called arduino_data.js will be left in the same directory as the sketch - check it is there and open it to view the JSON data. Processing sketches are generally saved in a folder under 'Processing' in your documents folder. Note that the Processing core is in My Programs, but the sketches are in My Documents (or equivalent naming on other operating systems).
5) Go to the 'read_com_write_json' folder where you will find an HTML file called gmap_gps_json.html. Double-click this and it should load into a web browser.
You should see a Google Map appear and then a trace of your route data.
If you are versed in HTML and can follow the Google Maps API, you can tease more data out, and display it in different ways on the map. For instance, the GPS module outputs elevation and how many/which satellites it has connected to. You could display the satellite count on one side, and add in speed every 100 points.