nrf24l01 Radio Does not seem to be receiving please help.

Transmiter code

The transmitter is using an uno

#include <SPI.h>
#include “RF24.h”
#include <math.h>

#define ThermistorPIN1 0 // Analog Pin 0
#define ThermistorPIN2 1 // Analog Pin 0
#define ThermistorPIN3 2 // Analog Pin 0

float vcc = 4.98;

float pad1 = 10010;
float pad2 = 9900;
float pad3 = 9930;

RF24 radio(9,10);

const uint64_t addresses[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

float Thermistor(float pad,int RawADC) {
long Resistance;
float Temp; // Dual-Purpose variable to save space.

Resistance=pad*((1024.0 / RawADC) - 1);
Temp = log(Resistance); // Saving the Log(resistance) so not to calculate it 4 times later
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15; // Convert Kelvin to Celsius

return Temp; // Return the Temperature
}

void setup() {
Serial.begin(9600);
radio.begin();
radio.setRetries(15,15);
// 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.
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_1MBPS);

// Open a writing and reading pipe on each radio, with opposite addresses
radio.openWritingPipe(addresses[1]);
radio.openReadingPipe(1,addresses[0]);

}

void loop() {
unsigned long averagetrans = 0;
unsigned long average = 0;
unsigned long temp;
temp=Thermistor(pad1,analogRead(ThermistorPIN1)); // read ADC and convert it to Celsius
Serial.print("---------------[1]---------------\n");
Serial.print(“Celsius: “);
Serial.print(temp,1); // display Celsius
temp = (temp * 9.0)/ 5.0 + 32.0; // converts to Fahrenheit
Serial.print(”, Fahrenheit: “);
Serial.print(temp,1); // display Fahrenheit
Serial.println(””);
average = temp + average;

temp=Thermistor(pad2,analogRead(ThermistorPIN2)); // read ADC and convert it to Celsius
Serial.print("---------------[2]---------------\n");
Serial.print(“Celsius: “);
Serial.print(temp,1); // display Celsius
temp = (temp * 9.0)/ 5.0 + 32.0; // converts to Fahrenheit
Serial.print(”, Fahrenheit: “);
Serial.print(temp,1); // display Fahrenheit
Serial.println(””);
average = temp + average;

temp=Thermistor(pad3,analogRead(ThermistorPIN3)); // read ADC and convert it to Celsius
Serial.print("---------------[3]---------------\n");
Serial.print(“Celsius: “);
Serial.print(temp,1); // display Celsius
temp = (temp * 9.0)/ 5.0 + 32.0; // converts to Fahrenheit
Serial.print(”, Fahrenheit: “);
Serial.print(temp,1); // display Fahrenheit
Serial.println(””);
average = (temp + average)/3;
Serial.print(“the average is “);
Serial.print(average);
Serial.println(””);
averagetrans = (average *100);

Serial.print("---------------------------------------------------------------------");
Serial.println("");

Serial.println(F(“Now sending”));

// start_time = 1 + start_time;
bool ok = radio.write( &averagetrans, sizeof(unsigned long) );
if (ok)
Serial.println(F(“failed”));
else {
Serial.println(averagetrans);

} // Loop

}


Receiver code

the receiver is using a mega

#include <SPI.h>
#include “RF24.h”
#include <LiquidCrystal.h>
#include <math.h>

RF24 radio(49,53);
/**********************************************************/

const uint64_t addresses[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

LiquidCrystal lcd(22,24,26,28,30,32);

void setup() {
Serial.begin(9600);
radio.begin();
lcd.begin(16,2);
//lcd.print(“Current Temp is”);
radio.setRetries(15,15);
// 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.
radio.setPALevel(RF24_PA_MAX);
//radio.setDataRate(RF24_1MBPS);

// Open a writing and reading pipe on each radio, with opposite addresses
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1,addresses[1]);

// Start the radio listening for data
radio.startListening();

}

void loop() {
double temp;
double actualtemp1;
//if ( radio.available() )
//{
bool done = false;
while (!done)
{
done = radio.read( &temp, sizeof(unsigned long) );
actualtemp1 = temp;
actualtemp1 = actualtemp1/100;

// Delay just a little bit to let the other unit
// make the transition to receiver
delay(200);
}

double temp;
double actualtemp1;
//while(radio.available()){// Grab the response, compare, and send to debugging spew

//unsigned long end_time = micros();
Serial.print(F(“Recieved Temp is “));
Serial.print(actualtemp1);
Serial.print( " F”);
Serial.println(”");
lcd.setCursor(0,1);
lcd.print(actualtemp1);
lcd.print(" F");

delay(10);

} // Loop

Try one of the examples in this Simple nRF24L01+ Tutorial.

…R

I have tried others code and they are working. Mine for some reason will only sometimes work.

rickryckman:
I have tried others code and they are working. Mine for some reason will only sometimes work.

I thought, from your title, that you were wondering if one of your nRF24s was broken.

Please modify your Original Post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum Your code is too long for me to study quickly without copying to a text editor.

…R