I've 2x NRF24L01 modules, Arduino Mega board, and ESP32 board.
I found a lot of tutorials to connect the module with arduino and NodeMCU, but I can't find an examples or tutorials to connect the rf modules to the esp32 board
Robin2:
Why use an nRF24 when the ESP32 has WiFi, ESP-NOW and Bluteooth?
...R
this is first time i know about ESP-NOW
the case that I need to get data from sensor that isn't near a wifi so I searched for radio connectivity between two mcus
will ESP-Now help me with this as the range is about 500 600 meters
I use the rf24 radios quite a bit with mega328 processors, but never with ESP8266 or ESP32s. So I thought to give it a try. I wired the rf24 to an ESP32 like so (ESP pins are as marked on my dev board) using the hardware SPI:
rf24 pin ESP pin
1 ground
2 3.3V Note (10uF cap across ground and 3.3V)
3 (CE) 22
4 (CSN) 21
5 (SCK) 18
6 (MOSI) 23
7 (MISO) 19
Make sure that you have the latest rf24 library. The library manager has the latest.
Here is the receive code from Robin2's simple rf24 tutorial, slightly modified to use different CE and CSN pins. This works with the sender sketch from the tutorial. I used an Uno to send test data to test this setup and code.
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <RF24.h>
#include <nRF24L01.h>
#define CE_PIN 22
#define CSN_PIN 21
const byte thisSlaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
RF24 radio(CE_PIN, CSN_PIN);
char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;
//===========
void setup()
{
Serial.begin(9600);
delay(3000);
Serial.println("SimpleRx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
}
//=============
void loop()
{
getData();
showData();
}
//==============
void getData()
{
if ( radio.available() )
{
radio.read( &dataReceived, sizeof(dataReceived) );
newData = true;
}
}
void showData()
{
if (newData == true)
{
Serial.print("Data received ");
Serial.println(dataReceived);
newData = false;
}
}
I can see the usefulness of this setup. Better range than Bleutooth, easy communication with an Arduino like Nano, Uno, Mega, ... To communicate with an ESP32 to ESP32 or ESP8266, ESP_NOW would probably be better.
KareemWaheed:
this is first time i know about ESP-NOW
the case that I need to get data from sensor that isn't near a wifi so I searched for radio connectivity between two mcus
will ESP-Now help me with this as the range is about 500 600 meters
That distance will be a struggle even for high power 2.4Ghz wireless with directional antennas - especially if there are obstacles in the way. Lower frequency wireless such as the HC12 is better for longer ranges.
It will be much easier to give useful advice if you describe the project you want to create rather than just asking questions about specific parts of it.
groundFungus:
Here is the receive code from Robin2's simple rf24 tutorial, slightly modified to use different CE and CSN pins. This works with the sender sketch from the tutorial.
Robin2:
That distance will be a struggle even for high power 2.4Ghz wireless with directional antennas - especially if there are obstacles in the way. Lower frequency wireless such as the HC12 is better for longer ranges.
It will be much easier to give useful advice if you describe the project you want to create rather than just asking questions about specific parts of it.
...R
The project is
I've a gateway with internet connectivity in a building inside a farm.
and there is an analog sensor or two sensors I want to send their readings to the gateway (it is about 300-400 meters away from the building open field with some trees and palms in between)
so I want to connect the sensors to a NodeMcu-Arduino-etc.. whatever microcontroller I should use and there is no internet connectivity around the analog sensors so I need a way to send the readings from the mcu to the gateway inside the building
Thanks
KareemWaheed:
(it is about 300-400 meters away from the building open field with some trees and palms in between)
It might work if you have a high-power nRF24 (with external antennas) at each end but the moisture in the leaves of trees is notorious for attenuating 2.4Ghz wireless signals.
IMHO it would be better to try a pair of HC12 modules though I have not used them myself. I believe they just use a serial connection with the Arduino (or whatever).
Robin2:
It might work if you have a high-power nRF24 (with external antennas) at each end but the moisture in the leaves of trees is notorious for attenuating 2.4Ghz wireless signals.
IMHO it would be better to try a pair of HC12 modules though I have not used them myself. I believe they just use a serial connection with the Arduino (or whatever).