espressif / esp-now

A connectionless Wi-Fi communication protocol
Apache License 2.0
477 stars 90 forks source link

esp now seems to have become intermittent (AEGHB-617) #117

Closed svdrummer closed 2 months ago

svdrummer commented 2 months ago

I have a system that has been working for months. Suddenly today, the data being received has become intermittent. As these are esp8266 units. two broadcast two receive the broadcasts. As I have not changed the code, could it be possible that channel 1 has become so busy that the channel is swamped? Different power supplies for each. Tried ne esp8266. When i look at the serial output which shows what is coming in vie esp now, there is nothing....then a bit of data... then nothing...later a few more strings of data.

Would appreciate any sugestions or if there is something broken.

I have tried Arduino old IDE and arduino new IDE. Both have the same issue. I am starting here, incase the espressif code has recent issue, the the arduino wrapper may be broken.

As i am using en esp8266 a channel change is not possible, only the esp32.

TIA

svdrummer commented 2 months ago

A few days later.. I have been trying to get this working, as it has always worked in the past for testing. The code below is the sender and the matching receiver . I am using esp8266. I have tested and working hundreds of these devices in commercial products. 8266 don't allow for channel change which only leaves two options. The wrapper has broken or I am being jammed on channel 1. People an commercial products programmers have become lazy, and i am seeing a large number of broadcast esp-now messages being sent on a regular basis. Whilst this may not be a library issue as such, I am trying to rule out there is a glitch or someone else has had an issue. Currently, my test bed is two esp8266 about two metres apart. For every 12 fails i get one success message. This is not normal with my years of exposure to esp-now. Thanks in advance. /* Rui Santos Complete project details at https://RandomNerdTutorials.com/esp-now-esp8266-nodemcu-arduino-ide/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. */

include

include

// Structure example to receive data // Must match the sender structure typedef struct struct_message { char a[32]; int b; float c; bool d; bool e; } struct_message;

// Create a struct_message called myData struct_message myData;

// Callback function that will be executed when data is received void OnDataRecv(uint8_t mac, uint8_t incomingData, uint8_t len) { memcpy(&myData, incomingData, sizeof(myData)); Serial.print("Bytes received: "); Serial.println(len); Serial.print("Char: "); Serial.println(myData.a); Serial.print("Int: "); Serial.println(myData.b); Serial.print("Float: "); Serial.println(myData.c); Serial.print("String: "); Serial.println(myData.d); Serial.print("Bool: "); Serial.println(myData.e); Serial.println(); }

void setup() { // Initialize Serial Monitor Serial.begin(115200);

// Set device as a Wi-Fi Station WiFi.mode(WIFI_STA); Serial.println(); Serial.println(WiFi.macAddress()); // Init ESP-NOW if (esp_now_init() != 0) { Serial.println("Error initializing ESP-NOW"); return; }

// Once ESPNow is successfully Init, we will register for recv CB to // get recv packer info esp_now_set_self_role(ESP_NOW_ROLE_SLAVE); esp_now_register_recv_cb(OnDataRecv); }

void loop() {

}

svdrummer commented 2 months ago

Followup feedback. It seems a commercial home automation device which uses an esp8266 lighting control unit......has gone faulty. Seems it was sending a carrier wave on channel one, which was blocking the esp-now channel one in the R&D office. A timely reminder that not all issues are software. I did consider this in my opening comment.