NRF2401 - Is this problem caused by power supply or is it the code?

Hi,
I have connected a DHT22 temperature and humidity sensor to my Arduino UNO. The sensor works fine while displaying data to the serial monitor. Also, I have successfully established a connection between two nRF24L01. The receiving unit displays my test message to the receiving units serial monitor.

Problem starts when I send the sensor data the same way. The serial monitor displays the data like this:

Package:13107
0.00
⸮A

I have changed the baudrate and but it does not help. I googled the problem and I think it could be a problem related to power supply. The tutorials suggest that I should solder a capacitor to the NRF24L01.
But I am not 100 % sure because it obviously sends something and the my setup can receive dummy messages in plain text. What do you recommend? Any advice appreciated!

One of several failures below…

/// receiving unit

#include "RF24.h" 

RF24 myRadio (7, 8); 
struct package
{
  int id=0;
  float temperature = 0.0;
  char  text[100] ="empty";
};

byte addresses[][6] = {"0"}; 



typedef struct package Package;
Package data;

void setup() 
{
  Serial.begin(9600);
  delay(1000);

  myRadio.begin(); 
  myRadio.setChannel(115); 
  myRadio.setPALevel(RF24_PA_MAX);
  myRadio.setDataRate( RF24_250KBPS ) ; 
  myRadio.openReadingPipe(1, addresses[0]);
  myRadio.startListening();
}


void loop()  
{

  if ( myRadio.available()) 
  {
    while (myRadio.available())
    {
      myRadio.read( &data, sizeof(data) );
    }
    Serial.print("\nPackage:");
    Serial.print(data.id);
    Serial.print("\n");
    Serial.println(data.temperature);
    Serial.println(data.text);
  }

}

// sending *EDITED, changed to send code
#include “DHT.h”
#include <SPI.h>
#include “RF24.h”

#define DHTPIN 4
#define DHTTYPE DHT22

RF24 myRadio (7, 8);
byte addresses[6] = {“0”};
const int led_pin = 13;

struct package
{
float temperature ;
float humidity ;
};

typedef struct package Package;
Package data;

DHT dht(DHTPIN, DHTTYPE);

void setup()
{
Serial.begin(9600);
pinMode(led_pin, OUTPUT);
dht.begin();
myRadio.begin();
myRadio.setChannel(115);
myRadio.setPALevel(RF24_PA_MAX);
myRadio.setDataRate( RF24_250KBPS ) ;
myRadio.openWritingPipe( addresses[0]);
delay(1000);
}

void loop()
{
digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
readSensor();
Serial.println(data.humidity);
Serial.println(data.temperature);
myRadio.write(&data, sizeof(data));
digitalWrite(led_pin, LOW);
delay(1000);
}

void readSensor()
{
data.humidity = dht.readHumidity();
data.temperature = dht.readTemperature();
}

[/code]

You seem to have posted the Receiving program twice by mistake.

What version of the RF24 library are you using?

This Simple nRF24L01+ Tutorial may be of interest.

...R

I edited my post and pasted code from the sending unit.
Currently, I am using version 1.3.0 of the RF24 library.

Thanks for the link. A lot of valuable information posted in that thread. If my problem isn't caused by the hardware I probably just start my project from scratch with the libraries discussed in the other thread.

Spirou:
Currently, I am using version 1.3.0 of the RF24 library.

Where did you get the library from - post a link.

IIRC the ManiacBug version of the library does not work happily with delay()s

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features - rather than adding wireless to an existing program.

...R