NRF24L01 sending float[SOLVED]

I want to be able monitor a battery located in another part of the building and transmit the value to another controller to make it easier to see how the voltage is.
I've managed to get them sending a value that counts up using the tutorial PaulS did, Great tutorial by the way very well explained. I want to be able to send a float value and did some searching and sound some code I think that should work has other posts I read it mentioned structs and unions ??
The code below I was just trying to compile to learn from it and take it from there but I get error and not sure or understand it, I'm using 1.6.9

C:\Users\Steve\Documents\Arduino\sketch_nov20c\sketch_nov20c.ino: In function 'void RecStruct()':
sketch_nov20c:54: error: void value not ignored as it ought to be
 bool ok = radio.read((byte *)&StructBuff, sizeof(StructBuff));

This is the RX code

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
#include <PString.h>
RF24 radio(8,9);
void setup(){
Serial.begin(57600); 
//**************Start Transiever (NRF24L01) config**************
printf_begin();
printf("\n\rRadio Setup\n\r");
radio.begin();
radio.setDataRate(RF24_2MBPS);
radio.setCRCLength(RF24_CRC_16);
radio.setPayloadSize(12 * sizeof(byte));
radio.setChannel(2);
radio.setAutoAck(true);
radio.openReadingPipe(1,0xF0F0F0F0D2LL);
radio.openWritingPipe(0xF0F0F0F0E1LL);
radio.startListening();
radio.printDetails();
//**************End Transiever (NRF24L01) config**************
} 
struct StructBuff_t {
char GPS[10]; 
float imuRoll;
float imuPitch;
float imuYaw;
unsigned int AP;
}
StructBuff;

//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{

RecStruct();
Serial.println(StructBuff.GPS);
Serial.println(StructBuff.imuRoll);
Serial.println(StructBuff.imuPitch);
Serial.println(StructBuff.imuYaw);
Serial.println(StructBuff.AP);
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void RecStruct(){

radio.startListening();
bool ok = radio.read((byte *)&StructBuff, sizeof(StructBuff));
if (ok) 
printf("ok...\n\r"); 
else 
printf("failed.\n\r");
delay(10);

}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+

This complies OK the TX code

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
#include <PString.h>
RF24 radio(48,49);
void setup(){
Serial.begin(57600); 
//**************Start Transiever (NRF24L01) config**************
printf_begin();
printf("\n\rRadio Setup\n\r");
radio.begin();
radio.setDataRate(RF24_2MBPS);
radio.setCRCLength(RF24_CRC_16);
radio.setPayloadSize(12 * sizeof(byte));
radio.setChannel(2);
radio.setAutoAck(true);
radio.openReadingPipe(1,0xF0F0F0F0E1LL);
radio.openWritingPipe(0xF0F0F0F0D2LL);
radio.startListening();
radio.printDetails();
//**************End Transiever (NRF24L01) config**************
} 
struct StructBuff_t {
char GPS[10]; 
float imuRoll;
float imuPitch;
float imuYaw;
unsigned int AP;
}
StructBuff;

//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
///////////////////////////////////////////////////////// 
char myChar = 'A'; //
PString(StructBuff.GPS, sizeof(StructBuff.GPS),myChar);//
StructBuff.imuRoll = -13.42; //
StructBuff.imuPitch = 6.98; //Temp Values
StructBuff.imuYaw = 0.42; //
StructBuff.AP = 55; //
/////////////////////////////////////////////////////////

TransStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void TransStruct(){

radio.stopListening();
bool ok = radio.write((byte *)&StructBuff, sizeof(StructBuff));
if (ok) 
printf("ok...\n\r"); 
else 
printf("failed.\n\r");
delay(10);

}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+

Which would be the best method to send one float value of say 12.26 which is the float value for the battery. I'm trying to get to understand the above code
Thanks

The error that you are seeing is because your version of the library that contains the class that radio is an instance of has a read() method that does not return a value. Other versions of the library do.

I got the library from the link in your thread, is that wrong one or because the code is older than your thread ?

thanks
Steve

Steveiboy:
I got the library from the link in your thread, is that wrong one or because the code is older than your thread ?

thanks
Steve

I think you must have me confused with someone else. I don't even own any NRF radios.

This Simple nRF24L01+ Tutorial may help. The code examples are considerably simpler than what you are working with.

...R

PaulS:
I think you must have me confused with someone else. I don't even own any NRF radios.

Sorry Paul yes it was Robin2 that posted it.
Robin2 I followed your thread and got my modules TXing and RXing,
This code also works
TX code.

/* YourDuinoStarter Example: Simple nRF24L01 Transmit
  - WHAT IT DOES: Transmits simple fixed data with nRF24L01 radio
  - SEE the comments after "//" on each line below
   Start with radios about 4 feet apart.
  - SEE the comments after "//" on each line below
  - CONNECTIONS: nRF24L01 Modules See:
  http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
  Uses the RF24 Library by TMRH2o here:
  https://github.com/TMRh20/RF24
   1 - GND
   2 - VCC 3.3V !!! NOT 5V
   3 - CE to Arduino pin 7
   4 - CSN to Arduino pin 8
   5 - SCK to Arduino pin 13
   6 - MOSI to Arduino pin 11
   7 - MISO to Arduino pin 12
   8 - UNUSED

   V1.02 02/06/2016
   Questions: terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <SPI.h>   // Comes with Arduino IDE
#include "RF24.h"  // Download and Install (See above)
/*-----( Declare Constants and Pin Numbers )-----*/
//None yet
/*-----( Declare objects )-----*/
// (Create an instance of a radio, specifying the CE and CS pins. )
RF24 myRadio (7, 8); // "myRadio" is the identifier you will use in following methods
/*-----( Declare Variables )-----*/
byte addresses[][6] = {"1Node"}; // Create address for 1 pipe.
int dataTransmitted =12;  // Data that will be Transmitted from the transmitter

