Modifications

Sauter à la navigation Sauter à la recherche
1 644 octets ajoutés ,  8 mai 2012 à 11:28
Ligne 130 : Ligne 130 :  
Next up, download the Adafruit GPS library. This library does a lot of the 'heavy lifting' required for receiving data from GPS modules, such as reading the steaming data in a background interrupt and automagically parsing it. [https://github.com/adafruit/Adafruit-GPS-Library To download it, visit the GitHub repository and click the DOWNLOADS button in the top right corner] , rename the uncompressed folder '''Adafruit_GPS'''. Check that the '''Adafruit_GPS''' folder contains '''Adafruit_GPS.cpp''' and '''Adafruit_GPS.h'''. Place the Adafruit_GPS library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
 
Next up, download the Adafruit GPS library. This library does a lot of the 'heavy lifting' required for receiving data from GPS modules, such as reading the steaming data in a background interrupt and automagically parsing it. [https://github.com/adafruit/Adafruit-GPS-Library To download it, visit the GitHub repository and click the DOWNLOADS button in the top right corner] , rename the uncompressed folder '''Adafruit_GPS'''. Check that the '''Adafruit_GPS''' folder contains '''Adafruit_GPS.cpp''' and '''Adafruit_GPS.h'''. Place the Adafruit_GPS library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
   −
Open up the File→Examples→Adafruit_GPS→echo sketch and upload it to the Arduino. Then open up the serial monitor. This sketch simply reads data from the software serial port (pins 2&3) and outputs that to the hardware serial port connected to USB.
+
Open up the '''File→Examples→Adafruit_GPS→echo''' sketch and upload it to the Arduino. Then open up the serial monitor. This sketch simply reads data from the software serial port (pins 2&3) and outputs that to the hardware serial port connected to USB.
   −
You can configure the output you see by commenting/uncommenting lines in the setup() procedure. For example, we can ask the GPS to send different sentences, and change how often it sends data. 10 Hz (10 times a second) is the max speed, and is a lot of data. You may not be able to output "all data" at that speed because the 9600 baud rate is not fast enough.
+
You can configure the output you see by commenting/uncommenting lines in the '''setup()''' procedure. For example, we can ask the GPS to send different sentences, and change how often it sends data. 10 Hz (10 times a second) is the max speed, and is a lot of data. You may not be able to output "all data" at that speed because the 9600 baud rate is not fast enough.
 +
 
 +
<nowiki>
 +
// You can adjust which sentences to have the module emit, below
 +
 +
  // uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
 +
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
 +
  // uncomment this line to turn on only the "minimum recommended" data for high update rates!
 +
  //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
 +
  // uncomment this line to turn on all the available data - for 9600 baud you'll want 1 Hz rate
 +
  //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_ALLDATA);
 +
 +
  // Set the update rate
 +
  // 1 Hz update rate
 +
  //GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
 +
  // 5 Hz update rate- for 9600 baud you'll have to set the output to RMC or RMCGGA only (see above)
 +
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_5HZ);
 +
  // 10 Hz update rate - for 9600 baud you'll have to set the output to RMC only (see above)
 +
  //GPS.sendCommand(PMTK_SET_NMEA_UPDATE_10HZ);
 +
</nowiki>
 +
 
 +
In general, we find that most projects only need the RMC and GGA NMEA's so you don't need ALLDATA unless you have some need to know satellite locations.
 +
 
 +
== Parsed output ==
 +
 
 +
Since all GPS's output NMEA sentences and often for our projects we need to extract the actual data from them, we've simplified the task tremendously when using the Adafruit GPS library. By having the library read, store and parse the data in a background interrupt it becomes trivial to query the library and get the latest updated information without any icky parsing work.
 +
 
 +
Open up the '''File→Examples→Adafruit_GPS→parsing''' sketch and upload it to the Arduino. Then open up the serial monitor.
 +
 
 +
[[Fichier:GpsUltimateParse.jpg]]
    
== Source ==
 
== Source ==
29 915

modifications

Menu de navigation