Setup: ESP32 NodeMCU, with ESPHome 2022.2.4 installed. GPIO 33 connected to Wemos D1 relay shield. Active High, attached to NO. This is to open a door on HA command.
The same setup on a ESP8266 worked perfectly. I had to expand this project to more sensors, including bluetooth, so opted for ESP32.
On ESP32, at boot or reset, the GPIO pin is going high, then low. This activates the relay, so opens the door (this becomes a security issue)
Initial code used switch platform GPIO, set on pin 32. I tried changing this to an output switch.
Tried GPIO 33 as well
Placed a pulldown resistor 4k7 between relay pin and ground.
changed ALWAYS_OFF to restore_DEFAULT_OFF
tried inverting pins to get an inverse logic
Tried a button script rather than switch
The only thing that worked was setting a different GPIO in the code, but keeping the physical connection. That is, soldering input to GPIO 33, but using GPIO 32 in code. At that point, nothing happens on boot, but of course, this is useless, as I cannot activate the relay any more.
It seems that at boot, GPIO outputs that are set up in ESPhome toggle on & off.
Help welcome, as now I have to take everything down again.
It would seem that the SWITCH or BUTTON component are activated once at boot. Is there a way to stop this?
I have commented out the line: output.turn_off: doorrelay
This causes the relay to activate at boot, and remain on. This would mean to me that rather than an issue with the GPIO startup, it is the button / switch component that are triggered for no reason at boot.
this means whenever restart ESP, all IO pins are going to high after booting, add pull-down resistor
I.e add 10k resistor on IO pin to ground, I think it will be solved.