void setup()   /****** SETUP: RUNS ONCE ******/
{
  // Use the serial Monitor (Symbol on far right). Set speed to 115200 (Bottom Right)
  Serial.begin(115200);
  delay(1000);
  Serial.println(F("RF24/Simple Transmit data Test"));
  Serial.println(F("Questions: terry@yourduino.com"));
  //dataTransmitted = 100; // Arbitrary known data to transmit. Change it to test...
  myRadio.begin();  // Start up the physical nRF24L01 Radio
  myRadio.setChannel(108);  // Above most Wifi Channels
  // Set the PA Level low to prevent power supply related issues since this is a
  // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
 // myRadio.setPALevel(RF24_PA_MIN);
    myRadio.setPALevel(RF24_PA_MAX);  // Uncomment for more power
myRadio.setDataRate(RF24_250KBPS); // Fast enough.. Better range

  myRadio.openWritingPipe( addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
  delay(1000);
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  myRadio.write( &dataTransmitted, sizeof(dataTransmitted) ); //  Transmit the data

  Serial.print(F("Data Transmitted = "));
  Serial.print(dataTransmitted);
  Serial.println(F(" No Acknowledge expected"));
dataTransmitted = dataTransmitted +1;  // Send different data next time
  delay(500);

}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/


//*********( THE END )***********

RX code

/* YourDuinoStarter Example: Simple nRF24L01 Receive
  - WHAT IT DOES: Receives simple fixed data with nRF24L01 radio
  - SEE the comments after "//" on each line below
   Start with radios about 4 feet apart.
  - SEE the comments after "//" on each line below
  - CONNECTIONS: nRF24L01 Modules See:
  http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
  Uses the RF24 Library by TMRH2o here:
  https://github.com/TMRh20/RF24
   1 - GND
   2 - VCC 3.3V !!! NOT 5V
   3 - CE to Arduino pin 7
   4 - CSN to Arduino pin 8
   5 - SCK to Arduino pin 13
   6 - MOSI to Arduino pin 11
   7 - MISO to Arduino pin 12
   8 - UNUSED

   V1.02 02/06/2016
   Questions: terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <SPI.h>   // Comes with Arduino IDE
#include "RF24.h"  // Download and Install (See above)
/*-----( Declare Constants and Pin Numbers )-----*/
//None yet
/*-----( Declare objects )-----*/
// (Create an instance of a radio, specifying the CE and CS pins. )
RF24 myRadio (7, 8); // "myRadio" is the identifier you will use in following methods
/*-----( Declare Variables )-----*/
byte addresses[][6] = {"1Node"}; // Create address for 1 pipe.
int dataReceived;  // Data that will be received from the transmitter

void setup()   /****** SETUP: RUNS ONCE ******/
{
  // Use the serial Monitor (Symbol on far right). Set speed to 115200 (Bottom Right)
  Serial.begin(115200);
  delay(1000);
  Serial.println(F("RF24/Simple Receive data Test"));
  Serial.println(F("Questions: terry@yourduino.com"));

  myRadio.begin();  // Start up the physical nRF24L01 Radio
  myRadio.setChannel(108);  // Above most Wifi Channels
  // Set the PA Level low to prevent power supply related issues since this is a
  // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  //myRadio.setPALevel(RF24_PA_MIN);
    myRadio.setPALevel(RF24_PA_MAX);  // Uncomment for more power
myRadio.setDataRate(RF24_250KBPS); // Fast enough.. Better range

  myRadio.openReadingPipe(1, addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
  myRadio.startListening();

}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{

  if ( myRadio.available()) // Check for incoming data from transmitter
  {
    while (myRadio.available())  // While there is data ready
    {
      myRadio.read( &dataReceived, sizeof(dataReceived) ); // Get the data payload (You must have defined that already!)
    }
    // DO something with the data, like print it
    Serial.print("Data received = ");
    Serial.println(dataReceived);
  } //END Radio available

}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/

//None yet
//*********( THE END )***********

I cannot send a float as it just print big random numbers, This is why I tried to search then found something about struct and union to send a float but most of them send more than one sensor value and just trying to get my head around them.

You should be easily able to send a float with a small modification to my simpleTx and simpleRx program

Where the TX program has

char dataToSend[10] = "Message 0";

try changing it to

float dataToSend = 123.456;

and disable the updateMessage() function - or modify it to work with your float.

Then make an equivalent change in the RX program

...R

Thanks. I was looking at it wrong I forgot to change the RX to a float instead of an int

The nRF24 just sends and receives bytes. It is up to the programs to interpret the bytes correctly.

...R