During boot relay go high

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
sprinkfitter
Posts: 36
Joined: Wed Sep 27, 2017 1:42 pm
Location: Louisville Ky

During boot relay go high

Post by sprinkfitter » Thu Mar 21, 2019 7:43 pm

When I reboot my esp32 both relay pins goes high and turns on. (Not Good)
Program works find but the boot is a big problem. I have tried to pull pins high and low. Does not seem to work. Anyone have this problem and knows how to fix.. Thanks

Code: Select all

import machine
from machine import Pin
import time

relay1 = Pin(14, Pin.OUT, machine.Pin.PULL_DOWN)
relay2 = Pin(13, Pin.OUT, machine.Pin.PULL_DOWN)
#relay3 = Pin(12, Pin.OUT, machine.Pin.PULL_DOWN)
#relay4 = Pin(15, Pin.OUT, machine.Pin.PULL_DOWN)

while True:
    relay1.value(0)  # to switch it off
    time.sleep(2)
    relay1.value(1)  # to switch it on
    time.sleep(2)

    relay2.value(0)  # to switch it off
    time.sleep(3)
    relay2.value(1)  # to switch it on
    time.sleep(2)

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

Re: During boot relay go high

Post by Roberthh » Thu Mar 21, 2019 8:03 pm

Did you try to add an external pull-down resistor? After reset the a GPIO pin is usually floating and/or set to input at high impedance. If you relay switches on in that state, the external resistor will keep it off..

sprinkfitter
Posts: 36
Joined: Wed Sep 27, 2017 1:42 pm
Location: Louisville Ky

Re: During boot relay go high

Post by sprinkfitter » Fri Mar 22, 2019 2:45 am

Thanks I will try that. Hope's ot works

sprinkfitter
Posts: 36
Joined: Wed Sep 27, 2017 1:42 pm
Location: Louisville Ky

Re: During boot relay go high

Post by sprinkfitter » Tue Mar 26, 2019 3:31 pm

I try the eternal resisters but no luck. Read some more on the esp32 and found out some pins go high on boot. Found some great info at https://espeasy.readthedocs.io/en/lates ... /GPIO.html.

Decided to switch pins and got the following to work great. Thanks for all the help :D :D :D

Code: Select all

import machine
from machine import Pin
import time

p32 = Pin(32, Pin.OUT)
p32.value(1)
p33 = Pin(33, Pin.OUT)
p33.value(1)
p25 = Pin(25, Pin.OUT)
p25.value(1)
p26 = Pin(26, Pin.OUT)
p26.value(1)

relay1 = Pin(32)
relay2 = Pin(33)
relay3 = Pin(25)
relay4 = Pin(26)



while True:
    relay1.value(0)  # to switch it off
    time.sleep(2)
    relay1.value(1)  # to switch it on
    time.sleep(2)

    relay2.value(0)  # to switch it off
    time.sleep(3)
    relay2.value(1)  # to switch it on
    time.sleep(2)

    relay3.value(0)  # to switch it off
    time.sleep(2)
    relay3.value(1)  # to switch it on
    time.sleep(1)
    
    relay4.value(0)  # to switch it off
    time.sleep(2)
    relay4.value(1)  # to switch it on
    time.sleep(1)

Post Reply