ESP-NOW Rx detecting loss of Tx signal.

Tron76
Posts: 2
Joined: Tue Feb 14, 2023 1:18 pm

ESP-NOW Rx detecting loss of Tx signal.

Postby Tron76 » Tue Feb 14, 2023 1:32 pm

I am using ESP-NOW and two ESP32's to control my grand-sons model train set. And I have had no trouble controlling the stop/start, direction, or speed of the train using the ESP-NOW examples. What I have been unable to do is stop the engine when there is a loss of Tx signal. Right now the train keeps right on going even when the Tx signal is lost.

Thank you very much,
Tron76

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP-NOW Rx detecting loss of Tx signal.

Postby ESP_Sprite » Thu Feb 16, 2023 4:02 am

Well, ESP-Now is sent as packets, meaning on the receiving end there's no difference between 'the transmitter sent something that wasn't received' and 'the transmitter didn't send anything'. What you would want to do is send data periodically (e.g. every 100ms or so), and detect loss of Tx by noticing you haven't received any packets for some multiple of that 100ms.

Tron76
Posts: 2
Joined: Tue Feb 14, 2023 1:18 pm

Re: ESP-NOW Rx detecting loss of Tx signal.

Postby Tron76 » Fri Feb 17, 2023 10:57 pm

ESP-Sprite.

Yes A loss of packets received is exactly what I need.
But so far I have not been able to figure out how to do it.

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP-NOW Rx detecting loss of Tx signal.

Postby ESP_Sprite » Sat Feb 18, 2023 12:46 am

As I said: on the transmitter side, send packets every 100mS or so. On the receiver side, implement a timer that times out after 500mS or so. Reset that timer every time a packet arrives. If the timer times out, you missed 5 packets in a row and probably lost signal.

Who is online

Users browsing this forum: Baidu [Spider] and 58 guests