Relay Board Weird Situation

Hello,

I have a nodemcu running ESPHome, and everything is working fine, except when I tried to add an extra relay board port. I have a sainsmart 4 port relay board and up until now had been using only 2 ports.

So I wired the additional port into GPIO port D5 and added it into the ESPHome config. Everything compiled and pushed to the nodemcu with no issues. But…the relay doesn’t fire? The relays connected to D3 and D8 work fine, so I dont know why the relay connected to D5 doesn’t work?

ESPHome config part covering relays…

switch:
  - platform: gpio
    pin: 
      number: D3
      inverted: True
    name: "hvac_damper"
    restore_mode: RESTORE_DEFAULT_OFF
    
  - platform: gpio
    pin: 
      number: D8
      inverted: True
    name: "hvac_fan"
    restore_mode: RESTORE_DEFAULT_OFF

  - platform: gpio
    pin: 
      number: D5
      inverted: True
    name: "chassis_fan"
    restore_mode: RESTORE_DEFAULT_OFF

Any other info I should supply here let me know… I have never come across this issue before, and never had a sensor or relay not work.

Thanks, Mark

Double check your wiring.

Is it signalling properly? Use a multimeter.

Hi Nick,

I tried multiple GPIO ports for the relay pin, and connected a working GPIO port to the relay pin that wasn’t working, all worked as expected. Not sure why the GPIO port is not being triggered? Perhaps ESPHome is not receiving the signal from HA… which is weird for just one of the relay ports.

Edit: Wired the relay port into a known good GPIO port, and it didn’t work. Replaced the cable between the GPIO port and relay board pin, no good. Removed and re-added the switch in HA, and even renamed the switch name in ESPHome config and HA, no good.

Very strange.

Thanks, Mark

Perhaps the relay is stuck.
Give it a few taps with something like the handle of a screwdriver from all sides.

Yeah hit it with a bigger hammer :slight_smile:

Have you looked at whether the GPIO changes with a multimeter?

I have proven the electrical/relay is not the issue, here’s my logic…

The ‘hvac_fan’ relay is on GPIO 14 or D5 and is connected to relay port 1 - it works. If I move the wire to relay pin 3 - it works, so the relay is not at fault.

Here’s the yaml code from HA…

type: entities
entities:
  - entity: switch.hvac_fan
  - entity: switch.hvac_damper
  - entity: switch.rack_fan
title: Studio

Here’s the ESPHome relay code…

switch:
  - platform: gpio
    pin: 
      number: 12
      inverted: True
    name: "hvac_damper"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 14
      inverted: True
    name: "hvac_fan"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 13
      inverted: True
    name: "rack_fan"
    restore_mode: RESTORE_DEFAULT_OFF

So in the above ESPHome setup the relays on GPIO 12 and 14 work. And the relay on GPIO 13 doesn’t work.

If I change the code to below…

switch:
  - platform: gpio
    pin: 
      number: 12
      inverted: True
    name: "hvac_damper"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 13
      inverted: True
    name: "hvac_fan"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 14
      inverted: True
    name: "rack_fan"
    restore_mode: RESTORE_DEFAULT_OFF

Then the ‘rack_fan’ relay works, but the ‘hvac_fan’ stops working.

If I then move the wire from GPIO 13 to GPIO5 (which previously had the temperature sensor successfully working) the relay doesn’t work for that port. Yet if I put the dallas sensor on GPIO13 it works. See below…

status_led:
  pin: GPIO2

switch:
  - platform: gpio
    pin: 
      number: 12
      inverted: True
    name: "hvac_damper"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 5
      inverted: True
    name: "hvac_fan"
    restore_mode: RESTORE_DEFAULT_OFF
  - platform: gpio
    pin: 
      number: 14
      inverted: True
    name: "rack_fan"
    restore_mode: RESTORE_DEFAULT_OFF

dallas:
  - pin: 13

So not really sure why this doesn’t work?

Checked with a multimeter… the pins that are working are showing 3.3 volts when not activated, and the pin not working shows 2.95 volts when not activated. When activated the 3.3 volt pins drop to 0.58 volts. And the pin not working, when activated it drops to almost zero volts.

Solved… pulled the relay board and checked/re-soldered a number of joints, and found a dry contact joint on relay board. Apology for wasting everyone’s time.

1 Like