I am using 3 ESP32's and talking between the three of them. I am only sending sensor data, but sometimes it isn't received.
I tried to use the "result == ESP_OK" to determine if the message was received, if not, continue to send until it is received, but that doesn't seem to work. Am I missing something? Or am I better off just sending continuously? That doesn't seem to be the best way to do things.
Here is a chunk of my code that verifies if a variable changes so I know if the data sent was received.
if(myData.g != Oldg){
esp_err_t result = esp_now_send(Tower_ESP, (uint8_t *) &myData, sizeof(myData));
if (result == ESP_OK) {
Oldg = myData.g;
Serial.println("Sending confirmed-4.5");
}
else {
Serial.println("Sending error-4.5");
}
}
It seems no matter what I do it will only send the data once, even when I know it wasn't received, so is the ESP==OK only saying that the data was sent whether or not it was received?
Do I need to send a confirmation from the receive ESP to verify it got the data? If that's the case, then I think I will just send constantly, this is getting messy the way it is.
I was going to put the ESP in Long Range mode, hopefully that will help with the packet loss, but I haven't found much information about how much better that works, or simple code to set it up. What little I found had drastically different code.
Thanks for any help.
ESP-NOW continue to send data if it fails
-
- Posts: 1701
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: ESP-NOW continue to send data if it fails
To know if and when esp-now data was sent and acknowledged you need to implement and register a send callback.
-
- Posts: 8
- Joined: Tue Apr 18, 2023 6:47 pm
Re: ESP-NOW continue to send data if it fails
So does that replace the line I have above, or do I need to add that as a seperate line?
Who is online
Users browsing this forum: Baidu [Spider], Bing [Bot], Majestic-12 [Bot] and 92 guests