Last active
June 24, 2020 15:23
-
-
Save Franck1333/440ed64edd6b3c941c3947eb071fdc19 to your computer and use it in GitHub Desktop.
Example of the use of a GPS on Arduino board.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//HARDWARE: https://tinyurl.com/AZYgpsUBLOX | |
//AIDE: https://lastminuteengineers.com/neo6m-gps-arduino-tutorial/ | |
//AIDE: http://arduiniana.org/libraries/tinygpsplus/#:~:text=TinyGPS%2B%2B%20is%20a%20new,course%20from%20consumer%20GPS%20devices. | |
#include <SoftwareSerial.h> | |
#include <TinyGPS++.h> | |
// Choose two Arduino pins to use for software serial | |
int RXPin = 2; | |
int TXPin = 3; | |
//Default baud of NEO-6M is 9600 | |
int GPSBaud = 9600; | |
// Create a TinyGPS++ object | |
TinyGPSPlus gps; | |
// Create a software serial port called "gpsSerial" | |
SoftwareSerial gpsSerial(RXPin, TXPin); | |
void setup() | |
{ | |
// Start the Arduino hardware serial port at 9600 baud | |
Serial.begin(9600); | |
// Start the software serial port at the GPS's default baud | |
gpsSerial.begin(GPSBaud); | |
} | |
void loop() | |
{ | |
Recuperation_Infos_GPS(); | |
} | |
float Recuperation_Infos_GPS(void){ | |
float latitude = gps.location.lat(); //Latitude en degres | |
float longitude = gps.location.lng(); //Longitude en degres | |
//uint32_t dateGPS = gps.date.value(); //Obtention de la date via GPS (uint32_t) | |
float vitesse_utilisateur = gps.speed.kmph(); //Obtention de la Vitesse de mouvement en Kilometre par Heure de l'utilisateur | |
uint32_t captation = gps.satellites.value(); //Inidcation du nombre de Satellite capté au meme moment | |
Serial.println("^ _ ^"); //Cette ligne permet de délimiter les nouvelles infos par rapport aux anciennes dans la console | |
Serial.print("Latitude: "); | |
Serial.println(latitude ,6); //Cette ligne permet d'afficher la Latitude de l'utilisateur en affichant uniquement les six premières valeurs | |
Serial.print("Longitude: "); | |
Serial.println(longitude ,6); //Cette ligne permet elle aussi d'afficher la Longitude de l'utilisateur avec uniquement les 6 premières valeurs | |
/*Serial.print("La Date: "); | |
Serial.println(dateGPS);*/ | |
Serial.print("Votre Vitesse: "); | |
Serial.println(vitesse_utilisateur); | |
Serial.print("Qt Satellite Capté: "); | |
Serial.println(captation); | |
delay(2048); | |
return latitude,longitude,vitesse_utilisateur,captation; //On retourne toute les informations interessantes pour une utilisation ulterieure. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment