nrf24l01 for 2 way communication

currently im running a arduino pro mini 5v 16mhz + nrf24l01 + pa + antenna as transmitter
and arduino pro mini + nrf24l01 pcb antenna one as reciver also have a oled on the rx

code:
RX

/* Test code for the Radio control transmitter
 *  Install the NRF24 library to your IDE
 * Upload this code to the Arduino UNO
 * Connect a NRF24 module to it:
 
    Module // Arduino UNO
    
    GND    ->   GND
    Vcc    ->   3.3V
    CE     ->   D9
    CSN    ->   D10
    CLK    ->   D13
    MOSI   ->   D11
    MISO   ->   D12

This code should print the received values to the serial monitor
Please, like share and subscribe : [url]http://www.youtube.com/c/ELECTRONOOBS[/url]
*/
#include <Adafruit_SSD1306.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
const uint64_t pipeIn = 0xE8E8F0F0E1LL; //Remember that this code is the same as in the transmitter

RF24 radio(9, 10); 

//We could use up to 32 channels
struct MyData {
byte throttle; //We define each byte of data input, in this case just 6 channels
byte yaw;
byte pitch;
byte roll;
byte AUX1;
byte AUX2;
};

MyData data;

int packetCounts[10];
int packetCountIndex = 0;
int packetCountTotal = 0;

void resetData()
{
//We define the inicial value of each data input
//3 potenciometers will be in the middle position so 127 is the middle from 254
data.throttle = 0;
data.yaw = 127;
data.pitch = 127;
data.roll = 127;
data.AUX1 = 0;
data.AUX2 = 0;

}

/**************************************************/

void setup()
{
Serial.begin(9600); //Set the speed to 9600 bauds if you want.
//You should always have the same speed selected in the serial monitor
resetData();
radio.begin();
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);

radio.openReadingPipe(1,pipeIn);
//we start the radio comunication
radio.startListening();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
memset(&data, 0, sizeof(MyData));  
memset( packetCounts, 0, sizeof(packetCounts) );
}

/**************************************************/

unsigned long packetsRead = 0;
unsigned long lastScreenUpdate = 0;
unsigned long lastAvgUpdate = 0;
unsigned long lastRecvTime = 0;
unsigned long drops = 0;

void recvData()
{
while ( radio.available() ) {
radio.read(&data, sizeof(MyData));
lastRecvTime = millis(); //here we receive the data
}
}

/**************************************************/

void loop()
{
recvData();
unsigned long now = millis();
//Here we check if we've lost signal, if we did we reset the values 
if ( now - lastRecvTime > 1000 ) {
// Signal lost?
resetData();
}
if ( now - lastScreenUpdate < 100 )
    return;
    
  // moving average over 1 second
  packetCountTotal -= packetCounts[packetCountIndex];
  packetCounts[packetCountIndex] = packetsRead;
  packetCountTotal += packetsRead;

  packetCountIndex = (packetCountIndex + 1) % 10;
  packetsRead = 0;

Serial.print("Throttle: "); Serial.print(data.throttle);  Serial.print("    ");
Serial.print("Yaw: ");      Serial.print(data.yaw);       Serial.print("    ");
Serial.print("Pitch: ");    Serial.print(data.pitch);     Serial.print("    ");
Serial.print("Roll: ");     Serial.print(data.roll);      Serial.print("    ");
Serial.print("Aux1: ");     Serial.print(data.AUX1);      Serial.print("    ");
Serial.print("Aux2: ");     Serial.print(data.AUX2);      Serial.print("\n");
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(0.5);
display.setCursor(0, 0);
display.println("A0");
display.setCursor(20, 0);
display.println(data.throttle);
display.setCursor(45, 0);
display.println("A1");
display.setCursor(65, 0);
display.println(data.yaw);
display.setCursor(0, 10);
display.println("A2");
display.setCursor(20, 10);
display.println(data.pitch);
display.setCursor(45, 10);
display.println("A3");
display.setCursor(60, 10);
display.println(data.roll);
display.setCursor(0,20);
display.println("PPS");
display.setCursor(30, 20);
display.println(packetCountTotal);
display.setCursor(40,20);
display.println("AUX2");
display.setCursor(70, 20);
display.println(data.AUX2);
display.display();


}

/**************************************************/

note the base code is from electronoobs and the pps part which i tried is from iforce2d but it doesnt work :frowning: (HELP HERE)

TX

/*A ba
sic 4 channel transmitter using the nRF24L01 module.*/
/* Like, share and subscribe, ELECTRONOOBS */
/* http://www.youtube/c/electronoobs */


/* First we include the libraries. Download it from 
   my webpage if you donw have the NRF24 library */
 
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

/*Create a unique pipe out. The receiver has to 
  wear the same unique code*/
  
const uint64_t pipeOut = 0xE8E8F0F0E1LL; //IMPORTANT: The same as in the receiver
const int ledPin = 2;

int ledState = HIGH;
int blinkcount = 0;
unsigned long previousMillis = 0;
const long interval = 100; //blink interval
const long interval2 = 1000; // pause interval

unsigned long currentMillis ;
unsigned long previousMillis2 = 0;  

RF24 radio(9, 10); // select  CSN  pin

// The sizeof this struct should not exceed 32 bytes
// This gives us up to 32 8 bits channals
struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
  byte AUX1;
  byte AUX2;
};

MyData data;

void resetData() 
{
  //This are the start values of each channal
  // Throttle is 0 in order to stop the motors
  //127 is the middle value of the 10ADC.
    
  data.throttle = 0;
  data.yaw = 127;
  data.pitch = 127;
  data.roll = 127;
  data.AUX1 = 0;
  data.AUX2 = 0;
}

void blinkSteps0to2() {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa:
      if (ledState == HIGH) {
        ledState = LOW;
        blinkcount++;
      } else {
        ledState = HIGH;
        blinkcount++;
      }
      // set the LED with the ledState of the variable:
      digitalWrite(ledPin, ledState);
    }

void blinkStep3(){
    unsigned long currentMillis2 = millis();
    ledState = HIGH;

    if (currentMillis2 - previousMillis2 >= interval2) {
      // save the last time you blinked the LED
      previousMillis2 = currentMillis2;
      // set the LED with the ledState of the variable:
      blinkcount = 0;
    }
 }

void setup()
{
  //Start everything up
  Serial.begin(9600);
  radio.begin();
  pinMode(ledPin, OUTPUT);
  radio.setAutoAck(false);
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipeOut);
  resetData();

}

/**************************************************/

// Returns a corrected value for a joystick position that takes into account
// the values of the outer extents and the middle of the joystick range.
int mapJoystickValues(int val, int lower, int middle, int upper, bool reverse)
{
  val = constrain(val, lower, upper);
  if ( val < middle )
    val = map(val, lower, middle, 0, 128);
  else
    val = map(val, middle, upper, 128, 255);
  return ( reverse ? 255 - val : val );
}

void loop()
{
  // The calibration numbers used here should be measured 
  // for your joysticks till they send the correct values.
  data.throttle = mapJoystickValues( analogRead(A0), 13, 524, 1015, true );
  data.yaw      = mapJoystickValues( analogRead(A1),  1, 505, 1020, true );
  data.pitch    = mapJoystickValues( analogRead(A2), 12, 544, 1021, true );
  data.roll     = mapJoystickValues( analogRead(A3), 34, 522, 1020, true );
  data.AUX1     = digitalRead(4); //The 2 toggle switches
  data.AUX2     = digitalRead(5);
  Serial.print("Throttle: "); Serial.print(data.throttle);  Serial.print("    ");
  Serial.print("Yaw: ");      Serial.print(data.yaw);       Serial.print("    ");
  Serial.print("Pitch: ");    Serial.print(data.pitch);     Serial.print("    ");
  Serial.print("Roll: ");     Serial.print(data.roll);      Serial.print("    ");
  Serial.print("Aux1: ");     Serial.print(data.AUX1);      Serial.print("    ");
  Serial.print("Aux2: ");     Serial.print(data.AUX2);      Serial.print("\n");
  radio.write(&data, sizeof(MyData));
  currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    if (blinkcount <= 3) blinkSteps0to2() ;
    else blinkStep3() ; 
  }
}

The above code is based of the code of electronoobs and the blink without delays sketch parts was included and the led blinks with out messing the transmitter stuff :smiley:

