Beginner Question on binary_sensor with inline led

Hi all,

I’ve messed around with esphome a bit, but am brand new to breadboards and wiring things up. I’m trying to set up what I think is a simple circuit to detect if a button is held or not.

I’m using an esp32, not an adruino but the simulator didn’t have one of those. But I hooked 5volt to positive on the breadboard, ground to negative and GPIO5 to the input side of the button.

I got the basic setup working using this code.

binary_sensor:
  # Test GPIO Binary Sensor
  - platform: gpio
    pin: 
      number: GPIO5
      mode:
        input: true
        pullup: true
      inverted: true
    name: "$name_of_board Test GPIO Pin"

and this wiring


If I press the button, I can see the sensor change state.

However, if I try to put an LED inline for some sort of visualization for the button, the sensor stops updating.


and the led comes on very dim.

Why is the sensor not reading the state change now, and why is the light dim?

Lastly, I wired the circuit using a jumper from the 5volt right to the input side of the button and unplugged the GPIO5 cable and the led came on super bright (probably should have put a resistor in :slight_smile: ).

I also wired up the switch again like the second image, except the wire going from the switch output to the led was replaced with a resistor. I then tried putting the GPIO pin parallel with the input side of the switch (H6), and my binary_sensor doesn’t update when I push the button. I put it on the outside (H8), and the led turns on dim, and when I push the button the led lights up normally, but the binary_sensor doesn’t turn on.

Ideally what I’m looking to get out of this is to have a binary sensor that can read if the led is on or off, and then also have a switch in esphome that can turn the led on and off. Right now I’m just stuck at the first part. Can someone please assist?

Leave the switch on one GPIO and control the LED from another GPIO

I’m only trying the binary sensor for now. I can’t get that working. Not sure what’s wrong with my wiring

figured it out. I had to put the GPIO pin after the resistor, not before. Now it works, and I also added another GPIO pin as a switch to H11 and can turn the led on and off by either pushing the button, or flipping the switch in home assistant. Now to figure out how to do this in my coffee maker :slight_smile: