This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Arduino, DS18B20 and NRF24l01

Hello guys, I'm doing a hobby project and can't seem to get it working. Aim of the project is to transmit temperature values from a DS18B20 using an Arduino Uno and NRF24l01. The receiver should receive temperature values from transmitter and display. Already worked on the code and the partial code is below.

TX part

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

#define ONE_WIRE_BUS 2 #define CE_PIN 9 #define CSN_PIN 10 #define ONE_WIRE_BUS 2 RF24 radio(CE_PIN, CSN_PIN); //RF24Network network(radio);

const uint16_t this_node = 1; const uint16_t other_node = 0; const unsigned long interval = 2000; //ms const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

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

void setup(void) { Serial.begin(9600); radio.begin(); radio.setChannel(127); Serial.println("Dallas Temperature IC Control Library Demo"); // network.begin(80, this_node); radio.openWritingPipe(pipes[1]); radio.openReadingPipe(1, pipes[0]); sensors.begin(); }

void loop(void) { Serial.print(" Requesting temperatures..."); sensors.requestTemperatures(); // Send the command to get temperatures Serial.println("DONE"); float currentTemp = sensors.getTempFByIndex(0); //RF24NetworkHeader header(other_node); //bool ok = network.write(header, &currentTemp, sizeof(currentTemp)); radio.powerUp(); radio.write( &currentTemp, sizeof(currentTemp) ); Serial.print("Temperature for Device 1 is: "); Serial.print(currentTemp); }

RX part

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

#define CE_PIN 9 #define CSN_PIN 10 RF24 radio(CE_PIN, CSN_PIN); //RF24Network network(radio);

const uint16_t this_node = 1; const uint16_t other_node = 0; const unsigned long interval = 2000; //ms const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

void setup(void) { Serial.begin(9600); delay(1000); radio.begin(); radio.setChannel(127); Serial.println("Nrf24L01 Receiver "); //network.begin(80, this_node); radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1, pipes[1]); radio.startListening();; }

void loop(void) { float currentTemp; if ( radio.available() ) { { bool done = false; while (!done) { //RF24NetworkHeader header; //bool ok = network.read(header, &currentTemp, sizeof(currentTemp)); done = radio.read( &currentTemp, sizeof(currentTemp) ); Serial.println("Temperature for Device 1 is: "); Serial.println(currentTemp); } } } else Serial.println("radio not found"); }

Transmitter is working perfectly but I'm not receiving any data at the receiver. The following websites were used to connect the circuit. The radios work as the example code works perfectly. Any help is appreciated

www.hobbytronics.co.uk/ds18b20-arduino arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo

Related