i need help to get pps readings on the reiever to test weather it is sufficient for controlling a quadcopter its intention
and also to send 3 - 4 voltage readings form RX > TX ( 3s - 4s lipo is planned to be used)

anyone who has do this kinda stuff before please help

Naresh_Rocker:
but it doesnt work

I assure you that it does work. It does exactly what it is coded to do. Whether or not that meets with your expectations isn't clear. I can see the code but you haven't really said what you want it to do that it isn't doing.

"It doesn't work" is the single most useless statement you could possibly make. Why don't you clear that up a little?

well, first of all thanks for your reply and intrest in helping me out

i mean by it is not working is the spefic pps (packes per secound section of it)

alll the rest works

i want the reciever to also send back some telementry (in this case the battery cells voltages) to the transmitter

Naresh_Rocker:
i mean by it is not working is the spefic pps (packes per secound section of it)

Again, that section of code does work. It does exactly what you coded it to do. Like I said, saying "it doesn't work" is the single most useless thing you could say. So why would you come back and just repeat that same statement? OK, at least you point to the section now, but you still have this totally useless description of the problem. Why?

What you need to say is something like, "I expected it do do blah blah blah but what really happens is blah blah blah." Can you see how that is going to help someone actually know what it is that you want?

Have a look at this Simple nRF24L01+ Tutorial. The examples do work.

...R

Delta_G:
Again, that section of code does work. It does exactly what you coded it to do. Like I said, saying "it doesn't work" is the single most useless thing you could say. So why would you come back and just repeat that same statement? OK, at least you point to the section now, but you still have this totally useless description of the problem. Why?

What you need to say is something like, "I expected it do do blah blah blah but what really happens is blah blah blah." Can you see how that is going to help someone actually know what it is that you want?

i told so because when i printed it in the serial monitor it just was 0 even when i got packets....

Robin2:
Have a look at this Simple nRF24L01+ Tutorial. The examples do work.

...R

ok i will go through it but i want it to be done with out delay and is it possiable to do it with ackpayloads? or just switching addresses madness ?

Note:These is the copy of the same code from the link provided above
SimpleTxAckPayload.ino

// SimpleTxAckPayload - the master or the transmitter

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


#define CE_PIN   9
#define CSN_PIN 10

const byte slaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

char dataToSend[10] = "Message 0";
char txNum = '0';
int ackData[2] = {-1, -1}; // to hold the two values coming from the slave
bool newData = false;

unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second

//===============

void setup() {

    Serial.begin(9600);
    Serial.println(F("Source File /mnt/sdb1/SGT-Prog/Arduino/ForumDemos/nRF24Tutorial/SimpleTxAckPayload.ino"));
    Serial.println("SimpleTxAckPayload Starting");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );

    radio.enableAckPayload();

    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
}

//=============

void loop() {

    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send();
    }
    showData();
}

//================

void send() {

    bool rslt;
    rslt = radio.write( &dataToSend, sizeof(dataToSend) );
        // Always use sizeof() as it gives the size as the number of bytes.
        // For example if dataToSend was an int sizeof() would correctly return 2

    Serial.print("Data Sent ");
    Serial.print(dataToSend);
    if (rslt) {
        if ( radio.isAckPayloadAvailable() ) {
            radio.read(&ackData, sizeof(ackData));
            newData = true;
        }
        else {
            Serial.println("  Acknowledge but no data ");
        }
        updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }

    prevMillis = millis();
 }


//=================

void showData() {
    if (newData == true) {
        Serial.print("  Acknowledge data ");
        Serial.print(ackData[0]);
        Serial.print(", ");
        Serial.println(ackData[1]);
        Serial.println();
        newData = false;
    }
}

//================

void updateMessage() {
        // so you can see that new data is being sent
    txNum += 1;
    if (txNum > '9') {
        txNum = '0';
    }
    dataToSend[8] = txNum;
}

A Few clarifications about the above tx code
1. Is it possiable to set the txinterval to 0 ? (as i intend to use this for controling the quadcopter i need alot of packets to make it smooth...)
2.why the ackpayload definition as -1 as the predefined value
3. radio.setRetries(3,5); // delay, count <<< As far as i can understand it waits for 3 secs and like that for 5 times ? so it is 15 secs of delay ? will it affect the transmission part or the reciver part of the orginal data (Control stuff) Sent from tx to rx ? can i reduce it?
4. i cant correctly understand wat the bool rslt; << rslt var doing.....
5.and i want about 3 - 4 values that are like 3.xx v - 4.7x << i need 2 decimal places this is the data that i am planing to send form RX to TX (AckPayload)

