Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection problem between the NodeMCU and NRF24L01 Transceiver Module #92

Open
coding-ram opened this issue Sep 7, 2022 · 0 comments

Comments

@coding-ram
Copy link

coding-ram commented Sep 7, 2022

Hello there,
Myself Tony

I am trying to make wireless communication between Arduino UNO and the NodeMCU using the NRF24L01 Transceiver module connected to both the boards. The aim of the code is to turn ON the LED connected to the NODEMCU (acts as a receiver) when the button is pressed on the Arduino UNO(acts as a transmitter). Now the problem starts, the code works very well when I use Arduino Nano as the receiver instead of NodeMCU, But when I use the same code with the NODEMCU, it doesn't receive any data from the UNO. I searched a lot on the internet and tried various combinations of pin configuration for CE and CSN pins of NRF24L01 but none of them worked. I used the Node MCU because I want to connect the project to the internet for future use. I am attaching the code below for both the transmitter and the receiver. Please Please help me. I am tired of trying many times. Hope you guys will figure this out.

Transmitter Code For Arduino UNO

#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
int Trigger = 3;  // Sets Digital Pin D3 as the Trigger Input Pin. (External Button attached)

RF24 radio(7,8);   // Declaring CE and CSN pins.
const byte address[] = "Sensor1";  // Sets the Address of pipeline for sending the Data. This should be the same for both the transmitter and the receiver.
                                  
             
bool Trigger_Value ;  // the value returned by digitalRead(4) is stored here

void setup()
{
  Serial.begin(9600);
  
  radio.begin();  // Initializes the operations of the chip .
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();  // Starts sending the data through the above address pipeline . 
  pinMode(Trigger, INPUT); // Declares Trigger as an input.

}
                                                                          

void loop()
{
  Trigger_Value = digitalRead(Trigger);  // Stores the Trigger input value in the "Trigger_Value" variable.
  
  // Sending the "Trigger_Value" and Sizeof(Trigger_Value) Data to Receiver.
  radio.write(&Trigger_Value, sizeof(Trigger_Value));
  
  Serial.println("");
  
  Serial.print("Trigger_Value = ");
  Serial.print(Trigger_Value);
  Serial.print("      ");
  
  Serial.print("Size of Trigger_Value = ");
  Serial.println(sizeof Trigger_Value);
    
}

Receiver Code For Arduino Nano (Works Perfectly)

#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
#define Alarm D3  // Sets Digital Pin D3 as the Alarm Output Pin. 

//RF24 radio(7,8); // declaring CE and CSN pins for Arduino Boards
const byte address[] = "Sensor1"; // Sets the Address of pipeline for sending the Data. This should be same for both the transmitter and the receiver.

bool Trigger_Value = 0; // Stores the received data from the Transmitter that the Trigger gives.

void setup()
{
  Serial.begin(9600);
  
  radio.begin(); // Initializes the operations of the chip
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening(); // Starts receiving the data from the above address pipeline .
  
  pinMode(Alarm, OUTPUT); // declares Alarm as an output .
  
}


void loop()
{
  while(radio.available()){  

    // Receiving the "Trigger_Value" and Sizeof(Trigger_Value) Data from the Transmitter.
    radio.read(&Trigger_Value, sizeof(Trigger_Value)); 
    
    digitalWrite(Alarm, Trigger_Value);
    Serial.println("");
  
    Serial.print("Trigger_Value = ");
    Serial.print(Trigger_Value);
    Serial.print("      ");
  
    Serial.print("Size of Trigger_Value = ");
    Serial.println(sizeof Trigger_Value);
  }

}

Receiver Code For Node MCU (Not Working)

#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
#include <ESP8266WiFi.h>

#define Alarm D3  // Sets Digital Pin D3 as the Alarm Output Pin. 

RF24 radio(2,4); // declaring CE and CSN pins for Node MCU
const byte address[] = "Sensor1"; // Sets the Address of pipeline for sending the Data. This should be the same for both the transmitter and the receiver.

bool Trigger_Value; // Stores the received data from the Transmitter that the Trigger gives.

void setup()
{
  Serial.begin(9600);
  
  radio.begin(); // Initializes the operations of the chip
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening(); // Starts receiving the data from the above address pipeline .
  
  pinMode(Alarm, OUTPUT); // declares Alarm as an output .
  
}


void loop()
{
   
  
  while(radio.available()){  

    // Receiving the "Trigger_Value" and Sizeof(Trigger_Value) Data from the Transmitter.
    radio.read(&Trigger_Value, sizeof(Trigger_Value)); 
    
    digitalWrite(Alarm, Trigger_Value);
    Serial.println("");
  
    Serial.print("Trigger_Value = ");
    Serial.print(Trigger_Value);
    Serial.print("      ");
  
    Serial.print("Size of Trigger_Value = ");
    Serial.println(sizeof Trigger_Value);
  }

}

The wiring of the NRF24L01 Module with NodeMCU is as follows
MISO connects to pin D6 of the NodeMCU
MOSI connects to pin D7 of the NodeMCU
SCK connects to pin D5 of the NodeMCU
CE connects to pin D4 of the NodeMCU
CSN connects to pin D2 of the NodeMCU
GND and VCC of the NRF24L01 are connected to GND and 3.3V of the NodeMCU.

First, I tried the Node MCU code without the Internet but still, it is not working. Please help me out !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant