How many binary sensors can a Wemos D1 Mini handle?

I am looking to monitor about 30 binary sensors (magnetic door sensors). They will be hardwired, all terminated in the same place. I know I can monitor these with a Tasmotized Wemos D1 Mini, but I can only find out how to monitor one. Is there a way to monitor several of these binary sensors with one Wemos D1 Mini?

Google says thereā€™s around 7 usable gpio on the D1

This can be increased by using an expander

These are supported by both Tasmota and ESPhome

Is there a good way to differentiate between the GPIO pins when sending the MQTT message to HA?

When I connect GND to D5 I get this output on the console

04:18:33 MQT: stat/reed-switch-test/RESULT = {ā€œPOWERā€:ā€œONā€}
04:18:33 MQT: stat/reed-switch-test/POWER = ON

When I connect GND to D6 I get this same output on the console

04:18:33 MQT: stat/reed-switch-test/RESULT = {ā€œPOWERā€:ā€œONā€}
04:18:33 MQT: stat/reed-switch-test/POWER = ON

So, if I have Door one connected to D5 and door two connected to D6 how can I tell HA which door opened?

What software are you using on the D1 ?

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).