Random relay switching - please check my config

hey guys,
ive set up my esp32 board to do quite a lot (?) of things - measure temp, ultrasonic sensor, 4 relay switch board and 3 buttons. so the sensors are working fine, but im having problems with random relay switch tiggered by button that is not even touched at all (even changed). please, could you check my config?

im not using any physical resistors, just enabled pulldown in config.

switches were connected to GND + GPIO and then later changed to 3v3 + GPIO.
relays are connected to 5V + GND. tried them with 3v3 but made no difference.
sensors are 5v and works fine.

please - if youve got any ideas - please comment below :slight_smile:

Thank you!

esphome:
  name: garaz_barak_esp32
  platform: ESP32
  board: esp-wrover-kit

wifi:
  ssid: "wifi"
  password: "pass"
  reboot_timeout: 0s
  manual_ip:
    static_ip: 192.168.1.119
    gateway: 192.168.1.1
    subnet: 255.255.255.0  
# Enable logging
logger:

# Enable Home Assistant API
api:
 reboot_timeout: 0s

sun:
  latitude: 50.6
  longitude: 17.8

# At least one time source is required
time:
  - platform: homeassistant
  
  
ota:


switch:
  - platform: gpio
    name: "wolny_relay"
    pin: 
      number: GPIO27

    id: wolny_relay
    inverted: yes
    restore_mode: RESTORE_DEFAULT_OFF 

    
  - platform: gpio
    name: "gniazdo_lewe"
    pin: 
      number: GPIO26
  
    id: gniazdo_lewe
    inverted: yes
    restore_mode: RESTORE_DEFAULT_OFF 

  - platform: gpio
    name: "gniazdo_prawe"
    pin: 
      number: GPIO33
  
    id: gniazdo_prawe
    inverted: yes
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    name: "garaz_swiatlo"
    pin: 
      number: GPIO25
    id: swiatlo
    inverted: yes
    restore_mode: RESTORE_DEFAULT_OFF  
    
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO15
      mode: INPUT_PULLDOWN
    name: "GUZIK"
    on_press:
      then:
      - switch.toggle: swiatlo

     
  - platform: gpio
    pin:
      number: 22
      mode: INPUT_PULLDOWN 
      inverted: true
    name: "drzwi_garaz"
    device_class: garage_door
    on_press:
    - if:
         condition:
          - sun.is_below_horizon:
         then:
           - switch.turn_on: swiatlo
           - delay: 180s  
           - switch.turn_off: swiatlo
    on_release:
      then:
      - switch.turn_off: swiatlo


  - platform: gpio
    pin:
      number: GPIO34
      mode: INPUT_PULLDOWN 
      inverted: true
    name: "szopa_drzwi"
    device_class: door



        
sensor:



  - platform: ultrasonic
    trigger_pin: 19
    echo_pin: 21
    name: "garaz_ultrasonic_sensor"
    update_interval: 5s
    pulse_time: 2s
    filters:
      - filter_out: nan

  - platform: dht
    model: DHT22
    pin: GPIO23
    temperature:
      name: "Garage Temperature"
    humidity:
      name: "Garage Humidity"
    update_interval: 60s


Which one triggers randomly?

Relay gpio25 gets triggers by binary_sensor GPIO22.

So button on binary sensor gpio25 randomly goes on and then off.

Thank you

And what do your esphome logs tell you when this occurs?

Log shows that the button got pressed and released instantly, which triggers relay at gpio25 on and then off. The button physically isn’t touched.
I’ll try to catch piece of log and paste it here.

Thank you

OK. What device is actually connected to gpio22? Is there a loose wire or something? Something shorting the pins?

That’s what I thought, but no, there’s no lose wires or faulty buttons. There was reed switch originally which I then replaced with just simple push button and connected with different set of short wires but random switching still occurs.

I’ll try to grab the log today and post it here.

Thank you

Where are those logs?

I know I can watch the logs live by going to the device in the dashboard and clicking “show logs” but are those logs actually stored anywhere to view later?

I’ve looked around and i don’t see any maintained log files.

There are a number of articles out there on preventing false triggers. A pullup resistor or a bypass capacitor are often mentioned. Give either or both a try.

esphome livingroom.yaml logs > livingroom.log

thanks

It looks like you need to start the logging and continue to log for a while to see what’s going on instead of an automatic log being generated continuously like HA does. Is that correct?

Well you need to log until the problem appears, like any logging.

I understand that but my point was that it will only log while you tell it to and not continuously in the way that HA does.

Thanks again. I didn’t know how to start logging. That would come in handy for some of the relay chattering I’ve had on some sonoffs recently.