Page 1 of 2

Relay trigger when startup or reset

Posted: Sat Oct 17, 2020 6:26 pm
by Ventran
Hello,
I have a problem with my device. The construcion have a six relays conected to ESP8266-12F module. When plug-in connector to 230V Socket and device start-up I see and heare spike on GPIO (especialy IO0 and IO2).

Below I attached short video. This short movie show what is wrong with GPIO when system reset or boot.
Image

  • boot.py

Code: Select all

import uos, machine
import gc
gc.collect()

Re: Relay trigger when startup or reset

Posted: Sun Oct 18, 2020 1:56 pm
by pythoncoder
Your problem is probably one of electronic design. It appears not to be deterministic which suggests you are getting a spike on power up which is getting through to the chips driving the relays. Is the board of your design? If not do you have schematics? What sort of power supply are you using? If you have access to an oscilloscope you could check for voltage spikes.

It's hard to recommend a solution without a good deal more detail, both of the design and the waveforms which are occurring.

Re: Relay trigger when startup or reset

Posted: Sun Oct 18, 2020 5:20 pm
by Roberthh
GPIO0 and GPIO2 are so called strapping pins. For a normal boot, their level has to be high at boot time. For that purpose, The ESP8266 have internal weak pull-up resistors. I guess that you code sets these GPIO ports to 0 when it starts and to 1 to activate a relay. So it's this short '1' event that you might notice at boot time.
There is little you can do about it, except inverting the level to activate the relay, e.g. with a single transistor inverter, such the the relay is switched on with a '0' signal and silent with a 1.

Re: Relay trigger when startup or reset

Posted: Mon Oct 19, 2020 6:22 am
by pythoncoder
Good point.

The only puzzlement is that the video shows nondeterministic behaviour: in one instance all relays are activated, in another only two.

Re: Relay trigger when startup or reset

Posted: Mon Oct 19, 2020 6:39 am
by Roberthh
We had questions about the relay boards a fee times in the forum. And most of the time it was a problem of these board's design, e.g. made for 5V with a pnp transistor for switching.

Re: Relay trigger when startup or reset

Posted: Mon Oct 19, 2020 6:48 pm
by Ventran
This is my design board. Here is a schematic:
  • One of six channel
channel.PNG
channel.PNG (77.83 KiB) Viewed 3858 times
  • ESP8266
mcu.PNG
mcu.PNG (78.06 KiB) Viewed 3858 times
  • Power Supply Unit
psu.PNG
psu.PNG (58.07 KiB) Viewed 3858 times

Oscilloscope Waveform:
State High on pin = Relay Turn-Off.
  • GPIO0 and GPIO2 Spike when boot
SDS00001.png
SDS00001.png (8.79 KiB) Viewed 3858 times
  • GPIO13 without spike
Image

Re: Relay trigger when startup or reset

Posted: Mon Oct 19, 2020 7:12 pm
by Roberthh
Thanks for the detailed information. The board design looks excellent. The problem seems to be the short low pulse at GPIO0 and the burst at GPIO2. The sawtooth part on GPIO looks like a floating input at mains frequency. I have no clue where short GPIO0 pulse comes from. Can you indicate at which time you code starts?

Re: Relay trigger when startup or reset

Posted: Mon Oct 19, 2020 8:12 pm
by Roberthh
I started up my scope and an WESP8266 to look at the signals. The pattern at GPIO2 is a debug message at 74880 baud. The pattern on GPIO0 is a ~25MHz burst. Screen shots attached at various zoom levels. That all happens before Micropython gets control. So there is little you can do except for instance gate off GPIO0 and GPIO2 until the signals are stable, or apply power to your board at that time.

Re: Relay trigger when startup or reset

Posted: Tue Oct 20, 2020 5:15 am
by pythoncoder
Very interesting, great work you two. Now logged in my "ESPx weirdness" database. ;)

Re: Relay trigger when startup or reset

Posted: Tue Oct 20, 2020 7:16 am
by Roberthh
Looking at he GPIO0 burst with a 100ns timebase, it turns out as the 26MHz clock signal. Interesting that this is at GPIO0 during boot. I have re-loaded the Pic above without the 20MHz bandwidth limiting at the GPIO0 signal. I normally use the 20 MHz bandwidth limit on the logical signals so I do not have that ringing visible cause by the long probe tip and GND cable.