Skip to content

The NRF24L01 receiver isn't receiving the message #102

@shreyassahu

Description

@shreyassahu

//Transmitter code
#include <nRF24L01.h> //NRF24L01 library created by TMRh20 https://github.com/TMRh20/RF24
#include <RF24.h>
#include <SPI.h>

int SentMessage[1] = {111};
RF24 radio(7,8); // NRF24L01 used SPI pins + Pin 9 and 10 on the NANO

const byte address[6] = "node1"; // Needs to be the same for communicating between 2 NRF24L01

void setup()
{
// pinMode(SwitchPin, INPUT_PULLUP);
// digitalWrite(SwitchPin,HIGH);

radio.begin(); // Start the NRF24L01
radio.openWritingPipe(address); // Get NRF24L01 ready to transmit
}

void loop()
{

  SentMessage[0] = {111};
  radio.write(SentMessage, 1);
  delay(100);

}

//Receiver Code
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
int RELAY=4;
RF24 radio(7, 8); // CE, CSN
int receivedMessage[1] = {111};
const byte address[6] = "node1";
void setup() {
// Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1, address);
// radio.setPALevel(RF24_PA_MIN);
radio.startListening();
pinMode(RELAY,LOW);
}

void loop()
{
while(radio.available())
{
radio.read(receivedMessage,1);

if(receivedMessage[0] == 111)
{
  digitalWrite(RELAY,HIGH);
}
else
{
  digitalWrite(RELAY,LOW);
}

// delay(2);
}
}

I am working on an automation project that uses NRF24L01 modules connected to an Arduino UNO(the receiver) and Arduino Nano(the transmitter). I have done the connections correctly. The receiver end doesn't work (the relay is not turning on) even though the transmitter is transmitting the message with the same address. What seems to be the issue here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions