Advertisement

nRF24L01+ Wireless Temperature Monitoring DS18B20 Arduino UNO

Parts List
  • nRF24L01+
  • DS18B20 Temperature Sensor
  • Arduino UNO
  • 4.7k resistor
Library

nRF24L01 Library
RF24 Library
DallasTemperature Library

Wiring

Wire nRF24L01+ to Arduino UNO

GND <–> GND
VCC <–> Arduino 3.3V
CE <–> Arduino pin 9
CSN <–> Arduino pin 10
SCK <–> Arduino pin 13
MOSI <–> Arduino pin 11
MISO <–> Arduino pin 12

 

nRF24L01_DS18B20_Arduino_UNO_TX_Elec-Cafe

nRF24L01_DS18B20_Arduino_UNO_RX_Elec-Cafe

Code

Upload Code to TX

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;

void setup(void) {
Serial.begin(9600);
sensors.begin();
radio.begin();
radio.openWritingPipe(pipe);
}

void loop(void)
{
sensors.requestTemperatures();
float temperature = sensors.getTempCByIndex(0);
radio.write(&temperature, sizeof(float));
delay(1000);
}

 

Upload Code to RX

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;

void setup(void) {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
Serial.begin(9600);
Serial.println("Temperature Starting.....");
delay(1000);
Serial.println("by www.elec-cafe.com");
delay(1000);
}

void loop(void)
{
if (radio.available()) {
float temperature = 0;
if (!radio.read(&temperature, sizeof(float))) {
Serial.println("ACK not received by client.");
}
Serial.print("Temperature : ");
Serial.println(temperature);
delay(1000);
}
}

Monitor Temperature

Use Serial monitor on Arduino UNO (RX)

nRF24L01_DS18B20_ArduinoUNO