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)
# Relay pin switch: - platform: output id: doorrelay #pin: GPIO32 output: doorPIN name: "Door relay" restore_mode: ALWAYS_OFF icon: "mdi:gate" on_turn_on: #- output.turn_on: doorPIN - output.turn_on: doorrelayLED - delay: 500ms #- output.turn_off: doorPIN - switch.turn_off: doorrelay - output.turn_off: doorrelayLED - homeassistant.service: service: notify.mobile_app_stefe_iphone data: title: "Button was pressed" message: "opening door" # Relay pin output: - platform: gpio pin: GPIO02 id: doorrelayLED inverted: true - platform: gpio pin: GPIO33 id: doorPIN
I have tried the following, with no success
- 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.