0

I am trying to transmit and receive the value using NRF24L01. I am sending 5 but receiving 0. The code i am using at the receiver's end is

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
Serial.begin(9600);
radio.begin();
 radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
}
void loop() {
Serial.println("clear 1 stage");
delay(500);
if (radio.available()) {Serial.println("clear 2 stage");
delay(500);
int count;
radio.read(&count, sizeof(count));
Serial.println(count);
}
}

and the code at transmitter end is

  #include <SPI.h>
  #include <nRF24L01.h>
  #include <RF24.h>
  RF24 radio(7, 8); // CE, CSN
  const byte address[6] = "00001";
  void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {   
  int count=5;
  radio.write(&count, sizeof(count));
  Serial.println("transmitted");
  Serial.println(count);
  delay(1000);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.