Relay trigger when startup or reset

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Ventran
Posts: 16
Joined: Sun Jun 21, 2020 4:28 pm

Relay trigger when startup or reset

Post by Ventran » Sat Oct 17, 2020 6:26 pm

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()

User avatar
pythoncoder
Posts: 4575
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Relay trigger when startup or reset

Post by pythoncoder » Sun Oct 18, 2020 1:56 pm

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.
Peter Hinch

User avatar
Roberthh
Posts: 2177
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Relay trigger when startup or reset

Post by Roberthh » Sun Oct 18, 2020 5:20 pm

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.

User avatar
pythoncoder
Posts: 4575
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Relay trigger when startup or reset

Post by pythoncoder » Mon Oct 19, 2020 6:22 am

Good point.

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

User avatar
Roberthh
Posts: 2177
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Relay trigger when startup or reset

Post by Roberthh » Mon Oct 19, 2020 6:39 am

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.

Ventran
Posts: 16
Joined: Sun Jun 21, 2020 4:28 pm

Re: Relay trigger when startup or reset

Post by Ventran » Mon Oct 19, 2020 6:48 pm

This is my design board. Here is a schematic:
  • One of six channel
channel.PNG
channel.PNG (77.83 KiB) Viewed 155 times
  • ESP8266
mcu.PNG
mcu.PNG (78.06 KiB) Viewed 155 times
  • Power Supply Unit
psu.PNG
psu.PNG (58.07 KiB) Viewed 155 times

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

User avatar
Roberthh
Posts: 2177
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Relay trigger when startup or reset

Post by Roberthh » Mon Oct 19, 2020 7:12 pm

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?

User avatar
Roberthh
Posts: 2177
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Relay trigger when startup or reset

Post by Roberthh » Mon Oct 19, 2020 8:12 pm

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.
Attachments
esp8266_boot_gpio0_2.png
esp8266_boot_gpio0_2.png (72.48 KiB) Viewed 115 times
esp8266_boot_gpio0_2_zoom.png
esp8266_boot_gpio0_2_zoom.png (56.23 KiB) Viewed 115 times

User avatar
pythoncoder
Posts: 4575
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Relay trigger when startup or reset

Post by pythoncoder » Tue Oct 20, 2020 5:15 am

Very interesting, great work you two. Now logged in my "ESPx weirdness" database. ;)
Peter Hinch

User avatar
Roberthh
Posts: 2177
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Relay trigger when startup or reset

Post by Roberthh » Tue Oct 20, 2020 7:16 am

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.

Post Reply