Problem sending Lat/Long using RF24L01

Hi All,

I have been playing around with the RF24L01 modules to make a radio controlled robot.
I have been able to send and receive data signals backwards and forwards using ints and everything is working well.
I then decided it would be useful to send GPS Lat and Long, time and date info from the robot to the controller. Time and date data was easy but as the lat/long contains data to 6 decimal places. I am having brain ache trying to work out how to do this!
I understand that Arduino is not great at sending decimal places but was wondering if there is a work around by sending the lat as a character array or even multiplying by 100000 sending it and dividing at the receiver end by 100000 but am not having much luck.
I am relatively new to chars, ints, long, strings etc, it is a minefield to me!
Please go easy on me I am 62 yo and sometimes reading detailed info just looks like gobbledegook.

Below is the code I have for the transmitter. This successfully extracts the Lat data and prints it out on the monitor. It's the format for radio.write that is proving to be a problem.

[code]
/*
* Sketch to read the lat value from 
* GPS unit and Tx via RF20L01 to Rx board
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

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

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
//char Lat;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";

void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  
 Serial.begin(9600);
  ss.begin(GPSBaud);
 
}
void loop() {
  
  delay(5);
radio.stopListening();
  while (ss.available() > 0){
    gps.encode(ss.read());
       
if (gps.location.isUpdated()){
      
      String Lat =  String {gps.location.lat(),6} ;
      Serial.print ( " Lat = " );
      Serial.println (Lat);
   
      radio.write(&Lat, sizeof(Lat));
      
   } 
  
    }
    
  }

[/code]

What makes you think this is an installation issue?

sizeof(Lat)) Lat is a String.
The size of a String is always six.
You want the String's length.
There's a method for that.

Hi,

Thanks for the quick response.
I have been unable to receive anything intelligible at the receiver end hence thinking it is the way I am sending it.
You say the size of a string is always six but when I print out the string I get 50.911234. I don't understand what you mean.

stevetyphoon:
Hi,

Thanks for the quick response.
I have been unable to receive anything intelligible at the receiver end hence thinking it is the way I am sending it.
You say the size of a string is always six but when I print out the string I get 50.911234. I don't understand what you mean.

No, I said the size of a String is always six.
The length of the string it encapsulates may vary, but is given by the method "length()".
Thus "Lat.length()".
You don't want to be passing the address of Lat to the function, you want to be passing the encapsulated string.

My favourite approach is to simply not use Strings.

@stevetyphoon

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.