Hello,
I earlier posted something about the nrf24l01+ but that was because there was no communication between them. Since i got that working, I noticed that the communication isn't realy stable. I check if there is a sensor and if there is it has to display the measured temperature on the screen. this can be 1 sensor or 2 sensors. And in the future I want to measure more values and display them.
I don't know where to look to get this stable. in the code:
RX
// --------------- llibrary's voor receiver ---------------------------------
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include "printf.h"
#include <SPI.h>
// ---------------------------------- Variabelen voor receiver ---------------------------------
float temp1, temp2;
// LET OP WELKE CE - CSN PIN JE GEBRUIKT!!
RF24 radio(46, 48);
const uint64_t pipes[6] = { 0xE8E8F0F0E1LL, 0xE8E8F0F0E2LL, 0xE8E8F0F0E3LL, 0xE8E8F0F0E4LL, 0xE8E8F0F0E5LL, 0xE8E8F0F0E6LL };
// ---------------------- setup ------------------------------
void setup() {
Serial.begin(115200);
//--------------SETUP nRF24L01------------------------
Serial.println("start ontvanger");
radio.begin(); // start the radio
radio.openReadingPipe(1, pipes[1]);
radio.openReadingPipe(2, pipes[2]);
radio.startListening();
}
// ------------------------------------- loop ---------------------------
void loop() {
uint8_t pipeNum;
if (radio.available(&pipeNum)) {
if(pipeNum == 1)
{
radio.read(&temp1, sizeof(temp1));
Serial.println(temp1);
Serial.print("temp1");
}
if(pipeNum == 2)
{
radio.read(&temp2, sizeof(temp2));
Serial.println(temp2);
Serial.print("temp2");
}
}
}
TX1 (the values are hardcoded for easier testing)
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include "printf.h" // comment this out if no radio info on serial
#include <SPI.h>
float temp2;
// LET OP WELKE CE - CSN PIN JE GEBRUIKT!!
RF24 radio(9, 10);
const uint64_t pipes[6] = { 0xE8E8F0F0E1LL, 0xE8E8F0F0E2LL, 0xE8E8F0F0E3LL, 0xE8E8F0F0E4LL, 0xE8E8F0F0E5LL, 0xE8E8F0F0E6LL };
// ---------------------- setup ------------------------------
void setup(void) {
Serial.begin(115200); // start the serial
Serial.println("Start zender");
radio.begin(); // start the radio
radio.openWritingPipe(pipes[2]); // open our pipe for communication
radio.setRetries(15, 15);
}
// ------------------------------------- loop ---------------------------
void loop(void) {
temp2 = 22.22;
radio.write(&temp2, sizeof(temp2));
}
TX2 (also hard coded value)
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include "printf.h" // comment this out if no radio info on serial
#include <SPI.h>
float temp1;
RF24 radio(9, 10);
const uint64_t pipes[6] = { 0xE8E8F0F0E1LL, 0xE8E8F0F0E2LL, 0xE8E8F0F0E3LL, 0xE8E8F0F0E4LL, 0xE8E8F0F0E5LL, 0xE8E8F0F0E6LL };
// ---------------------- setup ------------------------------
void setup(void) {
Serial.begin(115200); // start the serial
Serial.println("Start zender");
radio.begin(); // start the radio
radio.openWritingPipe(pipes[1]); // open our pipe for communication
radio.setRetries(15, 15);
}
// ------------------------------------- loop ---------------------------
void loop(void) {
temp1 = 11.11;
radio.write(&temp1, sizeof(temp1));
}
There is communication between the modules and the values it receives are correct but they aren't "seeing" each other every time it has to..
can someone explain to me what i am doing wrong?? this sketch is without screen because every one has different screens