Trouble getting GPIO pins to work

I’m trying to add an optocoupler to my HASS.IO unit in order to detect a power outage.

I’ve built an optocoupler using this tutorial

I entered the following in my configuration.yaml file (I entered all ports while troubleshooting to make sure I had the right one). The sensors do show up on my HA UI.

#GPIO Ports
binary_sensor:
  - platform: rpi_gpio
    ports:
      1: one
      2: two
      3: three
      4: four
      5: five
      6: six
      7: seven
      8: eight
      9: nine
      10: ten
      11: eleven
      12: twelve
      13: thirteen
      14: fourteen
      15: fifteen
      16: sixteen
      17: seventeen
      18: eighteen
      19: nineteen
      20: twenty
      21: twenty one
      22: Twenty two
      23: twenty three
      24: twenty four
      25: twenty five
      26: twenty six

I have the optocoupler plugged into the ports as described in the instructions.

I hooked the other end of the optocoupler into 110V main power and toggled the power on and off. I haven’t seen any change to the binary sensors in HA.

Do I need to do something else to get the GPIO pins to work? Is there a way to test that the pins do work?

If you have a multimeter, can you measure the voltage at GPIO5 (junction of the resistors and LDR) with the light on and off?

Shorting one of the GPIO pins to 3.3v or GND should cause the state to change in the front end. Best to do it with a resistor (any value from few hundred Ohms to 10K) in case you get the wrong pin.

Thanks! This is what I need to do. I’m trying to eliminate as many variables as possible. This should do that.

Problem solved. I didn’t have a bright enough indicator light for the sensor to pick up. I bought these and they work great.

1 Like