Data loss in RX node (Wireless sensor monitoring using nRF24L01+)

Hello everybody,
Greetings.
I am trying to monitor a DHT11 humidity & Temp. sensor using nRF24L01+ wireless modules in simplex mode. The temperature information is partially missing in the RX node. Rx shows the partial information of the String that is being sent over the wireless modules.
Hardware:
I have 2 uno boards. In the TX board, the DTH sensor (Data pin of DHT is connected to pin 2) & nRF module is connected properly.
In the RX node only the nRF is connected.
nRF connections

TX Sketch:

#include <SPI.h>
#include <nRF24L01p.h>
#include "DHT.h"
#define DHTPIN 2     // what pin we're connected to
#define DHTTYPE DHT11   // DHT 11  (AM2302)
DHT dht(DHTPIN, DHTTYPE);
nRF24L01p transmitter(7,8);//CSN,CE
String message;
String error = "Failed to read from DHT";

void setup(){
  delay(150);
  Serial.begin(115200); //Initializing Serial communication Arduino<====>PC
  Serial.println("DHTxx test!");
  dht.begin();//DHT sensor Initializing
  SPI.begin();// Initializing SPI 
  SPI.setBitOrder(MSBFIRST);// set the transmission as MSB First
  transmitter.channel(90);
  transmitter.TXaddress("Artur");
  transmitter.init(); // Initializing transmitter
}

void loop(){
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();//store Humidity reading
  float t = dht.readTemperature();//store Temperature reading
  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    transmitter.txPL(error); // If no sensor is present send this acknowledgement message
    transmitter.send(SLOW); //
    Serial.println("Failed to read from DHT");// For debugging
  } 
  else {
    // create a String containing the required data
    message = "Humidity: " + String(h) + " %\t" + "Temperature: " + String(t) + " *C";
    Serial.println (message); // for debugging
    transmitter.txPL(message);
    transmitter.send(SLOW);
    message=""; // empty the message String
  }
}

Output:

RX Sketch:

#include <SPI.h>
#include <nRF24L01p.h>

nRF24L01p receiver(7,8);//CSN,CE

void setup(){
  delay(150);
  Serial.begin(115200);//Initializing Serial communication Arduino<====>PC
  SPI.begin();// Initializing SPI 
  SPI.setBitOrder(MSBFIRST);// set the transmission as MSB First
  receiver.channel(90);
  receiver.RXaddress("Artur");
  receiver.init();// Initializing receiver
}

String message;

void loop(){ 
  if(receiver.available()){ //if message is available
    receiver.read();// read received message
    receiver.rxPL(message);// process the received information
    Serial.println(message);// display the message
    message=""; // reset message String
  }
}

Output:

Problem:
The transmitted String is not properly received or displayed in the RX node.
Is it due to the payload (max. Payload = 32) ? the length of the received String (alpha-numeric) is 31 bytes I suppose.
The library I used, is attached herewith this post.
Kindly put some light on the issue. Thanks for your kind attention.
Good day.

nRF24L01p.rar (13.5 KB)

I'm not familiar with that nRF24L01p library you're using. Does it come with examples you can use to test the hardware and wiring?

The RF24 library I'm more familiar with has a maximum payload of 32 bytes (which I think is imposed by the RF24 chip) and the messages you're sending are much longer than that (I counted 38 bytes not counting a null terminator). I don't know what that library does if there is a buffer overflow on the sending or receiving side. To see whether that's the problem, you could change the sender to send a much shorter string and see whether the problems then stop.

Thanks PeterH for your views. Yes, the library contains example sketches. I shall try with shorter messages & update accordingly.
:slight_smile:

PeterH:
To see whether that's the problem, you could change the sender to send a much shorter string and see whether the problems then stop.

Your solution works perfectly. I shorten the TX node String contents & now the RX node shows the FULL Length information.

Received data is sometimes erroneous. Why is it happening?
What is the probable solution to eliminate these errors? Please give some idea
Thank you.

Seems as if you may be getting corruption on the connection. Does the library you are using support CRC? The RF chip does. If it is supported, enable it. I don't know anything about that library, but if it's any good it ought to enable you to configure the CRC checks, and also timeout and retransmission options. If so, the examples ought to demonstrate how to use these features. If you don't find that information, consider adopting ManiacBug's RF24 library instead - it is just as easy to use, works well, and comes with plenty of examples.

I am trying to recreate the same project
http://forum.arduino.cc/index.php?PHPSESSID=0lm0o7rko0ei3p4pdqjid12662&topic=232640.0

The objective is same to have the temperature / humidity be transmitted wirelessly using DHT11 sensor and be read through Serial Monitor of the computer.

When I compile the TX code below. I get the error message ----
"DHT11" was not declared in this scope.

Which DHT library did you use? Is there a link to download it? I am using DHT11 sensor too.
Any help would be appreciated.


#include <SPI.h>
#include <nRF24L01p.h>
#include "DHT.h"
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT11 // DHT 11 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
nRF24L01p transmitter(7,8);//CSN,CE
String message;
String error = "Failed to read from DHT";

void setup(){
delay(150);
Serial.begin(115200); //Initializing Serial communication Arduino<====>PC
Serial.println("DHTxx test!");
dht.begin();//DHT sensor Initializing
SPI.begin();// Initializing SPI
SPI.setBitOrder(MSBFIRST);// set the transmission as MSB First
transmitter.channel(90);
transmitter.TXaddress("Artur");
transmitter.init(); // Initializing transmitter
}

void loop(){
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();//store Humidity reading
float t = dht.readTemperature();//store Temperature reading
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
transmitter.txPL(error); // If no sensor is present send this acknowledgement message
transmitter.send(SLOW); //
Serial.println("Failed to read from DHT");// For debugging
}
else {
// create a String containing the required data
message = "Humidity: " + String(h) + " %\t" + "Temperature: " + String(t) + " *C";
Serial.println (message); // for debugging
transmitter.txPL(message);
transmitter.send(SLOW);
message=""; // empty the message String
}
}

PeterH:
Seems as if you may be getting corruption on the connection. Does the library you are using support CRC? The RF chip does. If it is supported, enable it. I don't know anything about that library, but if it's any good it ought to enable you to configure the CRC checks, and also timeout and retransmission options. If so, the examples ought to demonstrate how to use these features. If you don't find that information, consider adopting ManiacBug's RF24 library instead - it is just as easy to use, works well, and comes with plenty of examples.

Thanks again for your kind response. I shall try it with RF24 library. Visited the Maniacbug blog, it is nice. But the point at which I am stuck is the functions of the RF24 library. Right now I'm googling for a in-detail description of those RF24 functions. In the meanwhile my DHT11 is burnt due to uncontrolled power supply from wall adapter... :frowning:
I used a cheap 12V 1A wall adapter & it destroyed both the ATmega328 & DHT but FTDI is OK. Yesterday I replaced the Mega328. Going to test with LDR & Thermistor now.

wonrobot:
Which DHT library did you use? Is there a link to download it? I am using DHT11 sensor too.
Any help would be appreciated.

Here it is...
:slight_smile:

I m trying to send joystick data to another arduino via nrf24l01 to control multiple servos but another arduino is not receiving complete data. I'm not using delay in my sketch. I m using nRFlite library.

chandresh7885:
I m trying to send joystick data to another arduino via nrf24l01 to control multiple servos but another arduino is not receiving complete data. I'm not using delay in my sketch. I m using nRFlite library.

Why are you resurrecting a thread that is almost 5 years old? Best to start a new thread.

Don't be offended, I sometimes do the same thing!

Paul