Hello,
This is my first project with NRF24.
I am trying to measure at different spots the temperture. The data needs to be stored on a SD card and using a LCD display to show the tempertures I cut the project in 3 pieces. I am using 5 nodes (5 pro mini with DHT22) for sending all the data to node 00. This is working fine. I want to use a node 011 (mini with LCD) for displaying the data. At the moment, the data to node 011 is not recieved. Node 01 is running.
When I disconnect node 05 for measuring temperture and use node 05 for sending the data to, it works perfectly.
Can you please tell me what i am missing. Already a few days finding out where the problem could be.
Thanks for the reply,
Cheers,
node 00
// pin Lay out
// ----------------------
// pin 2 LED green
// pin 3 LED red
// pin 4 CS SD card
// pin 8 CSN nrf24
// pin 9 CE nrf24
// pin 11 MOSI SD, MOSI NRF24
// pin 12 MISO SD, MISO NRF24
// pin 13 CLK SD, CLK NRF24
// A4, A5 DS3231
// 1 2 3 4 5 6
// bmp280 DHT22 DHT2 FC37 bmp280 teller
// luchtdruk vochtig temp regen temp teller
//nrf2401 receiver
#include <SPI.h>
#include <Wire.h>
#include <RF24.h>
#include <RF24Network.h>
// Define Radio Pins
#define CE_PIN 9
#define CSN_PIN 8
// Create RF24 and RF24Network objects
RF24 radio(CE_PIN, CSN_PIN);
RF24Network network(radio);
// Define Node Addresses
const uint16_t MASTER_NODE = 011 ; // Node address of the receiver
const uint16_t SENDER_NODE = 00; // Node address of the sender
#include <SD.h>
File myFile; // CS op pin 4
#include <DS3231.h>
DS3231 rtc(SDA, SCL);
const byte greenLED = 2;
const byte redLED = 3;
float data[6];
float recdata[6];
/////////////////////////////////////////////////////////////////////
void setup()
{
Serial.begin(9600);
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
Serial.println("Starting");
if (!radio.begin()) {
Serial.println(F("radio hardware is not responding!!"));
while (1) {
digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
delay(100);
} // hold in infinite loop
}
network.begin(90, SENDER_NODE); // Start the network with node address 1
//radio.setDataRate(RF24_2MBPS); deze gaf problemen en werkt het zenden niet meer
radio.setPALevel(RF24_PA_LOW);
Serial.println(F("radio hardware is responding!!"));
Serial.println("Initializing SD card...");
if (!SD.begin(4)) {
while (1) {
digitalWrite(redLED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(redLED, LOW); // turn the LED off by making the voltage LOW
delay(2000);
}
}
rtc.begin();
digitalWrite(redLED, HIGH);
delay(500);
digitalWrite(redLED, LOW);
delay(500);
digitalWrite(redLED, HIGH);
delay(500);
digitalWrite(redLED, LOW);
delay(500);
digitalWrite(redLED, HIGH);
delay(500);
digitalWrite(redLED, LOW);
Serial.println("end setup");
}
//---------------------------------------------------------------------------------------------------
void loop()
{
digitalWrite(greenLED, LOW);
network.update(); // Check for incoming messages
// Check if we received a message
RF24NetworkHeader header;
if (network.available()) {
network.read(header, &data, sizeof(data)); // Read the incoming message
RF24NetworkHeader header(MASTER_NODE);
network.write(header, &data, sizeof(data));
// Print received data
//Serial.println("Received data:");
recdata[0] = data[0],0;
recdata[1] = data[1],0;
recdata[2] = data[2],1;
recdata[3] = data[3];
recdata[4] = data[4];
recdata[5] = data[5],0;
screen();
delay(50);
digitalWrite(greenLED, HIGH);
datawriting();
}
}
//----------------------------------------------------------store data on the SD card
void datawriting(){
int y=0; // teller
char *place[] = {"huiskam.csv", "overloop.csv", "achterpl.csv", "badkamer.csv","keuken.csv" };
if (recdata[0] == 10010) {
Serial.println("huiskam");
myFile = SD.open(place[0], FILE_WRITE);
}
if (recdata[0] == 10020) {
Serial.println("overloop");
myFile = SD.open(place[1], FILE_WRITE);
}
if (recdata[0] == 10030) {
Serial.println("achterpl");
myFile = SD.open(place[2], FILE_WRITE);
}
if (recdata[0] == 10040) {
Serial.println("badkamer");
myFile = SD.open(place[3], FILE_WRITE);
}
if (recdata[0] == 10050) {
Serial.println("keuken");
myFile = SD.open(place[4], FILE_WRITE);
}
Serial.println("start data writing");
/*
if (myFile) {
y=y+1;
myFile.print(rtc.getDateStr());
myFile.print(";");
myFile.print(rtc.getTimeStr());
myFile.print(";");
myFile.print(data[0]);
myFile.print(";");
myFile.print(data[1]);
myFile.print(";");
myFile.print(data[2]);
myFile.print(";");
myFile.print(data[3]);
myFile.print(";");
myFile.print(data[4]);
myFile.print(";");
myFile.print(data[5]);
myFile.print(";");
myFile.print(y);
myFile.println(";");
}
*/
myFile.close();
delay(500);
digitalWrite(greenLED, LOW);
Serial.println("end data writing");
delay(500);
Serial.println(" ");
}
void screen(){
Serial.print(rtc.getDateStr()); Serial.print("\t");
Serial.print(rtc.getTimeStr()); Serial.print("\t");
Serial.print(data[0],0); Serial.print("\t");
Serial.print(data[1],0); Serial.print("\t");
Serial.print(data[2],1); Serial.print("\t");
Serial.print(data[3],1); Serial.print("\t");
Serial.print(data[4],1); Serial.print("\t");
Serial.println(data[5],0);
//Serial.println(" ");
}
node 011
// pin Lay out
// ----------------------
// pin 2 LED green
// pin 3 LED red
// pin 4 CS SD card
// pin 8 CSN nrf24
// pin 9 CE nrf24
// pin 11 MOSI SD, MOSI NRF24
// pin 12 MISO SD, MISO NRF24
// pin 13 CLK SD, CLK NRF24
// A4, A5 DS3231
// 1 2 3 4 5 6
// bmp280 DHT22 DHT2 FC37 bmp280 teller
// luchtdruk vochtig temp regen temp teller
//nrf2401 receiver
#include <SPI.h>
#include <Wire.h>
#include <RF24.h>
#include <RF24Network.h>
// Define Radio Pins
#define CE_PIN 9
#define CSN_PIN 8
// Create RF24 and RF24Network objects
RF24 radio(CE_PIN, CSN_PIN);
RF24Network network(radio);
// Define Node Addresses
const uint16_t MASTER_NODE = 00 ; // Node address of the receiver
const uint16_t SENDER_NODE = 011; // Node address of the sender
#include <DS3231.h>
DS3231 rtc(SDA, SCL);
const byte greenLED = 2;
const byte redLED = 3;
float data[6];
float recdata[6];
/////////////////////////////////////////////////////////////////////
void setup()
{
Serial.begin(9600);
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
Serial.println("Starting");
if (!radio.begin()) {
Serial.println(F("radio hardware is not responding!!"));
while (1) {
digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
delay(100);
} // hold in infinite loop
}
network.begin(90, SENDER_NODE); // Start the network with node address 1
//radio.setDataRate(RF24_2MBPS); deze gaf problemen en werkt het zenden niet meer
radio.setPALevel(RF24_PA_LOW);
Serial.println(F("radio hardware is responding!!"));
//rtc.begin();
digitalWrite(redLED, HIGH);
delay(500);
digitalWrite(redLED, LOW);
delay(500);
digitalWrite(redLED, HIGH);
delay(500);
digitalWrite(redLED, LOW);
delay(500);
digitalWrite(redLED, HIGH);
delay(500);
digitalWrite(redLED, LOW);
Serial.println("end setup");
}
//---------------------------------------------------------------------------------------------------
void loop()
{
digitalWrite(greenLED, LOW);
network.update(); // Check for incoming messages
// Check if we received a message
RF24NetworkHeader header;
if (network.available()) {
network.read(header, &data, sizeof(data)); // Read the incoming message
// Print received data
//Serial.println("Received data:");
recdata[0] = data[0],0;
recdata[1] = data[1],0;
recdata[2] = data[2],1;
recdata[3] = data[3];
recdata[4] = data[4];
recdata[5] = data[5],0;
screen();
delay(50);
}
}
void screen (){/*
//Serial.println("node vochtigh. temp spare spare teller");
Serial.print(recdata[0],0);
Serial.print("\t");
Serial.print(recdata[1],0);
Serial.print("%");
Serial.print(" ");
Serial.print("\t");
Serial.print(recdata[2],1);
Serial.print(" ");
Serial.write(0xC2);
Serial.write(0xB0);
Serial.print("C ");
Serial.print("\t");
Serial.print(recdata[3],0);
Serial.print("\t");
Serial.print(recdata[4],0);
Serial.print("\t");
Serial.println(recdata[5],0);
Serial.println();
*/
//Serial.print(rtc.getDateStr()); Serial.print("\t");
//Serial.print(rtc.getTimeStr()); Serial.print("\t");
Serial.print(data[0],1); Serial.print("\t");
Serial.print(data[1],1); Serial.print("\t");
Serial.print(data[2],1); Serial.print("\t");
Serial.print(data[3],1); Serial.print("\t");
Serial.print(data[4],1); Serial.print("\t");
Serial.println(data[5],1);
}
node 01
// pin lay out
//
// pin 2 cs DHT22
// pin 4 LED
// pin 8 CSN nrf24
// pin 9 CE nrf24
// pin 11 MOSI NRF24
// pin 12 MISO NRF24
// pin 13 CLK NRF24
// 1 2 3 4 5 6
// node DHT22 DHT22 spare spare teller
// nr vochtigheid temp teller
#include <SPI.h>
#include <Wire.h>
#include <RF24.h>
#include <RF24Network.h>
// Define Radio Pins
#define CE_PIN 9
#define CSN_PIN 8
// Create RF24 and RF24Network objects
RF24 radio(CE_PIN, CSN_PIN);
RF24Network network(radio);
// Define Node Addresses
const uint16_t MASTER_NODE = 00 ; // Node address of the receiver
const uint16_t SENDER_NODE = 01; // Node address of the sender
#include "DHT.h"
#define DHTPIN1 2
#define DHTTYPE1 DHT22
DHT dht1(DHTPIN1, DHTTYPE1);
float hum1 = 0; //
float tempdht1 = 0;
float cortemp1 = -0.3 ;// +0.2
float corhum1 = -1.1 ; // 0.0
float teller = 0.0;
// Define the size of the float array
float data[6] ; // Example float array
void setup() {
Serial.begin(9600);
if (!radio.begin()) {
Serial.println(F("radio hardware is not responding!!"));
while (1) {
digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
delay(100);
} // hold in infinite loop
}
network.begin(90, SENDER_NODE); // Start the network with node address 1
//radio.setDataRate(RF24_2MBPS); deze gaf problemen en werkt het zenden niet meer
dht1.begin();
radio.setPALevel(RF24_PA_LOW);
Serial.println(F("radio hardware is responding!!"));
Serial.println(" ");
Serial.println("node vocht temp niets niets teller");
Serial.println(" ");
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(100);
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(1000);
}
void loop() {
hum1 = dht1.readHumidity();
tempdht1 = dht1.readTemperature();
data[0] = 10010; // node adress
data[1] = hum1 + corhum1;
data[2] = tempdht1 + cortemp1;
data[3] = 0;
data[4] = 0;
data[5] = teller;
// Send the data to the receiver node
RF24NetworkHeader header(MASTER_NODE);
network.write(header, &data, sizeof(data));
//----- display on local monitor: ------------
Serial.print(data[0],0);
Serial.print(" ");
Serial.print("\t");
Serial.print(data[1],0);
Serial.print("%");
Serial.print(" ");
Serial.print("\t");
Serial.print(data[2],1);
Serial.print(" ");
Serial.write(0xC2); //send degree symbol
Serial.write(0xB0); //send degree symbol
Serial.print("C ");
Serial.print("\t");
Serial.print(data[3],0);
Serial.print(" ");
Serial.print("\t");
Serial.print(data[4],0);
Serial.print("\t");
Serial.print(data[5],0);
Serial.println("\t");
delay(1000);
digitalWrite(4, HIGH);
delay(2000); // was 8000
digitalWrite(4, LOW);
delay(7000); //elke 5 minuten een data was 290000
teller=teller+1;
}