SimpleRxAckPayload.ino

// SimpleRx - the slave or the receiver

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[10]; // this must match dataToSend in the TX
int ackData[2] = {109, -4000}; // the two values to be sent to the master
bool newData = false;

//==============

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleRxAckPayload Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);

    radio.enableAckPayload();
    radio.writeAckPayload(1, &ackData, sizeof(ackData)); // pre-load data

    radio.startListening();
}

//==========

void loop() {
    getData();
    showData();
}

//============

void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        updateReplyData();
        newData = true;
    }
}

//================

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived);
        Serial.print(" ackPayload sent ");
        Serial.print(ackData[0]);
        Serial.print(", ");
        Serial.println(ackData[1]);
        newData = false;
    }
}

//================

void updateReplyData() {
    ackData[0] -= 1;
    ackData[1] -= 1;
    if (ackData[0] < 100) {
        ackData[0] = 109;
    }
    if (ackData[1] < -4009) {
        ackData[1] = -4000;
    }
    radio.writeAckPayload(1, &ackData, sizeof(ackData)); // load the payload for the next time
}

what is the speed i could get it to transmit and recieve ?

Naresh_Rocker:
A Few clarifications about the above tx code

  1. Is it possiable to set the txinterval to 0 ? (as i intend to use this for controling the quadcopter i need alot of packets to make it smooth...)
    2.why the ackpayload definition as -1 as the predefined value
  2. radio.setRetries(3,5); // delay, count <<< As far as i can understand it waits for 3 secs and like that for 5 times ? so it is 15 secs of delay ? will it affect the transmission part or the reciver part of the orginal data (Control stuff) Sent from tx to rx ? can i reduce it?
  3. i cant correctly understand wat the bool rslt; << rslt var doing.....
    5.and i want about 3 - 4 values that are like 3.xx v - 4.7x << i need 2 decimal places this is the data that i am planing to send form RX to TX (AckPayload)

There are a lot of things wrong with this.

  1. You don't need to send a lot of packets to a 'copter. It should be designed to be largely autonomous and my guess is 5 messages per second should be ample.
  2. The -1 is in the code that receives the payload data. When data arrives the -1 will be overwritten.
  3. If you study the Nordic nRF24L01+ datasheet you will see that 3,5 means wait (3 * 250 + 250) microsecs (i.e. 1 millisec) and do 5 retries before giving up. You can change the values to suit yourself. You can also disable acknowledgements completely.
  4. rslt gets a true or false response from the write() command
    THIS ALL SOUNDS like you have not even studied the TMRh20 RF24 library documentation.
  5. You can send an array of floating point values if you want to. Each float takes 4 bytes so a single message could have 8 of them in its 32 bytes.

Whether sending floating point values is a sensible thing to do is another matter. I would not use them as floating point maths is slow on an Arduino.

...R

this is the code i used but it doesnt work kindly help..........

TX

/*A ba
sic 4 channel transmitter using the nRF24L01 module.*/
/* Like, share and subscribe, ELECTRONOOBS */
/* http://www.youtube/c/electronoobs */


/* First we include the libraries. Download it from 
   my webpage if you donw have the NRF24 library */
 
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

/*Create a unique pipe out. The receiver has to 
  wear the same unique code*/
  
const uint64_t pipeOut = 0xE8E8F0F0E1LL; //IMPORTANT: The same as in the receiver
const int ledPin = 2;

int ledState = HIGH;
int blinkcount = 0;
unsigned long previousMillis = 0;
const long interval = 100; //blink interval
const long interval2 = 1000; // pause interval

unsigned long currentMillis ;
unsigned long previousMillis2 = 0;  

RF24 radio(9, 10); // select  CSN  pin

// The sizeof this struct should not exceed 32 bytes
// This gives us up to 32 8 bits channals
struct MyData {
  byte throttle;
  byte yaw;
  byte pitch;
  byte roll;
  byte AUX1;
  byte AUX2;
};

