How many binary sensors can a Wemos D1 Mini handle?

I have Tasmota on it. I’m familiar with Tasmota, but open to using something else, if needed.

I’m not familiar with Tasmota.

I use ESPhome.
Setup is using yaml, same as HA.
I set up a door sensor yesterday using mqtt and all i had to do was define the binary sensor.
The sensor was auto discovered in HA.

What does your tasmota configuration look like? Can you send a screenshot?

i’m just a newbie. but hopefully i might help a bit. in my device configuration this is what i did:
D1 = Switch2
D2 = Switch3
D3 = Switch4
Capture
then in the Device Console i typed:
SwitchTopic2 MainDoor (or whatever you want to name it)
SwitchTopic3 MainGate
SwitchTopic4 GateStairs
so whenever D3 is triggered, the MQTT message i get is:
cmnd/GateStairs/Power - ON

this might not be the best solution but it works for me.

1 Like

Thanks! I’ll bet this is what I need to do. I’ll try it when I get home.

Be carefull with D3 (GPIO0). When it’s grounded, the Wemos D1 mini will not start.
https://forum.arduino.cc/index.php?topic=504662.msg3441778#msg3441778
I’ve spent hours on searching, just to find out that a window must be open for the D1 to boot. :slightly_smiling_face:

4 Likes

Good tip! Thanks!

Thanks for the tip, i don’t know much about GPIOs yet

Also, if that one place your reed terminals are terminated happens to be near your HA device (pi or whatever), you could do it more efficiently using a mega with the HA serial sensor platform (mega has 54inputs, and doesn’t require using wifi resources). I use a nano as a serial sensor to monitor the wires I have in my alarm closet (my doorbell, mains power, and UPS power). It’s not too hard to code the mega either… the arduino json library makes it fairly painless. Here’s what I use:

Based on this website, it looks like there are 5 safe GPIO pins for inputs (4, 5, 12, 13, 14). Do you know which pins are the 6th and 7th I could use?

Hi,

this is no problem with I2c IO Expander. pcf8574 You can set there in a row
Here a Example

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

  - platform: gpio
    name: "Garten_Relais_3"
    id: garten_relais_3
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 2
      number: 2
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true
      
  - platform: gpio
    name: "Garten_Relais_4"
    id: garten_relais_4
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 3
      number: 3
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true

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

  - platform: gpio
    name: "Garten_Relais_6"
    id: garten_relais_6
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 5
      number: 5
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true

  - platform: gpio
    name: "Garten_Relais_7"
    id: garten_relais_7
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 6
      number: 6
      # 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: 7
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: OUTPUT
      inverted: true

2 Likes

I would use a raspberry pi with node-red.
Since you are using TASMOTA you have a MQTT broker installed and you can easily interface with the RPI using MQTT if needed.
Nodered has also an integrated dashboard, so no LEDs needed, you can monitor the status on the dashboard (any PC, tablet, Ipad that has access to your network can visualize the dashboard).

If you need more inputs to the device you can use a multiplexer that selects one of the inputs by an 3 bit address (8 input - 3 address select, like M54HC151 IC).

There is also the MCP23017 each one of them has 16 I/O and as it uses the I2C bus you can use multiple of them if you change the addresses.

Thanks for the replies with the other options. I had been resisting learning ESPhome since I was already using TASMOTA. I dug into it last night and am glad I did. I can easily differentiate the GPIO pins with ESPhome, so I’ll use that in the future. I especially like how much faster it is than that MQTT through TASMOTA.

I’m an amateur when it comes to this stuff, so I prefer to stick with what I know. I’d rather spend the extra $20 for 6-8 Wemos D1 Minis with ESPhome on them than try to work with something I’m not as familiar with. I’ve tried using Node-Red in the past and never really been good at it, so I’d like to avoid that. I’ve also dug into the MCP23017 and just gotten confused by it. That stuff is over my head at this point. I don’t really see an issue with using multiple Wemos D1 Minis.

Just for your information, this hardware could also be used … is less complicated. You could read 2x16 inputs with 6 gpio pins (4 address lines and 2 inputs).

@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