ESP32 WROOM module inverts GPIO13 when GPIO33 is toggled on

Hi Folks,

image

Fan Speed is setup through input boolean which triggers automation which in turn triggers a script that toggles GPIO pin33 to “on” state
But strangely when I toggle from Low to Medium Speed and the ceiling switch is “on” not only medium speed switch goes “off” but also the ceiling switch goes “off”.

Obviously interlock is not enabled but in some of the ESP32 datasheets, I have seen them talk about pin 32 & 33 are tied to RTC function and special code needed to make them work as normal GPIO if not they go crazy.

So do I need to put in any special lambda functions in esphome or am I missing something? Any help is much appreciated.

Regards
Anil Verma

First you should always supply your yaml config. Second your esp logs from when the the switches turn off. Turn the log level to VERY_VERBOSE Also the actual unit you are using could be helpful

yes, you are right sorry for not thinking about this before. Here is the config file…

esphome:
  name: hoesp32v4
  platform: ESP32
  board: esp32dev

# Enable logging
logger:
  level: VERY_VERBOSE

# Enable Home Assistant API
# api:

mqtt:
  broker: 192.168.1.30
  port: 1883
  username: mqttuser
  password: *********

ota:
  password: "*************"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  
  power_save_mode: NONE
  fast_connect: true
  reboot_timeout: 45min

  # Optional manual IP
  manual_ip:
    static_ip: 192.168.1.36
    gateway: 192.168.1.1
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Hoesp32V4 Fallback Hotspot"
    password: "*************"

captive_portal:

switch:
  - platform: gpio
    pin: 32
    inverted: no
    name: "1u"
    restore_mode: ALWAYS_OFF
  - platform: gpio
    pin: 33
    inverted: no
    name: "2u"
    restore_mode: ALWAYS_OFF
  - platform: gpio
    pin: 25
    inverted: no
    name: "3u"
    restore_mode: ALWAYS_OFF
  - platform: gpio
    pin: 26
    inverted: no
    name: "fu"
    restore_mode: ALWAYS_OFF
  - platform: gpio
    pin: 27
    inverted: yes
    name: "hosoc"
    restore_mode: ALWAYS_ON
  - platform: gpio
    pin: 14
    inverted: yes
    name: "hoac"
    restore_mode: ALWAYS_ON
  - platform: gpio
    pin: 12
    inverted: no
    name: "holight"
    restore_mode: ALWAYS_OFF
  - platform: gpio
    pin: 13
    inverted: no
    name: "holc1"
    restore_mode: ALWAYS_OFF

here are the logs, first switched on “holc1” which is the ceiling light then I switch on “1u” which is a fan at low speed, then I toggle to “2u” which is medium speed. This is when everything goes off, Looks like the MCU has reset. Same result when I toggle the fan speed switches manually instead of the automation.

