I am wondering if anyone uses a pcf8574 or pcf8575 port expander together with esphome and an 8266 ?
I suspect that I am missing some basic understanding somewhere but I do not now where. The port expander pins are all available to me as switches under esphome but the physical output pins do not change states when I flip the switch under my lovelace interface.
The physical setup is a Wemos 8266 board hooked up via I2C (pins D1 and D2 plus ground and power) to the expander module shown here: PCF8575 IO Expander Module I2C To 16IO Integrated Circuits New 2018 | eBay
There is nothing set up in the configuration.yaml file to enable everything and under ESPHome I have the following code on the NodeMCU device:
==========================================================================================================================
esphome:
name: wemos_esp8266_2
platform: ESP8266
board: esp01_1m
wifi:
ssid: !secret wifi_iot_ssid
password: !secret wifi_iot_password
fast_connect: true # required when using a hidden network
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Wemos Esp8266 2 Fallback Hotspot"
password: "ZU8JEmHrsxIL"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
i2c:
sda: 04
scl: 05
scan: True
# id: bus_a
pcf8574:
- id: 'pcf8575_1'
address: 0x20
pcf8575: True
# Individual outputs
switch:
- platform: gpio
name: "PCF8575 Pin #0"
pin:
pcf8574: pcf8575_1
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode: OUTPUT
inverted: False
- platform: gpio
name: "PCF8575 Pin #1"
pin:
pcf8574: pcf8575_1
# Use pin number 1
number: 1
# One of INPUT or OUTPUT
mode: OUTPUT
inverted: False
status_led:
pin:
number: GPIO13
inverted: yes
=====================================================================================================================
...
When the nodeMCU powers up it connects, goes out and finds an I2C device on 0x20 and all outputs are set to zero. Unfortunately they stay at zero. I set them up as switches under lovelace and can flip them but nothing happens on the port expander output pins.
I was going to try to put the I2C definition into configuration.yam but as soon as I remove it out of the esphome file it complains.
I am wondering if I am using the device (pcf8574) correctly in the esphome file above as the actual device is the pcf8575 (16 port) version?
So close yet so far away ......