-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreceiver.ino
46 lines (41 loc) · 1.19 KB
/
receiver.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
struct incoming_data {
int temperature;
int humidity;
float ppm;
};
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
radio.begin();
radio.setChannel(35);
radio.openReadingPipe(0, address); //Setting the address at which we will receive the data
radio.setPALevel(RF24_PA_LOW); //You can set this as minimum or maximum depending on the distance between the transmitter and receiver.
radio.setDataRate(RF24_250KBPS);
radio.startListening(); //This sets the module as receiver
}
incoming_data A;
void loop()
{
if (radio.available()) //Looking for the data.
{
radio.read(&A,sizeof(A));
lcd.setCursor(0,0);
lcd.print("temp:"+String(A.temperature)+"C");
lcd.setCursor(9,0);
lcd.print("hum:"+String(A.humidity)+"%");
lcd.setCursor(0,1);
lcd.print("ppm:"+String(A.ppm));
Serial.println(A.temperature);
Serial.println(A.humidity);
Serial.println(A.ppm);
}
}