LOGIN
Kemal Ficici
3
Collaborator
Student, Content Creator, Entrepreneur (Project Leader)
 · WashingtonU.S.
Share
Report
Get Link
STATUS

Getting GPS Data!

We recently got our GPS sensor working, and have finally been able to pull data from it! The following program shows how we got Speed, Heading, and Location Data from a Ublox Max-M8Q connected to our Arduino 101.

We’re going to be using this data along with an Input coordinate to plan a path for the glider, then use our previous PID Code so that our target direction will be determined by the difference between its current location and the target location/waypoint in 3D space.

#include <SoftwareSerial.h>
#include <TinyGPS.h>

long lat,lon; // create variable for latitude and longitude object
float heading;
float speed;

SoftwareSerial gpsSerial(7, 8); // create gps sensor connection
TinyGPS gps; // create gps object

void setup(){
 Serial.begin(9600); // connect serial
 gpsSerial.begin(9600); // connect gps sensor
}

void loop(){
 while(gpsSerial.available()){ // check for gps data
  if(gps.encode(gpsSerial.read())){ // encode gps data
   gps.get_position(&lat,&lon); // get latitude and longitude
   speed = gps.f_speed_mps(); //Speed in m/s
   heading = gps.f_course(); //Heading in degrees

   //Output Data:
   Serial.print("Heading: "); Serial.print(heading);
   Serial.print("Speed: "); Serial.print(speed);
   Serial.print("Position: ");Serial.print("lat: ");Serial.print(lat);Serial.print(" ");// print latitude
   Serial.print("lon: ");Serial.println(lon); // print longitude
  }
 }
}



1 like 
Like
Award Contribution
Leave a reply...
DISCOVER
CHAT
HIRE
ACTIVITY
FEED
Chat with us!
Help
Write something before you submit it!
Photo updated
Request Sent!
Updated
Copied to Clipboard