[19:37:22][D][switch:013]: 'holc1' Turning ON.
[19:37:22][D][switch:037]: 'holc1': Sending state ON
[19:37:22][VV][scheduler:026]: set_timeout(name='send', timeout=0)
[19:37:22][VV][scheduler:185]: Running timeout 'send' with interval=0 last_execution=27204 (now=27217)
[19:37:22][V][mqtt:404]: Publish(topic='hoesp32v4/switch/holc1/state' payload='ON' retain=1)
[19:37:24][D][switch:017]: 'fu' Turning OFF.
[19:37:24][D][switch:017]: '3u' Turning OFF.
[19:37:25][D][switch:017]: '2u' Turning OFF.
[19:37:25][D][switch:013]: '1u' Turning ON.
[19:37:25][D][switch:037]: '1u': Sending state ON
[19:37:25][VV][scheduler:026]: set_timeout(name='send', timeout=0)
[19:37:25][VV][scheduler:185]: Running timeout 'send' with interval=0 last_execution=29852 (now=29867)
[19:37:25][V][mqtt:404]: Publish(topic='hoesp32v4/switch/1u/state' payload='ON' retain=1)
[19:37:30][VV][scheduler:185]: Running interval '' with interval=60000 last_execution=4294941655 (now=34362)
[19:37:36][D][switch:017]: 'fu' Turning OFF.
[19:37:37][D][switch:017]: '3u' Turning OFF.
[19:37:37][D][switch:017]: '1u' Turning OFF.
[19:37:41][I][mqtt:214]: MQTT Connected!
[19:37:41][V][mqtt:309]: subscribe(topic='hoesp32v4/switch/1u/command')
[19:37:41][V][mqtt.component:062]: '1u': Sending discovery...
[19:37:41][V][mqtt:404]: Publish(topic='homeassistant/switch/hoesp32v4/1u/config' payload='{"name":"1u","stat_t":"hoesp32v4/switch/1u/state","cmd_t":"hoesp32v4/switch/1u/command","avty_t":"hoesp32v4/status","uniq_id":"ESPswitch1u","dev":{"ids":"943cc611cd94","name":"hoesp32v4","sw":"esphome v2021.12.1 Dec 30 2021, 19:28:56","mdl":"esp32dev","mf":"espressif"}}' retain=1)
[19:37:41][V][mqtt:404]: Publish(topic='hoesp32v4/switch/1u/state' payload='OFF' retain=1)
[19:37:41][V][mqtt:309]: subscribe(topic='hoesp32v4/switch/2u/command')
[19:37:41][V][mqtt.component:062]: '2u': Sending discovery...
[19:37:42][V][mqtt:404]: Publish(topic='homeassistant/switch/hoesp32v4/2u/config' payload='{"name":"2u","stat_t":"hoesp32v4/switch/2u/state","cmd_t":"hoesp32v4/switch/2u/command","avty_t":"hoesp32v4/status","uniq_id":"ESPswitch2u","dev":{"ids":"943cc611cd94","name":"hoesp32v4","sw":"esphome v2021.12.1 Dec 30 2021, 19:28:56","mdl":"esp32dev","mf":"espressif"}}' retain=1)
[19:37:42][V][mqtt:404]: Publish(topic='hoesp32v4/switch/2u/state' payload='OFF' retain=1)
[19:37:42][V][mqtt:309]: subscribe(topic='hoesp32v4/switch/3u/command')
[19:37:42][V][mqtt.component:062]: '3u': Sending discovery...
[19:37:42][V][mqtt:404]: Publish(topic='homeassistant/switch/hoesp32v4/3u/config' payload='{"name":"3u","stat_t":"hoesp32v4/switch/3u/state","cmd_t":"hoesp32v4/switch/3u/command","avty_t":"hoesp32v4/status","uniq_id":"ESPswitch3u","dev":{"ids":"943cc611cd94","name":"hoesp32v4","sw":"esphome v2021.12.1 Dec 30 2021, 19:28:56","mdl":"esp32dev","mf":"espressif"}}' retain=1)
[19:37:42][V][mqtt:404]: Publish(topic='hoesp32v4/switch/3u/state' payload='OFF' retain=1)
[19:37:42][V][mqtt:309]: subscribe(topic='hoesp32v4/switch/fu/command')
[19:37:42][V][mqtt.component:062]: 'fu': Sending discovery...
[19:37:42][V][mqtt:404]: Publish(topic='homeassistant/switch/hoesp32v4/fu/config' payload='{"name":"fu","stat_t":"hoesp32v4/switch/fu/state","cmd_t":"hoesp32v4/switch/fu/command","avty_t":"hoesp32v4/status","uniq_id":"ESPswitchfu","dev":{"ids":"943cc611cd94","name":"hoesp32v4","sw":"esphome v2021.12.1 Dec 30 2021, 19:28:56","mdl":"esp32dev","mf":"espressif"}}' retain=1)
[19:37:42][V][mqtt:404]: Publish(topic='hoesp32v4/switch/fu/state' payload='OFF' retain=1)
[19:37:42][V][mqtt:309]: subscribe(topic='hoesp32v4/switch/hosoc/command')
[19:37:42][V][mqtt.component:062]: 'hosoc': Sending discovery...
[19:37:42][V][mqtt:404]: Publish(topic='homeassistant/switch/hoesp32v4/hosoc/config' payload='{"name":"hosoc","stat_t":"hoesp32v4/switch/hosoc/state","cmd_t":"hoesp32v4/switch/hosoc/command","avty_t":"hoesp32v4/status","uniq_id":"ESPswitchhosoc","dev":{"ids":"943cc611cd94","name":"hoesp32v4","sw":"esphome v2021.12.1 Dec 30 2021, 19:28:56","mdl":"esp32dev","mf":"espressif"}}' retain=1)
[19:37:42][V][mqtt:404]: Publish(topic='hoesp32v4/switch/hosoc/state' payload='ON' retain=1)
[19:37:42][V][mqtt:309]: subscribe(topic='hoesp32v4/switch/hoac/command')
[19:37:42][V][mqtt.component:062]: 'hoac': Sending discovery...
[19:37:42][V][mqtt:404]: Publish(topic='homeassistant/switch/hoesp32v4/hoac/config' payload='{"name":"hoac","stat_t":"hoesp32v4/switch/hoac/state","cmd_t":"hoesp32v4/switch/hoac/command","avty_t":"hoesp32v4/status","uniq_id":"ESPswitchhoac","dev":{"ids":"943cc611cd94","name":"hoesp32v4","sw":"esphome v2021.12.1 Dec 30 2021, 19:28:56","mdl":"esp32dev","mf":"espressif"}}' retain=1)
[19:37:42][V][mqtt:404]: Publish(topic='hoesp32v4/switch/hoac/state' payload='ON' retain=1)
[19:37:42][V][mqtt:309]: subscribe(topic='hoesp32v4/switch/holight/command')
[19:37:42][V][mqtt.component:062]: 'holight': Sending discovery...
[19:37:42][V][mqtt:404]: Publish(topic='homeassistant/switch/hoesp32v4/holight/config' payload='{"name":"holight","stat_t":"hoesp32v4/switch/holight/state","cmd_t":"hoesp32v4/switch/holight/command","avty_t":"hoesp32v4/status","uniq_id":"ESPswitchholight","dev":{"ids":"943cc611cd94","name":"hoesp32v4","sw":"esphome v2021.12.1 Dec 30 2021, 19:28:56","mdl":"esp32dev","mf":"espressif"}}' retain=1)
[19:37:42][V][mqtt:404]: Publish(topic='hoesp32v4/switch/holight/state' payload='OFF' retain=1)
[19:37:42][V][mqtt:309]: subscribe(topic='hoesp32v4/switch/holc1/command')
[19:37:42][V][mqtt.component:062]: 'holc1': Sending discovery...
[19:37:42][V][mqtt:404]: Publish(topic='homeassistant/switch/hoesp32v4/holc1/config' payload='{"name":"holc1","stat_t":"hoesp32v4/switch/holc1/state","cmd_t":"hoesp32v4/switch/holc1/command","avty_t":"hoesp32v4/status","uniq_id":"ESPswitchholc1","dev":{"ids":"943cc611cd94","name":"hoesp32v4","sw":"esphome v2021.12.1 Dec 30 2021, 19:28:56","mdl":"esp32dev","mf":"espressif"}}' retain=1)
[19:37:42][V][mqtt:404]: Publish(topic='hoesp32v4/switch/holc1/state' payload='OFF' retain=1)
[19:37:42][I][app:062]: setup() finished successfully!
[19:37:42][V][mqtt:404]: Publish(topic='hoesp32v4/status' payload='online' retain=1)
[19:37:42][I][app:102]: ESPHome version 2021.12.1 compiled on Dec 30 2021, 19:28:56
[19:37:42][C][wifi:488]: WiFi:
[19:37:42][C][wifi:350]:   Local MAC: 94:3C:C6:11:CD:94
[19:37:42][C][wifi:351]:   SSID: 'ANILHOME2'
[19:37:42][C][wifi:352]:   IP Address: 192.168.1.36
[19:37:42][C][wifi:354]:   BSSID: E8:48:B8:13:0E:EB
[19:37:42][C][wifi:355]:   Hostname: 'hoesp32v4'
[19:37:42][C][wifi:361]:   Channel: 4
[19:37:42][C][wifi:362]:   Subnet: 255.255.255.0
[19:37:42][C][wifi:363]:   Gateway: 192.168.1.1
[19:37:42][C][wifi:364]:   DNS1: 0.0.0.0
[19:37:42][C][wifi:365]:   DNS2: 0.0.0.0
[19:37:42][C][logger:233]: Logger:
[19:37:42][C][logger:234]:   Level: VERY_VERBOSE
[19:37:42][C][logger:235]:   Log Baud Rate: 115200
[19:37:42][C][logger:236]:   Hardware UART: UART0
[19:37:42][C][switch.gpio:048]: GPIO Switch '1u'
[19:37:42][C][switch.gpio:049]:   Pin: GPIO32
[19:37:42][C][switch.gpio:071]:   Restore Mode: Always OFF
[19:37:42][C][switch.gpio:048]: GPIO Switch '2u'
[19:37:42][C][switch.gpio:049]:   Pin: GPIO33
[19:37:42][C][switch.gpio:071]:   Restore Mode: Always OFF
[19:37:42][C][switch.gpio:048]: GPIO Switch '3u'
[19:37:42][C][switch.gpio:049]:   Pin: GPIO25
[19:37:42][C][switch.gpio:071]:   Restore Mode: Always OFF
[19:37:42][C][switch.gpio:048]: GPIO Switch 'fu'
[19:37:42][C][switch.gpio:049]:   Pin: GPIO26
[19:37:42][C][switch.gpio:071]:   Restore Mode: Always OFF
[19:37:42][C][switch.gpio:048]: GPIO Switch 'hosoc'
[19:37:42][C][switch.gpio:048]:   Inverted: YES
[19:37:42][C][switch.gpio:049]:   Pin: GPIO27
[19:37:42][C][switch.gpio:071]:   Restore Mode: Always ON
[19:37:42][C][switch.gpio:048]: GPIO Switch 'hoac'
[19:37:42][C][switch.gpio:048]:   Inverted: YES
[19:37:42][C][switch.gpio:049]:   Pin: GPIO14
[19:37:42][C][switch.gpio:071]:   Restore Mode: Always ON
[19:37:42][C][switch.gpio:048]: GPIO Switch 'holight'
[19:37:42][C][switch.gpio:049]:   Pin: GPIO12
[19:37:42][C][switch.gpio:071]:   Restore Mode: Always OFF
[19:37:42][C][switch.gpio:048]: GPIO Switch 'holc1'
[19:37:42][C][switch.gpio:049]:   Pin: GPIO13
[19:37:42][C][switch.gpio:071]:   Restore Mode: Always OFF
[19:37:42][C][captive_portal:144]: Captive Portal:
[19:37:42][C][ota:082]: Over-The-Air Updates:
[19:37:42][C][ota:083]:   Address: 192.168.1.36:3232
[19:37:42][C][ota:086]:   Using Password.
[19:37:42][W][ota:092]: Last Boot was an unhandled reset, will proceed to safe mode in 6 restarts
[19:37:42][C][mqtt:063]: MQTT:
[19:37:42][C][mqtt:065]:   Server Address: 192.168.1.30:1883 (192.168.1.30)
[19:37:42][C][mqtt:066]:   Username: 'mqttuser'
[19:37:42][C][mqtt:067]:   Client ID: 'hoesp32v4-943cc611cd94'
[19:37:42][C][mqtt:069]:   Discovery prefix: 'homeassistant'
[19:37:42][C][mqtt:070]:   Discovery retain: YES
[19:37:42][C][mqtt:072]:   Topic Prefix: 'hoesp32v4'
[19:37:42][C][mqtt:074]:   Log Topic: 'hoesp32v4/debug'
[19:37:42][C][mqtt:077]:   Availability: 'hoesp32v4/status'
[19:37:42][C][mdns:084]: mDNS:
[19:37:42][C][mdns:085]:   Hostname: hoesp32v4
[19:37:42][V][mdns:086]:   Services:
[19:37:42][V][mdns:088]:   - _http, _tcp, 80
[19:37:42][V][mdns:090]:     TXT: version = 2021.12.1
[19:37:42][C][mqtt.switch:041]: MQTT Switch '1u':
[19:37:42][C][mqtt.switch:042]:   State Topic: 'hoesp32v4/switch/1u/state'
[19:37:42][C][mqtt.switch:042]:   Command Topic: 'hoesp32v4/switch/1u/command'
[19:37:42][C][mqtt.switch:041]: MQTT Switch '2u':
[19:37:42][C][mqtt.switch:042]:   State Topic: 'hoesp32v4/switch/2u/state'
[19:37:42][C][mqtt.switch:042]:   Command Topic: 'hoesp32v4/switch/2u/command'
[19:37:42][C][mqtt.switch:041]: MQTT Switch '3u':
[19:37:42][C][mqtt.switch:042]:   State Topic: 'hoesp32v4/switch/3u/state'
[19:37:42][C][mqtt.switch:042]:   Command Topic: 'hoesp32v4/switch/3u/command'
[19:37:42][C][mqtt.switch:041]: MQTT Switch 'fu':
[19:37:42][C][mqtt.switch:042]:   State Topic: 'hoesp32v4/switch/fu/state'
[19:37:42][C][mqtt.switch:042]:   Command Topic: 'hoesp32v4/switch/fu/command'
[19:37:42][C][mqtt.switch:041]: MQTT Switch 'hosoc':
[19:37:42][C][mqtt.switch:042]:   State Topic: 'hoesp32v4/switch/hosoc/state'
[19:37:42][C][mqtt.switch:042]:   Command Topic: 'hoesp32v4/switch/hosoc/command'
[19:37:42][C][mqtt.switch:041]: MQTT Switch 'hoac':
[19:37:42][C][mqtt.switch:042]:   State Topic: 'hoesp32v4/switch/hoac/state'