Advertisement
Guest User

Untitled

a guest
Jun 8th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.39 KB | None | 0 0
  1. // These variables are created at the top of the program (global variables)
  2.  
  3. char DeviceID[10]="a840418"; //DeviceID or Device identifier in GPSWOX.com
  4.  
  5. String datastring1="";
  6. String datastring2="";
  7. String datastring3="";
  8. uint8_t datasend[50];    //Storage  longtitude,latitude and altitude
  9.  
  10. char gps_lon[50]={"\0"};  //Storage GPS info
  11. char gps_lat[20]={"\0"}; //Storage latitude
  12. char gps_alt[20]={"\0"}; //Storage altitude
  13.  
  14.  
  15. //This code runs in the loop
  16.  
  17.   float flat, flon,falt;
  18.   unsigned long age;
  19.   gps.f_get_position(&flat, &flon, &age);
  20.   falt=gps.f_altitude();  //get altitude      
  21.   flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;//save six decimal places
  22.   flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
  23.   falt == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : falt, 2;//save two decimal places
  24.   datastring1 +=dtostrf(flat, 0, 6, gps_lat);
  25.   datastring2 +=dtostrf(flon, 0, 6, gps_lon);
  26.   datastring3 +=dtostrf(falt, 0, 2, gps_alt);
  27.   if(flon!=1000.000000)
  28.   {
  29.   strcat(gps_lon,",");
  30.   strcat(gps_lon,gps_lat);
  31.   strcat(gps_lon,",");
  32.   strcat(gps_lon,gps_alt);
  33.   strcat(gps_lon,",");
  34.   strcat(gps_lon,DeviceID);
  35.   strcat(gps_lon,",");
  36.   strcpy((char *)datasend,gps_lon);//the format of datasend is longtitude,latitude,altitude,DeviceID,
  37.   Serial.println((char *)datasend);
  38.  
  39.   // send data
  40.   rf95.send(datasend, sizeof(datasend));  
  41.   rf95.waitPacketSent();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement