Hi, i’m relative new to Home Assistant, ESPHome, …
Untill now I managed to use inputs/outputs (binary sensor/switches) on the Wemos D1 mini in combination with Home Assistant and ESPhome.
I’m trying to use a I2C I/O extender, the PCF8574AP connected to my Wemos, without any luck.
Hardware & Software:
Home Assistant 4.15
Wemos D1 Mini
ESPHome 1.18.0
Wemos is powered with USB.
Connections
Wemos 3.3V connected to pin16 of PCF8574 (VCC)
Wemos Gnd connected to pin 8 of PCF8574 (GND)
Wemos D2 (SDA) + D1 (SCL) connected to pin 15 (SDA) + 14 (SCL) of PCF8574
PCF8574 pin 1+2+3 (A0+A1+A2) connected to gnd (to set the address to 0x20)
optionally: PCF8574 pin 12 (P7) connected through a resistor → LED → gnd (pin will be used as ouput)
The log shows the communication with PCF8574 failed.
It also shows “Found i2c device at address 0x38” (somethimes multiple linex with different hex codes are showed), however I have no idea which these are since no other components are connected.
The output pin (P7) seems to be giving 1.7V (floating?)
Does anyone have an idea of what I’m doing wrong? YAML + logs below…
I was replied with some specific info, I’ll post it here…
As I said:
PCF8574 pin 1+2+3 (A0+A1+A2) connected to gnd (to set the address to 0x20 )
I checked again, this is really the case. A0+A1+A2 are connected to the ground, verified it.
The logs shows:
[12:14:28][I][i2c:033]: Scanning i2c bus for active devices…
[12:14:28][I][i2c:040]: Found i2c device at address at 0x38
However, this 0x38 is unknown to me. (and somethimes the log also shows other addresses) I only have the wemos connected to the I/O extender. No other devices are running (although, Home Assistant is running on the Raspberry Pi, some integrations are made in HA, like my NAS, Tado thermostat, …)
I was also pointed out to the datasheet concerning the address reference… But I’m not sure how to interpret this. The hex address should be 0x40 or 0x41 when A0-A1-A2 are low? But should I use the read or write address (I don’t want to write data to the I/O extender, so I guess read since I only want to read an input - but set (write?) an output)? Tried with 0x40 + 0x41 in my yaml also…
Ok…
I disconnected P7 and checked again A0+A1+A2 are connected to the ground (also changed dupont cables)
→ same issues (address 0x20 used in yaml)
I disconnected P7 and used address 0x38 in yaml
→ seems to work now. I changed the yaml to use P0 as the output → connected this one to the resistor - LED - ground. Works fine, I can turn on/off the LED with a button in HA.
[15:17:26][C][i2c:028]: I2C Bus:
[15:17:26][C][i2c:029]: SDA Pin: GPIO4
[15:17:26][C][i2c:030]: SCL Pin: GPIO5
[15:17:26][C][i2c:031]: Frequency: 50000 Hz
[15:17:26][I][i2c:033]: Scanning i2c bus for active devices...
[15:17:26][I][i2c:040]: Found i2c device at address 0x38
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
[15:17:26][C][pcf8574:021]: PCF8574:
[15:17:26][C][pcf8574:022]: Address: 0x38
[15:17:26][C][pcf8574:023]: Is PCF8575: NO
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
[15:17:26][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'pin_0_input_PCF8574'
[15:17:26][C][gpio.binary_sensor:016]: Pin: GPIO0 (Mode: INPUT)
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
[15:17:26][C][switch.gpio:042]: GPIO Switch 'PCF8574 Pin #4'
[15:17:26][C][switch.gpio:043]: Pin: GPIO4 (Mode: OUTPUT)
[15:17:26][C][switch.gpio:059]: Restore Mode: Restore (Defaults to OFF)
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
[15:17:26][C][logger:189]: Logger:
[15:17:26][C][logger:190]: Level: VERY_VERBOSE
[15:17:26][C][logger:191]: Log Baud Rate: 115200
[15:17:26][C][logger:192]: Hardware UART: UART0
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
[15:17:26][C][captive_portal:169]: Captive Portal:
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
[15:17:26][C][ota:029]: Over-The-Air Updates:
[15:17:26][C][ota:030]: Address: keuken.local:8266
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
[15:17:26][C][api:095]: API Server:
[15:17:26][C][api:096]: Address: keuken.local:6053
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
[15:17:26][VV][i2c:083]: Requesting 1 bytes from 0x38:
[15:17:26][VV][i2c:113]: Received 0b11101110 (0xEE)
So, not really clear to met yet
0x38 shouldn’t be allowed, since I can only set A0-A1-A2 from 0-0-0 to 1-1-1 (= 0x20 → 0x27)
Maybe a bad connection with my breadboard? I’ll try later with a different one or cables connected directly to the I/O extender.
in this case, I cannot use P7 as an I/O ? (maybe same issue with others?)
Ok, tried with a different breadboard, same results. When using address 0x20, it fails. When using 0x38 it works (and the logs say it found a device at address 0x38)
I also added P7 as a switch to Yaml (still using address 0x38), and I can use this as a switch, so LED on/off works.
Very strange… Especially if I want to add a second I/O extender, I should use a different hex address (for examle A0-A1-A2 = low, low, high)
Edit/Update
tried without a breadboard… Address stays at 0x38.
I think I’ll get a second PCF8547 to check it it behaves the same (and if it uses a different address, also good - then I can use both)