How many binary sensors can a Wemos D1 Mini handle?

@IngoNRW, is that code you posted the YAML that I would use in ESPhome if I used that 12c IO extender?

If so, if I daisy-chained another pcf8574 to the first one would my YAML code continue with

 - platform: gpio
    name: "Garten_Relais_8"
    id: garten_relais_8
    pin:
      pcf8574: pcf8574_hub
      #Use pin number 7
      number: 8
      #One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true

 - platform: gpio
    name: "Garten_Relais_8"
    id: garten_relais_8
    pin:
      pcf8574: pcf8574_hub
      #Use pin number 7
      number: 9
      #One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true

....

Or would I need to start over with the pin numbers and add some other code to differentiate the second pcf8574 in the daisy chain?

The more I think about it, would my code for daisy-chained pcf8574 hubs look more like this?

i2c:
  sda: D2
  scl: D1

pcf8574:
  - id: 'pcf8574_hub'
    address: 0x20
    pcf8575: False

- platform: gpio
    name: "Garten_Relais_1"
    id: garten_relais_1
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 0
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true
      
  - platform: gpio
    name: "Garten_Relais_2"
    id: garten_relais_2
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 1
      number: 1
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true

...................

pcf8574:
  - id: 'pcf8574_hub2'
    address: 0x21
    pcf8575: False
      
  - platform: gpio
    name: "Garten_Relais_4"
    id: garten_relais_4
    pin:
      pcf8574: pcf8574_hub2
      # Use pin number 0
      number: 0
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "Garten_Relais_5"
    id: garten_relais_5
    pin:
      pcf8574: pcf8574_hub2
      # Use pin number 1
      number: 1
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true

............................

pcf8574:
  - id: 'pcf8574_hub3'
    address: 0x22
    pcf8575: False

  - platform: gpio
    name: "Garten_Relais_7"
    id: garten_relais_7
    pin:
      pcf8574: pcf8574_hub3
      # Use pin number 0
      number: 0
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "Garten_Relais_8"
    id: garten_relais_8
    pin:
      pcf8574: pcf8574_hub3
      # Use pin number 1
      number: 1
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true

........................

yes that is true
You define first the Extender with his own Address (set with the jupmer) an a unique name .
Then you can define the GPIOs

1 Like

I received two pcf8574 boards today, I was able to get one of them to work with my Wemos D1 Mini, but when I daisy chain two of them, the Wemos D1 Mini doesnā€™t boot.

My connections from Wemos D1 Mini to first pcf8574
pcf8574 -> Wemos D1
vcc -> 3.3v
gnd -> G
SDA -> D2
SCL -> D1

On the first pcf8574 Iā€™m using 0x20 address. All three address pins are to the right (on -). When just one pcf8574 is connected using the 0x20 address it works. When a second pcf8574 is connected using 0x21, or if the single pcf8574 is changed to address 0x21, the Wemos D1 Mini doesnā€™t boot.

To make sure Iā€™m understanding addressing correctly, to get the 0x21 address Iā€™m moving the top yellow pin (A2) to the left (+) and leaving the other two ins (A1 & A0) to the left (-). Iā€™m using this table.

Here is my ESPhome YAML code

# pcf8574 configuration entry
i2c:
  sda: D2
  scl: D1

pcf8574:
  - id: 'pcf8574_hub'
    address: 0x20
    pcf8575: False
  - id: 'pcf8574_hub2'
    address: 0x21
    pcf8575: False

# Individual outputs
binary_sensor:
  - platform: gpio
    name: "PCF8574 Pin #0"
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 0
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #1"
    pin:
      pcf8574: pcf8574_hub
      number: 1
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #2"
    pin:
      pcf8574: pcf8574_hub
      number: 2
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #3"
    pin:
      pcf8574: pcf8574_hub
      number: 3
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #4"
    pin:
      pcf8574: pcf8574_hub
      number: 4
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #5"
    pin:
      pcf8574: pcf8574_hub
      number: 5
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #6"
    pin:
      pcf8574: pcf8574_hub
      number: 6
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #7"
    pin:
      pcf8574: pcf8574_hub
      number: 7
      mode: INPUT
      inverted: False

#Hub2
  - platform: gpio
    name: "PCF8574 Pin #0"
    pin:
      pcf8574: pcf8574_hub2
      # Use pin number 0
      number: 0
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #1"
    pin:
      pcf8574: pcf8574_hub2
      number: 1
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #2"
    pin:
      pcf8574: pcf8574_hub2
      number: 2
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #3"
    pin:
      pcf8574: pcf8574_hub2
      number: 3
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #4"
    pin:
      pcf8574: pcf8574_hub2
      number: 4
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #5"
    pin:
      pcf8574: pcf8574_hub2
      number: 5
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #6"
    pin:
      pcf8574: pcf8574_hub2
      number: 6
      mode: INPUT
      inverted: False
  - platform: gpio
    name: "PCF8574 Pin #7"
    pin:
      pcf8574: pcf8574_hub2
      number: 7
      mode: INPUT
      inverted: False

Sorry about this reply. iā€™ve retested it and it doesnā€™t work. SwitchTopic applies to all switches.
So same question as your original post:
ā€œIs there a good way to differentiate between the GPIO pins when sending the MQTT message to HA?ā€
i tried using tele but it Teleperiod only goes down to 10sec. i need to be updated as soon as one of my magnetic reed switches turns on. Any update on this?

SOLVED:
see this

I use the PCF8574 with 5 V VCC

you can conect it with serveral address settings and look into the log whtich adress found:

[12:05:18][C][i2c:028]: I2C Bus:
[12:05:18][C][i2c:029]: SDA Pin: GPIO4
[12:05:18][C][i2c:030]: SCL Pin: GPIO5
[12:05:18][C][i2c:031]: Frequency: 50000 Hz
[12:05:18][I][i2c:033]: Scanning i2c bus for active devicesā€¦
[12:05:18][I][i2c:040]: Found i2c device at address 0x20
[12:05:18][I][i2c:040]: Found i2c device at address 0x27
[12:05:18][I][i2c:040]: Found i2c device at address 0x39
[12:05:18][I][i2c:040]: Found i2c device at address 0x76
[12:05:18][C][pcf8574:021]: PCF8574:
[12:05:18][C][pcf8574:022]: Address: 0x20
[12:05:18][C][pcf8574:023]: Is PCF8575: NO

@IngoNRW, do you have pull up resistors installed between SCL>3v and SDA>3v?

no
pure 5 V