ESP8266 / Tasmota, Hardwired RJ45 Options

Looking for a little advice on my upcoming project, currently i have over 40 Tasmota devices mostly all sonoff’s and a few d1 mini’s all running great… however I’ve started construction on a renovation project of an old barn and have the luxury to wire it “smart” from the offset. The plan is to build a panel inside a large steel junction box housing all the relays and smart tec in one place then i simply have to wire all my switches and all my lighting circuits to the same junction box, then in the future i’ll then have easy access to the relay boards in the event of faults or upgrades.

The relay boards i have…

in total ill need 40 relays my initial plan was to drive all the relays with numerous D1 Mini’s running tasmota i bought a few d1 mini’s and tested with a relay board and they worked great however I’ve been thinking before i go to the trouble of building my panel and assembling a circuit board basing the system on wifi coms is there a simple solution to use a hard wired RJ45 option ? something like this…

The perfect solution for me would be a hard wired option that can run tasmota ? unfortunately my programming knowledge is limited, Ive been happy flashing sonoff’s, creating a zigbee2mqtt network and programming home assistant yaml’s but that’s about it.

I guess i can use the D1 Mini’s and it will work fine i was just wondering if there is an easy out of the box option to remove wifi connections.

Note ill still need inputs for attaching physical switches & inputs for current meters, temps humidity etc etc all that are available on tasmota.

1 Like

Rather than using multiple D1 minis use a raspberry pi running this MQTT to GPIO server. It is configured using yaml so no programming required. And bonus, the pi has an Ethernet port.

The pi only has 20 something usable GPIOs so for 40 relays you will need two unless you do some sort of multiplexing.

I made some custom pi interface boards that may interest you too: Custom Raspi GPIO Interfcae PCB Project

Be careful with the power supply for the relay boards. You will need at least a 5V 5A power supply for 40 relays to be all on at once. Issue with RPi GPIOs

1 Like

That looks great thanks I’ll look into this didn’t consider I could drive 20 relays from a Pi direct, have you found it to be very stable ? This is a must for what I’m doing…

Regarding the power supplies I’ve actually already purchased two 5v 3amp supplies… I decided to split the power and relay arrangements in half in case of fault I don’t loose everything… this would work well with a 2 Pi arrangement as well

Rock solid. Which is good because my alarm system depends upon it.

I’ve had a read and I understand this is just for high / low input / outputs ? So I could send a signal to the relay board but also I’d be able to read a signal in from example a physical switch or a door reed switch ?

However I’m limited to just this ? I can’t input a motion sensor, temp humidity sensors such as the dht22 etc ??

Thanks for your help

Correct. It supports exposing the Pi’s digital i/o via mqtt. So only binary_input type sensors and switch outputs. If you purchase standard PIRs you can use the relay output from them for motion sensing.

However as this mqtt-gpio client runs on Rasbian you can add other applications. For example: or

Alternatively use D1 minis and ESPhome for the DHT sensors. This is what I do. I found any length of cable over a meter or so (even using cat6 cable) introduced errors when using the HA DHT22 sensor. The D1 minis + DHT have been perfect.

1 Like

Do you know if its possible to directly tie an input to an output ? the wife acceptance factor requires some physical switches on the wall to toggle the relays. Im trying to avoid having an input switch and a relay switch in home assistant and linking them with aumtomations it would just get messy

You can get I/O expansion boards really cheap for the RPi. It looks like the server software you linked does support I/O expansion

Hi 3reeman, I am extremely interested in your project as I have exactly the same requirements. Have you managed to get any further, made any decisions on what you are going to purchase and run?
Any insight as to your process would be very interesting.

Kind regards.

@speedyrazor I’m going down the raspberry Pi MQTT route I’ve got all the parts now just need more time in the day to assemble it all… will post pictures when I finally get round to it


You’ve got all the parts, nice, I would love to know what you got and where from, if you could please?

Kind regards.

Hi, great idea, I’m interested. Could you explain to me how to configure a relay connected to the Gpio of rasp in home assistant? Thank you

It is documented here


Are you going to use the raspberry only as a mqtt2gpio device or will it be also your main home controller with HASS ?
If it is not also your main controller it seems maybe too powerfull for this task.

I’m asking this because here is an architecture proposal based on my 3 years of HA experience for whom that didn’t ordered the parts yet :

  • regarding the relay piloting I would prefer to stay with a lower level board like an arduino mega. For reliability, power consumption and lower maintenance.
    It can be either connected by USB either by ethernet with a shield, to your main controller.
  • regarding the controller I will avoid raspberry for reliability issue, I prefer some mini PC like NUC or second hand little desktop without mechanical parts and without sdcard as a main storage if you have less budget.

My arduino stuff are always up and running but it is not the case of my raspberry pi, which had at least one failure per year.

So, I’m using 2 raspberry pi’s with additional expansion boards (PCF8574) the 2 pi’s are getting used for mqtt2gpio solely, my home assistant is on a completely separate raspberry pi running hassio.

I have x12 PCF8574 expansion boards running 6x16 channel relay boards, the remainder 20+ gpio’s on each pi are used for inputs.

You could consider the raspberry pi overkill and over power for its use but I wanted the reliability of a hard wired network and when you brake the costs down I’d still consider this great value …

X 2 raspberry pi £29 each
X 12 PCF8574 £0.95 each
X 6 relay boards 16 channel £8.64 each

Total £121.64 / $153 / 137€

Take Into account cabling and power supplies etc it would still come under £200

For that money I’ve got 40+ inputs ( switches, Reed switches on doors, or even temperatures etc)
And 96 switchable relays used for lights, blinds, heating, security etc

1 Like


My remarks are more related to reliability/maintenance than price. In my experience even if a pi has a low cost, it requires more maintenance work compared to low level boards and have a lower availability rate.
In particular I have noticed regarding the Pi:

  • sensibility to power outage ( I will say it is normal for a computer, but you don’t have this issue with a microcontroller, it just restart without issues and potential corruption)
  • SDCard corruption (can be avoided with lowering the writing but it is time…)
  • on the pi you put a complete OS with programs on top of it, needing time to setup and maintain

I’m sure your system will work with the Pi(s) and have advantages. The goal is more to open the readers of this post to an alternative path.

There is a HLK-SW16 board. It can control 16relay and has RJ45 port. HA can control it…


1 Like

Interesting, would other modules from hlktech also work? I’m liking the look of the HLK-DIO16 16 digital inputs and 16 digital outputs.

I do not know :frowning:
Can’t find any information about it.
For input i use NodeMCU modules.

I realize this is old. This is interesting did you make a board for this or set something up for this config?

Also, tom_l set up a board to improve the limitations (which I don’t fully comprehend with my feeble mind) of the GPIO. Wondering if you had issues.