Sonoff Relay, UDP SendTo, and Wifi interference

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mrh_icb
Normal user
Posts: 11
Joined: 08 Oct 2020, 04:15

Sonoff Relay, UDP SendTo, and Wifi interference

#1 Post by mrh_icb » 09 Oct 2020, 04:54

I ran into an interesting issue, when trying to use Global Sync / ESPEasy P2P to network several Sonoff BASIC relays.
It seems that RF interference is caused by the Sonoff relay, which causes UDP packets dopped over Wifi. I thought I report my finding, in case anybody runs into it.

I used 2 Sonoff BASIC R2 relays, with an external switch on GPIO-14 each. Operating the switch on either unit shall flip the relay on both.
I enabled Global Sync / P2P on both, and assigned unit number 1 and 2.

First the non-working code, the sendto command never worked. It seems the UDP send gets disturbed by the local relay operating on GPIO-12.

Code: Select all

on switch#state do
  if [relay#state]=1
    gpio,12,0 // turn off local relay
    sendto,1,gpio,12,0 // turn off remote relay
  else
    gpio,12,1 // turn on local relay
    sendto,1,gpio,12,1 // turn on remote relay
  endif
endon
After lots debugging, the solution was to simply switch the order of commands:

Code: Select all

on switch#state do
  if [relay#state]=1
    sendto,1,gpio,12,0
    gpio,12,0
  else
    sendto,1,gpio,12,1
    gpio,12,1
  endif
endon

User avatar
Ath
Normal user
Posts: 3508
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Sonoff Relay, UDP SendTo, and Wifi interference

#2 Post by Ath » 09 Oct 2020, 07:41

Does this also happen when switching another gpio? For example gpio 2, instead of 12.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8748
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Sonoff Relay, UDP SendTo, and Wifi interference

#3 Post by TD-er » 09 Oct 2020, 09:03

To me it looks like the extra power drawn from the relay may make the WiFi a bit unstable.

Can you at least also try with enabling sending Gratuitous ARP to see if it changes behavior?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 39 guests