MyData data;

struct AckPayload {
  float cell1;
  float cell2;
  float cell3;
  float cell4;
};

AckPayload ackPayload;

void resetData() 
{
  //This are the start values of each channal
  // Throttle is 0 in order to stop the motors
  //127 is the middle value of the 10ADC.
    
  data.throttle = 0;
  data.yaw = 127;
  data.pitch = 127;
  data.roll = 127;
  data.AUX1 = 0;
  data.AUX2 = 0;
}

void blinkSteps0to2() {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa:
      if (ledState == HIGH) {
        ledState = LOW;
        blinkcount++;
      } else {
        ledState = HIGH;
        blinkcount++;
      }
      // set the LED with the ledState of the variable:
      digitalWrite(ledPin, ledState);
    }

void blinkStep3(){
    unsigned long currentMillis2 = millis();
    ledState = HIGH;

    if (currentMillis2 - previousMillis2 >= interval2) {
      // save the last time you blinked the LED
      previousMillis2 = currentMillis2;
      // set the LED with the ledState of the variable:
      blinkcount = 0;
    }
 }

void setup()
{
  //Start everything up
  Serial.begin(9600);
  radio.begin();
  pinMode(ledPin, OUTPUT);
  radio.setDataRate(RF24_250KBPS);
  radio.enableAckPayload();
  radio.openWritingPipe(pipeOut);
  resetData();
  radio.printDetails();
}

/**************************************************/

// Returns a corrected value for a joystick position that takes into account
// the values of the outer extents and the middle of the joystick range.
int mapJoystickValues(int val, int lower, int middle, int upper, bool reverse)
{
  val = constrain(val, lower, upper);
  if ( val < middle )
    val = map(val, lower, middle, 0, 128);
  else
    val = map(val, middle, upper, 128, 255);
  return ( reverse ? 255 - val : val );
}

void loop()
{
  // The calibration numbers used here should be measured 
  // for your joysticks till they send the correct values.
  data.throttle = mapJoystickValues( analogRead(A0), 13, 524, 1015, true );
  data.yaw      = mapJoystickValues( analogRead(A1),  1, 505, 1020, true );
  data.pitch    = mapJoystickValues( analogRead(A2), 12, 544, 1021, true );
  data.roll     = mapJoystickValues( analogRead(A3), 34, 522, 1020, true );
  data.AUX1     = digitalRead(4); //The 2 toggle switches
  data.AUX2     = digitalRead(5);
  Serial.print("Throttle: "); Serial.print(data.throttle);  Serial.print("    ");
  Serial.print("Yaw: ");      Serial.print(data.yaw);       Serial.print("    ");
  Serial.print("Pitch: ");    Serial.print(data.pitch);     Serial.print("    ");
  Serial.print("Roll: ");     Serial.print(data.roll);      Serial.print("    ");
  Serial.print("Aux1: ");     Serial.print(data.AUX1);      Serial.print("    ");
  Serial.print("Aux2: ");     Serial.print(data.AUX2);      Serial.print("\n");
  radio.write(&data, sizeof(MyData));
  while ( radio.isAckPayloadAvailable()) {
    radio.read(&ackPayload, sizeof(AckPayload));
      Serial.print(" Cell1 ");   Serial.print(ackPayload.cell1);
      Serial.print(" Cell2 ");   Serial.print(ackPayload.cell2);
      Serial.print(" Cell3 ");   Serial.print(ackPayload.cell3);
      Serial.print(" Cell4 ");   Serial.print(ackPayload.cell4);
  }
  currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    if (blinkcount <= 3) blinkSteps0to2() ;
    else blinkStep3() ; 
  }
}

RX

/* Test code for the Radio control transmitter
 *  Install the NRF24 library to your IDE
 * Upload this code to the Arduino UNO
 * Connect a NRF24 module to it:
 
    Module // Arduino UNO
    
    GND    ->   GND
    Vcc    ->   3.3V
    CE     ->   D9
    CSN    ->   D10
    CLK    ->   D13
    MOSI   ->   D11
    MISO   ->   D12

This code should print the received values to the serial monitor
Please, like share and subscribe : https://www.youtube.com/c/ELECTRONOOBS
*/
#include <Adafruit_SSD1306.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
const uint64_t pipeIn = 0xE8E8F0F0E1LL; //Remember that this code is the same as in the transmitter

