Nodemcu (ESP32) with 16ch Relay board lose communication

Hi Guys,

I hope someone can help me. I am getting trouble.
I would like to control my floorheating system with an esp with Relay board.

I am using a pin expander MCP23017 to handle this 16 channel relay board. I made some test and my first problem I can not get working on the same time all 16 channel. Just 14 channel, the other two replacing the MCP23017 randolmy goes forward to other channels but 14 pieces work. I need just 12 channel so this is not a big problem. But heart me why can I get woking all of them.

The second much bigger problem = The relay board working only if i don’t have any load on them. If just connect the one of them to the 220V, I don’t any connectiong more with the relay board. It switched off… Without load, it working and I can switch them for weeks. (I would like not install on my heating system if I know it not woring correctly, so I tested it now for weeks till last week, where I tried to test with two actuator) If I connect one and I give it a power, then switching off the relay board or the MCP23017.

I am using one AC/DC 5V 2,4A PSU for power der ESP/MCP/Relay board. I think not the power the problem.


esphome:
  name: futes-relay
  friendly_name: Futes_Relay

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxx"

ota:
  - platform: esphome
    password: "xxxxxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Futes-Relay Fallback Hotspot"
    password: "xxxxxx"

captive_portal:

web_server:
  port: 80

i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true

mcp23017:
  - id: 'mcp23017_hub'
    address: 0x20

# Individual outputs
switch:
  - platform: gpio
    name: "Nappali1"
    pin:
      mcp23xxx: mcp23017_hub
      # Use pin GPA0
      number: 0
      mode:
        output: true
      inverted: false
  - platform: gpio
    name: "Nappali2"
    pin:
      mcp23xxx: mcp23017_hub
      # Use pin GPA1
      number: 1
      mode:
        output: true
      inverted: false
.
.
.
  - platform: restart
    name: "Futes Restart"

one_wire:
  - platform: gpio
    pin: 13
    id: dallas_1
#  - platform: gpio
#    pin: 14
#    id: dallas_2

sensor:
  - platform: dallas_temp
    address: 0xd73c98e38125c828
    name: "Víz HVM bejövő"
    one_wire_id: dallas_1
  - platform: dallas_temp
    address: 0xe83c1404578afb28
    name: "Víz HVM elmenő"
    one_wire_id: dallas_1
  - platform: dallas_temp
    address: 0x820417207b7dff28
    name: "Garázs hőmérséklet"
    one_wire_id: dallas_1

text_sensor:
  - platform: wifi_info
    ip_address:
      name: ESP IP Address
    ssid:
      name: ESP Connected SSID
    mac_address:
      name: ESP Mac Wifi Address

Do you have any Idea what’s wrong? I think I made somewhere the mistake but I don’t know where… I made before more esp8266 with a single relayboard in my previous home and they worked like a chram. This is my first project mit a pin expander.

Thank you very much!

Hi

If your power supply is the little black box on the right on your picture, it’s clearly the source of most of your problems :wink: Replace it with a proper PSU and it should work lot better !

Vincèn

Blockquote I think not the power the problem.

Did you measure the voltage or the current?

Umm… shouldn’t you also have cables going into the Com terminals in your relays if you actually want it to switch stuff?

I tried now with an other psu which can 5V and 60A but I get a same thing. So this is 100% not a power issue.

Blockquote
Umm… shouldn’t you also have cables going into the Com terminals in your relays if you actually want it to switch stuff?

If I connet something to the relay (doesn’t matter COM and NC or COM and NO) then after switching the relay (where on the load) I lose the connection over the relay board and it switch off. I have to restart the esp. I checked now and the MCP is working forward, so the problem should be there somewhere the relay board.

This big metal plate you have everything screwed on to, did you shield the backside of your PCBs?
I mean it looks kind of dangerous and could very much be the issue.

All those relays are probably through hole soldered so they are in contact with the plate

They are on plastic holders and I have 8mm distance from the metalsheet. I tough that is the Problem but I tried( I gave under them the plasticshield) but nothing changed.

Now I find something strange… If I change the the mode: inverted true

  - platform: gpio
    name: "Nappali1"
    pin:
      mcp23xxx: mcp23017_hub
      # Use pin GPA0
      number: 0
      mode:
        output: true
      inverted: true

Then I can get work under load one relay output… but just only one, the last one. I can change the switch anytime and it working… If i connect the fuse without load on more relay channel, then if I switch get the same error as before.

I don’t understand why this working, and why just here. If the board is faulty can couse trouble but I cannot think every channel are “death” without that.It sould be a “user error” somewhere.

This shouldn’t be possible with optoisolated relay module. Are you switching AC or DC?

I am switching AC. The actuators working on 220V.

Now what happened: After I set the mode inverted true on each channel. It works a lil bit better… I can change the loaded channels but I have to wait 5s to switch in and if I have to wait other more then 10s then I can switch off them one by one… If I am faster I have to reset a board. I cannot change more channel on the same time just one. It will be important to my floor heating.

I have doubts that anything depends on the AC load connected or not.
But your relay board and MCP wiring is incorrect, you are mixing 5V and 3.3V like they were same to you.

Take all 5V connections out from the setup except relay board screw connector.Esp32 is 3.3V MCU!! So power MCP from 3.3V pin.


Also you need pullup resistors for the I2C lines.

Thank you very much! You made my day. It worked like a charm.

Good to hear :+1: