leonyuhanov / ESP-NOW-TX-RX

A very basic TX and RX demo for the ESP-NOW Protocol for the ESP8266 & ESP32
Apache License 2.0
87 stars 13 forks source link

ESP-NOW-TX-RX

A very basic TX and RX demo for the ESP-NOW Protocol for the ESP8266 & ESP32

DUAL Mode RX/TX on 2 devices

FOR the ESP8266:

DualModeMaster : Has code for a master/server that sends a PING with a 200Byte data packet to the slave and prints the time in micros for it to return

DualModeSlave : Has code for a slave/node that waits for a PING with a 200Byte data packet and returns same

FOR the ESP32:

ESP32_DualMode_Master : Has code for a master/server that sends a PING with a 200Byte data packet to the slave and prints the time in micros for it to return

ESP32_DualMode_Slave : Has code for a slave/node that waits for a PING with a 200Byte data packet and returns same NOTES:

Setup Instructions FOR the ESP8266

If you are using Arduino IDE you need to do the following before compiling:

  1. Make sure you have the LATEST espnow.h file get it form here https://github.com/esp8266/Arduino/blob/d24a358817f0c11f7087b3c8acbf24629b15998f/tools/sdk/include/espnow.h and replace what you have in C:\Users\YOUR_USER_NAME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\tools\sdk\include

  2. Open the file C:\Users\YOUR_USER_NAME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\platform.txt find the line that starts with "compiler.c.elf.libs" add the following(without talking marks) to the END OF THE LINE and save "-lespnow"

Things I found deep in the rabbit hole

 extern "C"{
   #include <espnow.h>
   #include "user_interface.h"
 }
 uint8_t mac[] = {0x36, 0x33, 0x33, 0x33, 0x33, 0x33};
 void initVariant()
 {
   wifi_set_macaddr(STATION_IF, &mac[0]);
 }

For the ESP32 read https://github.com/espressif/esp-idf/issues/3238 for very detailed explanantion of espnow speeds and ways to controll them using the espidf example code here https://github.com/leonyuhanov/ESP32_ESPIDF_ESPNOW