The map visualizer displays GPS locations on a map downloaded automatically from MapQuest.
Locations can be obtained by your Arduino sketch using a GPS sensor. Most GPS sensors send serial data in NEMA format, which can be readily decoded by the tiny GPS Arduino library.
The built-in MapQuest API key lets you quickly try out the mapping visualizer before requesting your own (free) MapQuest API key for more frequency map updates.
Creating a Map Visualizer
Select Mapping from the visualizer menu or toolbox to add a new map visualizer to your MegunoLink project. You can add as many map visualizers as you like. Use message channels in your Arduino sketch to control the data sent to each visualizer.
Drag the visualizer tab to organize the windows in your MegunoLink project.
Map controls can also be added to interface panels.
Sending Data from an Arduino
Create a Map
variable to send data from your Arduino sketch to a map visualizer. After installing the Arduino library:
- Add
#include "MegunoLink.h"
to the top of your Arduino sketch, - Create a variable to send data:
Map MyMap
, then - Call
MyMap.SendData(/*Label*/, /*Latitude*/, /*Longitude*/)
to send a location to MegunoLink.
The Arduino map library reference has details of all the methods available.
This example uses the fantastic TinyGPSPlus library to decode GPS messages and send location to MegunoLink periodically. Most GPS devices send data using the NMEA standard so the TinyGPSPlus library works with the majority of GPS sensors. We used a Titan X1 GPS receiver, which sends its data through a serial connection. The SoftwareSerial
library was used to receive data from the GPS sensor on an Arduino board. The data is fed into the Tiny GPS Plus library as it arrives, which decodes the position information. The position is sent to MegunoLink every 30 seconds (highlighted).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
#include "MegunoLink.h" #include "ArduinoTimer.h" #include "SoftwareSerial.h" #include <TinyGPS++.h> const byte RxPin = 6; const byte TxPin = 7; SoftwareSerial GPSSerial(RxPin, TxPin); TinyGPSPlus GPSDecoder; ArduinoTimer ReportTimer; void setup() { Serial.begin(9600); GPSSerial.begin(9600); Serial.println(F("GPS Mapping")); Serial.println(F("-----------")); } void loop() { // Feed the GPS decoder with data from the GPS device if (GPSSerial.available()) { GPSDecoder.encode(GPSSerial.read()); } // Send location to MegunoLink periodically. if (ReportTimer.TimePassed_Seconds(30)) { if (GPSDecoder.location.isValid()) { Map MyMap; MyMap.SendData("Sensor 1", GPSDecoder.location.lat(), GPSDecoder.location.lng()); } else { Serial.println(F("Location not available")); } } } |
User Interface
The mapping visualizer user interface shows the locations sent from your Arduino sketch on a map and in a list. Uncheck items in the list to hide them from the map. A map view encompassing all of the selected locations is displayed automatically.
Visualizer Toolbar
Tool | Description |
---|---|
Connect/disconnect the selected connection. Use the drop-down to select the connection used by this visualizer. | |
Select the channels processed by the visualizer (message logger only). | |
Change the MapQuest API key (see below). | |
Remove all locations. | |
Reload the map. | |
Open online documentation for the visualizer. |