Hi I searched on internet about ESP-NOW, and i discovered that this protocol of the esp32 can receive messages from an Arduino using NRF24L01.
But nobody explain how to code the receiver (the esp32 with the protocol ESP-NOW).
I have writed the code for the transmitter (the Arduino).
//#include <Wire.h>
#include <SPI.h>
#include "RF24.h"
RF24 myRadio (9, 10); //CE = D9 | CS = D10
byte addresses[][6] = {"0"};
struct package{ //Declare struct with datas
String toSend = "Hello!";
};
typedef struct package Package;
Package data; //declare "data" to interact with the struct
//----------------------------------------------------------------------------
void setup(){
Serial.begin(9600);
delay(1000);
myRadio.begin();
myRadio.setChannel(115);
myRadio.setPALevel(RF24_PA_MAX); //RF24_PA_MAX -> High and Low signal| RF24_PA_MIN -> No signal | RF24_PA_HIGH -> Only High signal | RF24_PA_LOW -> Only Low signal
myRadio.setDataRate(RF24_250KBPS);
myRadio.openWritingPipe(addresses[0]);
delay(1000);
}
void loop(){
delay(2000);
myRadio.write(&data, sizeof(data)); //Send the struct with all datas
}
Now, how can i set my esp32 to receive the struct? i really don't now...
Thank very much.
Surely this would be part of the details that the site you have found would contain
I note that in the code you posted there is no mention of the MAC address of the target ESP32, which is a fundamental part of ESP-NOW. Indeed, the code looks like a perfectly normal NRF24 transmitter
Ah, sorry, I did not understand that ESP-NOW only works with another ESP-NOW, now everything is clearer to me.
I can only use:
ESP-NOW <---> ESP-NOW
can't use:
ESP-NOW <---> NRF24L01
A possible solution would be to connect another nrf24l01 module to my ESP32, so that I can communicate (therefore receive) from my Arduino which transmits with an nrf24l01?
This could work.
Though both nRF24 and ESP-NOW use the same radio-frequency
you would have to make sure that their channel-frequencies are "wide" from each other.
And as an ESP32 can do anything an Arduino can do the only reason for combining an arduino with an nRF24 would be an existing and running project or a project that uses an Arduino Mega with his lots of IO-pins for creating high-frequency-PWM-signals or other more special input-capture-features.
For lower PWM-signals or simple on/off-switching an ESP32 with IO-expander-chips and a ADC-module will do the job and offer even more FLASH and RAM than an Arduino Mega does