Hi guys,
I have a problem probably with code. I am using for my station 2x arduino and 2x nRF24L01 and dht22
The code seems to be ok, but its not work. I dont know what i have to do, I spend 6 hours to fix it :(. Can you please look at that code and tell me whats is wrong ? (Sorry for my english)
Code for Transmitter:
```
**#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <DHT.h>
#define DHTPIN 5 // do not connect to pin 0 or pin 1
#define DHTTYPE DHT22 // Define DHT22 module
DHT dht(DHTPIN, DHTTYPE); //create DHT object called dht
RF24 transmit (2,3); //create RF24 object called transmit
byte address [5] = “00001”; //set address to 00001
struct package
{
float temperature = 0;
float humidity = 0;
float rainfall = 0;
};
typedef struct package Package;
Package data;
void setup() {
dht.begin();
transmit.begin();
transmit.openWritingPipe(address); //open writing pipe to address 00001
transmit.setPALevel(RF24_PA_MAX); //set RF power output to maximum
transmit.setDataRate(RF24_250KBPS); //set datarate to 250kbps
transmit.setChannel(100); //set frequency to channel 100
transmit.stopListening();
}
void loop() {
data.temperature = dht.readTemperature();
data.humidity = dht.readHumidity();
transmit.write(&data,sizeof(data));
delay(1000);
}**
** __**and there is code for reciever:**__ **
**#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <LiquidCrystal.h>
RF24 receive (2,3);
byte address [5] = “00001”;
LiquidCrystal lcd(8,9,4,5,6,7);
int output_pin10 = 10;
int contrast = 75;
struct package
{
float temperature = 0;
float humidity = 0;
};
typedef struct package Package;
Package data;
void setup() {
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(“Now Receiving”);
pinMode(output_pin10, OUTPUT);
analogWrite(output_pin10, contrast);
receive.begin();
receive.openReadingPipe(0,address);
receive.setPALevel(RF24_PA_MIN);
receive.setDataRate(RF24_250KBPS);
receive.setChannel(100);
receive.startListening();
}
void loop() {
if (receive.available()) //check when received data available
{
receive.read(&data, sizeof(data));
lcd.setCursor(0,1);
lcd.print(data.temperature);
lcd.print(“C “);
lcd.print(data.humidity);
lcd.print(“%”);
}
}**
```