Arduino with Home Assistant

Hi, I have a Home Assistant set up and everything I working just fine. However I am trying to connect an Arduino Mega with about 40 relays and 10 buttons connected to it and I want to be able to control them using Home Assistant. I was planning to use MQTT with this library but I ran into major problems as desbribed here. I already spent hours trying to fix my issues but I wasnt able to up until now (The issue also Isnt realted to homeassitant but rather to the library i mentioned as the Arduino doesnt send any packages in the respective MQTT channels as I found out when using MQTTX).

Long story short: I’am looking for an alternative suitable for my usecase. It would be best if the solution was working over LAN and not USB as I would have to cover quite a large distance with an USB cable and I would also like to have the extra flexibility LAN offers.

(Propably irreleveant information: Arduino Mega with an Ethernet Shield, Home Assistant running on my home server in a Proxmox VE)

I’d love to hear suggestions!

Regards, Emil

Maybe the better option would be use a ESP32 and EspHome instead of arduino mega.

You can add more GPIO using a multiplexer to get the 50 GPIOs necessary (or use multiple ESP32)

I’ve been thinking about using an ESP32 as well but I thought there might be another way especially as I’ve now already set everything up with an Arduino.

It just occured to me that I still have a few ESP32 Dev Borads laying around which I’am going to use now.

The ESP32 with ESPHome would be much more suited to this application.
An Olimex ESP32-POE-ISO used with an I/O Expander as mentioned above would be what I’d do.
ESPHome has support for a variety of I/O Expanders (see ESPHome’s Miscellaneous Components).
ESPHome’s Home Assistant integration uses it’s own optimized API which I have found to work better than MQTT.