RF24 radio(9, 10); 

//We could use up to 32 channels
struct MyData {
byte throttle; //We define each byte of data input, in this case just 6 channels
byte yaw;
byte pitch;
byte roll;
byte AUX1;
byte AUX2;
};

MyData data;

struct AckPayload {
  float cell1 = 0;
  float cell2 = 0;
  float cell3 = 0;
  float cell4 = 0;
};

AckPayload ackPayload;

int packetCounts[10];
int packetCountIndex = 0;
int packetCountTotal = 0;

void resetData()
{
//We define the inicial value of each data input
//3 potenciometers will be in the middle position so 127 is the middle from 254
data.throttle = 0;
data.yaw = 127;
data.pitch = 127;
data.roll = 127;
data.AUX1 = 0;
data.AUX2 = 0;

}

/**************************************************/

void setup()
{
Serial.begin(9600); //Set the speed to 9600 bauds if you want.
//You should always have the same speed selected in the serial monitor
resetData();
radio.begin();
radio.setAutoAck(1);
radio.enableAckPayload();
radio.writeAckPayload(1, &ackPayload, sizeof(AckPayload)); // pre-load data
radio.setDataRate(RF24_250KBPS);

radio.openReadingPipe(1,pipeIn);
//we start the radio comunication
radio.startListening();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
memset(&data, 0, sizeof(MyData));  
memset( packetCounts, 0, sizeof(packetCounts) );
}

/**************************************************/

unsigned long packetsRead = 0;
unsigned long lastScreenUpdate = 0;
unsigned long lastAvgUpdate = 0;
unsigned long lastRecvTime = 0;
unsigned long drops = 0;

void recvData()
{
while ( radio.available() ) {
radio.read(&data, sizeof(MyData));
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
ackPayload.cell1     = voltage;
radio.writeAckPayload(1, &ackPayload, sizeof(AckPayload)); // pre-load data
lastRecvTime = millis(); //here we receive the data
}
}

/**************************************************/

void loop()
{
recvData();
unsigned long now = millis();
//Here we check if we've lost signal, if we did we reset the values 
if ( now - lastRecvTime > 10000 ) {
// Signal lost?
resetData();
}
if ( now - lastScreenUpdate < 100 )
    return;
    
  // moving average over 1 second
  packetCountTotal -= packetCounts[packetCountIndex];
  packetCounts[packetCountIndex] = packetsRead;
  packetCountTotal += packetsRead;

  packetCountIndex = (packetCountIndex + 1) % 10;
  packetsRead = 0;

Serial.print("Throttle: "); Serial.print(data.throttle);  Serial.print("    ");
Serial.print("Yaw: ");      Serial.print(data.yaw);       Serial.print("    ");
Serial.print("Pitch: ");    Serial.print(data.pitch);     Serial.print("    ");
Serial.print("Roll: ");     Serial.print(data.roll);      Serial.print("    ");
Serial.print("Aux1: ");     Serial.print(data.AUX1);      Serial.print("    ");
Serial.print("Aux2: ");     Serial.print(data.AUX2);      Serial.print("\n");
Serial.print("Ack Sent: ");     Serial.print(ackPayload.cell1);      Serial.print("\n");
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(0.5);
display.setCursor(0, 0);
display.println("A0");
display.setCursor(20, 0);
display.println(data.throttle);
display.setCursor(45, 0);
display.println("A1");
display.setCursor(65, 0);
display.println(data.yaw);
display.setCursor(0, 10);
display.println("A2");
display.setCursor(20, 10);
display.println(data.pitch);
display.setCursor(45, 10);
display.println("A3");
display.setCursor(60, 10);
display.println(data.roll);
display.setCursor(0,20);
display.println("PPS");
display.setCursor(30, 20);
display.println(packetCountTotal);
display.setCursor(40,20);
display.println("AUX2");
display.setCursor(70, 20);
display.println(data.AUX2);
display.display();


}

/**************************************************/

Naresh_Rocker:
this is the code i used but it doesnt work kindly help..........

Have you managed to get any of my examples to work?

...R