Hello everyone,
I would like to thank everyone who reads my post and everyone who tried to help.
I have 2 arduino nanos. To the first i have NRF24L01 connected to it and a push button connected to the A2 pin as a digital input and another connected to the pin 3. On the second nano, I have a LED connected to the pin 8 and one connected to the pin 7. What I am trying to do is send data from the receiver arduino which is the second arduino to the first to let it know that this receiver is still on and not unplugged. So when I comment this line "bool ok = network.write(header2, &sendingData, sizeof(sendingData));", everything works fine and the led is on when i press the pushbutton to a certain interval which i defined but when I uncomment that line, the led doesnt turn on and no data is received on the receiver side. So I would like to know if the receiver is being locked at sending which is why not receiving anymore and if there is any line i must add to let the nrf24l01 take turn between sending and receiving ?
here is the receiver side:
// Defining the SPI library and RF24
// We must make sure to download RF24 library and place it in the arduino libraries folder
#include <SPI.h>
#include <RF24.h>
#include <RF24Network.h>
//Defining radio object for the RF24 function pin 9 and 10 of arduino
RF24 radio(9, 10); // nRF24L01 (CE,CSN)
RF24Network network(radio); // Include the radio in the network
const uint64_t base = 00; // 00
const uint64_t this_node = 01; // Address of our node in Octal format ( 04,031, etc) // 01
// Defining the outputs
// Relay
int relay1Pin = 8;
int relay2Pin = 7;
int incomingData[2];
int sendingData[2];
int relay1 = 0;
int relay2 = 0;
void setup() {
Serial.begin(9600);
pinMode(relay1Pin, OUTPUT);
digitalWrite(relay1Pin, LOW);
pinMode(relay2Pin, OUTPUT);
digitalWrite(relay2Pin, LOW);
SPI.begin();
radio.begin();
network.begin(90, this_node); //(channel, node address)
radio.setDataRate(RF24_2MBPS);
}
void loop() {
//Serial.println("Entering loop()");
// For vibrator disk, we send values from 0 to 255 by the analogWrite() to the PWM pin to which it is connected
// or we send HIGH or LOW for on off by digitalWrite()
network.update();
while ( network.available() ) { // Is there any incoming data?
Serial.println("incomingData");
RF24NetworkHeader header;
network.read(header, &incomingData, sizeof(incomingData)); // Read the incoming data
relay1 = incomingData[0];
relay2 = incomingData[1];
}
Serial.println(incomingData[0]);
digitalWrite(relay1Pin, relay1);
digitalWrite(relay2Pin, relay2);
//===== Sending =====//
sendingData[0] = 1;
sendingData[1] = 0;
RF24NetworkHeader header2(base);
//bool ok = network.write(header2, &sendingData, sizeof(sendingData));
} // end of void loop()