Home Assistant Switch for 8 Relays: PCF8574 can be used to extend the GPIO of ESP8266/32 and here we use 8 ports of PCF8574 to control 8 Relay module

GitHub: debsahu/PCF8574_8Relay

Home Assistant Switch for 8 Relays

  • Code can compile on ESP8266/32
  • PCF8574 can be used to extend the GPIO of ESP8266/32
  • 8 ports of PCF8574 is connected to 8 Relay module

Libraries Needed

platformio.ini is included, use PlatformIO and it will take care of installing the following libraries.

LibraryLink
MQTThttps://github.com/256dpi/arduino-mqtt
ArduinoJson v6https://github.com/bblanchon/ArduinoJson
WiFiManager Develophttps://github.com/tzapu/WiFiManager/archive/development.zip
PCF8574 Libraryhttps://github.com/xreef/PCF8574_library
Arduino WebSocketshttps://github.com/Links2004/arduinoWebSockets
UpdateUploadServer (ESP8266)https://github.com/debsahu/DDUpdateUploadServer

Hardware

Items

  1. ESP8266 (aliexpress) / ESP32 (aliexpress)
  2. 3.3V to 5V converter (aliexpress)
  3. PCF8574AP (aliexpress)
  4. 8-port relay (aliexpress)
  5. Plastic Box (amazon)
  6. AC plug socket (aliexpress)
  7. 3-pin AC cable (aliexpress)
  8. 2 sockets (Home Depot)

Instructions

  • Break the tab on the sides with brass screws
  • Connect each of the brass screws to Normally Open (N/O) on relay

plug

  • Use PCF8574AP (exact version used here)
  • Use 3.3V to 5V level shifters for ESP8266 I2C data
  • Set A0, A1, A2 to GND so I2C address is 0x20
  • Use 5V as VCC on PCF8574AP
  • Use a good 110V AC to 5V DC device like a phone charger

schematic