Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // These variables are created at the top of the program (global variables)
- char DeviceID[10]="a840418"; //DeviceID or Device identifier in GPSWOX.com
- String datastring1="";
- String datastring2="";
- String datastring3="";
- uint8_t datasend[50]; //Storage longtitude,latitude and altitude
- char gps_lon[50]={"\0"}; //Storage GPS info
- char gps_lat[20]={"\0"}; //Storage latitude
- char gps_alt[20]={"\0"}; //Storage altitude
- //This code runs in the loop
- float flat, flon,falt;
- unsigned long age;
- gps.f_get_position(&flat, &flon, &age);
- falt=gps.f_altitude(); //get altitude
- flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;//save six decimal places
- flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
- falt == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : falt, 2;//save two decimal places
- datastring1 +=dtostrf(flat, 0, 6, gps_lat);
- datastring2 +=dtostrf(flon, 0, 6, gps_lon);
- datastring3 +=dtostrf(falt, 0, 2, gps_alt);
- if(flon!=1000.000000)
- {
- strcat(gps_lon,",");
- strcat(gps_lon,gps_lat);
- strcat(gps_lon,",");
- strcat(gps_lon,gps_alt);
- strcat(gps_lon,",");
- strcat(gps_lon,DeviceID);
- strcat(gps_lon,",");
- strcpy((char *)datasend,gps_lon);//the format of datasend is longtitude,latitude,altitude,DeviceID,
- Serial.println((char *)datasend);
- // send data
- rf95.send(datasend, sizeof(datasend));
- rf95.waitPacketSent();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement