Sending GPS data through XBEE

XBee's are communicated with each other. I tested it. That's Okay.
The PROBLEM IS : I can't send all the information in Longtitude and Latitude because these are float number.xbee can send a maximum of 2 digits.
What algorithm should I make so that I can understand what the data is on the receiver side

Transmitter ARDUINO MEGA XBEE S2C

#include "SoftwareSerial.h"
#include <TinyGPS.h>
//long   lat,lon; // create variable for latitude and longitude object
float lat,lon;
TinyGPS gps; // create gps object
SoftwareSerial XBee(10, 11);



void setup(){

Serial.begin(9600);
  XBee.begin(9600);
Serial.println("The GPS Received Signal:");
Serial3.begin(9600); // connect gps sensor

}
 
void loop(){
    while(Serial3.available()){ // check for gps data
    if(gps.encode(Serial3.read()))// encode gps data
    {
    gps.f_get_position(&lat,&lon); // get latitude and longitude

    Serial.print("Position: ");
    
    //Latitude
    Serial.print("Latitude: ");
    Serial.print(lat,8);
    
    Serial.print(",");
    
    //Longitude
    Serial.print("Longitude: ");
    Serial.println(lon,8);
    
   }
  }


   XBee.write("l");          //  WHEN IT reaches to other part Receiver will understand  Latitude is coming       ASCII= 108
XBee.write(lat);
   delay(100);            
  XBee.write("k");            //  WHEN IT reaches to other part Receiver
 will understand  Longtitude is coming    ASCII  =107
XBee.write(lon);
delay(100);




   
    
}

Receiver

#include "SoftwareSerial.h"
// RX: Arduino pin 2, XBee pin DOUT.  TX:  Arduino pin 3, XBee pin DIN
SoftwareSerial XBee(10, 11);


void setup()
{Serial.begin(9600);
  // Baud rate MUST match XBee settings (as set in XCTU)
  XBee.begin(9600);
  
}

void loop()
{
  if (XBee.available())  
  { 
    
    int c = XBee.read();
  if(c==108){
    Serial.println("Longtitude");
    }
    if(c==107){
      Serial.println("Latitude");
    }
    
}


}

XBee's and GPS(GY NEO 6MV2) is working properly. I tested it

What makes you think the maximum payload is 2 bytes?
The datasheet says...

Each unicast transmission may support up to 84 bytes of RF payload, although enabling security or using source routing can reduce this number. For more information, see NP (Maximum Packet Payload Bytes). However, the XBee Zigbee firmware supports a Zigbee feature called fragmentation that allows a single large data packet to be broken up into multiple RF transmissions and reassembled by the receiver before sending data out its serial port.

The transmit frame can include up to 255 bytes of data broken up into multiple transmissions and reassembled on the receiving side. If one or more of the fragmented messages are not received by the receiving device, it drops the entire message, and the sender indicates a transmission failure in Extended Transmit Status - 0x8B.

gunesmadrali:
I can't send all the information in Longtitude and Latitude because these are float number.xbee can send a maximum of 2 digits.

So if the latitude was 54.67565 degrees the Xbee can only send 54 ?

You sure ?

srnet:
So if the latitude was 54.67565 degrees the Xbee can only send 54 ?

You sure ?

Unfortunately

Here the Prints of Transmitter and Receiver

mdkvmdk.PNG

sdsdfsfd.PNG

Can you please post the code which sent and received the truncated output.

cattledog:
Can you please post the code which sent and received the truncated output.

at transmitter side sending

XBee.write("l"); // WHEN IT reaches to other part Receiver will understand Latitude is coming ASCII= 108
delay(100);
XBee.write(lat);
delay(100) ;
XBee.write("k"); // WHEN IT reaches to other part Receiver will understand Longtitude is coming ASCII =107
delay(100);
XBee.write(lon);

The use of XBee.write() is not correct. See these references

The documentation specifies the use of .write() only for single characters, null terminated character strings, and character arrays with a character count.

You should be using XBee.print(lat,6) or Xbee.print(lon,6) to print the character representations of the floats with 6 decimal places.

What is strange, is that the compiler lets you get away with your incorrect use of .write(). Indeed, with Serial it complains, but with Software Serial it does not. Play around with the commented statement.

#include <SoftwareSerial.h>
SoftwareSerial XBee(10, 11); // RX, TX
void setup() {
  Serial.begin(9600);
  XBee.begin(9600);
  float x = 123.4567;
  //Serial.write(x);
  XBee.write(x);

}

void loop() {
  // put your main code here, to run repeatedly:

}