ESPHome 16 Channel Relay/Outlet Smart Power Plug

Hi there,

I am building a 16 Outlet Smart Power Plug built around ESPHome and the 16 Channel Relay Board. Here is where it’s got me. And I think this will work. What I am asking is do you think I should use other components power-wise? Any other thoughts?

BTW, I am using a 12V Relay board as this what I have. Next version will have a 5V Relay board, so it won’t need the buck converter, as I will change the power supply as well to be 220v to 5v.

This is the electronics hookup. I didn’t link all the pins, but you get the idea

This is how half of it actually looks like:

And this is the ESPHome code:

esphome:
  name: 16outlet
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "ssid"
  password: "password"
  fast_connect: true

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:


captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

# I2C basic config used for multiple sensors and IO Expanders
i2c:
  sda: D2
  scl: D1
  scan: True

# Configuration entry for MCP23017 I/O Expander
mcp23017:
  - id: 'mcp23017_hub'
    address: 0x20

switch:
# Individual outputs for MCP Relays
     
  - platform: gpio
    name: "Outlet 1"
    icon: mdi:electric-switch
    pin:
      mcp23017: mcp23017_hub
      # Use pin number 1
      number: 1
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: True
      
  - platform: gpio
    name: "Outlet 2"
    icon: mdi:electric-switch
    pin:
      mcp23017: mcp23017_hub
      # Use pin number 2
      number: 2
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: True

And so on for each output

So let me know what you think! :wink:

1 Like

What sort of load are you switching?

Your power supply should have a fuse and overload protection.

Hi Nickrout! Thank you for your input. I will definitely look into it.

I made it so I can switch on/off some external HDDs. Together they draw quite a bit. This is actually the reason why I am doing this smart power outlet. The idea is to only power the harddisks I am using in that moment.

I would say about 24Amps in total

24A for hard disks? Depending on where you live, that is more than 2640W / 5520W. Are you sure your figures are correct?
Make sure it is fused, overload and overheating protected !

24A 12V. Sorry I forgot to mention. That would mean about 288W.

It’s estimated based on what is written on the power adapters. There are about 15 harddrives. I will check with a measuring device once I get back home.

Then why does your diagram show AC going through the relay?

The relays control the HDD power adapters which convert 220v 0.3A to 12v 1.2A

Something like this: https://www.thomann.de/gr/t_rex_power_supply_12v_dc.htm (random search result)

OK so the answer is that you are switching 220 v up to 0.3A per channel.

Do you really want to do this to hard drives? You are not supposed to just switch them off.

If you switch them off from the pc/server/nas, they are not actually switched off completely. They still draw power. I want to resolve 2 problems. One is that they actually tend to eat a lot of current over time.
The second is that they tend to wear down over time.

So considering HA, whenever I want to use a hdd, I first power it via HA and ESPHome. And whenever I want to switch off, I first unmount it and then switch off the power supply. Of course all automated.

Nice idea @ygreq.
The wiring diagram above has a problem, you show the active and neutral of the AC supply across the normally closed relay terminals, this will short the AC supply as soon as power is applied.

Yeap. Sorry about that. I put the fritzing diagram in a hurry. I will correct it asap

1 Like

I changed the diagram to reflect your observation, Brad.
Thank you!

Nick, where should the fuse be? And how should I take care of protection to overload? Thank you!

Just two remarks:

  • If possible, I would always recommend to avoid 220V in DIY projects. In this case your consumers only require 12V DC, so why not use a single off-the-shelf transformer to get 12V for all consumers and then use relays to switch 12V DC for each consumer?
  • It would be interesting to see if in the long term if turning the hard-drives on and off all the time wears them out faster (shorter lifespan) vs. keep them all powered and just mount/unmount them but at the cost of idle power.
2 Likes

Thank you for your thoughtful remarks!

I understand the problems that come with high voltage power and diy projects. And indeed they should be well considered. Interesting idea with a single 12V power adapter. I am guessing it cannot power about 15 HDDs though. I will think about it.

I don’t believe you wear them out faster by keeping them powered off more often. En contraire. But your observation should be taken into consideration nonetheless.

The other thing to consider is what happens if you need to reboot your esp? Do the disks all suddenly turn off? Guessing you would NOT want that.

I could not agree more. Do not mess around with mains power. Do not thrust cheapo ali-express boards with mains power.
There are 12V 24A power supplies available, use those.

I will definitely look into it

I forgot to mention. I bought a bulkier power supply (which was covering well above the necessary Amps) and a few jack splitters and tested using 2 External HDDs using 1 single power supply. The HDDs started acting up. I believe there is some feedback from the HDD case electronics to the power adapter so when using more than 1 HDD, you are messing with this. So in the end the solution remained to use 220v.