ESP-01 input pin

I am thinking of using the ESP-01S relay (ESP-01S-1-channel-relay | ESPHome-Devices) as my sewers overflow sensor + alarm silencer. I have one 220v circuit that I need to switch to turn the alarm sound on/off, but I’d also like to receive notifications in Home Assistant about an imminent poopstorm. Is it possible to use the esphome configuration linked above but specify an additional pin to use as an input / binary sensor?

Esp01 has only two output pins: gpio0 and gpio2. Additionally you can use RxD and TxD pins (gpio1 and 3) by disabling uart in yaml. Just check out for possible mandatory pull-ups on those pins and make sure you’ll have correctly wired so you don’t get boot problems.
Theoretically, other pins CAN be accessible, but it requires microscope and precise soldering directly on esp pins… (i’ve done it).

gpio0 and 2 have to be in certain states for the ESP to boot up
See the table a little ways down in this link:

Makes it hard to use a ESP-01 for discrete inputs.

Gotcha, thanks! This confirms my suspicions. I have s few Nodemcus lying around. Will try to use one of them instead.

It’s no problem using these pins as inputs if you add pull-up resistors (and connect button to gnd when active) and make sure that they are not pressed/active at bootup. Sonoff devices have all on/off buttons connected to gpio0. (Gpio0 through gpio4 all requires to be high at boot).

So the only troublesome corner case would be when my alarm is triggering (i.e. gpio0/2 is high) when my ESP-01 boots up?

Yep, just that. But, i guess that this to happen is pretty small chance, right? I mean…when you update/reset… you module you generally know what you’re doing (and when), so only “risky” time is possible power blackout. But, as said, chances are pretty slim.

Yup. Plus, I have an audible alarm as a fallback anyway. Thanks, everybody for the thoughts! I’ll try the ESP-01 route as the small form factor and an integrated relay is a big bonus.

Hi, simple question: How to disable uart? A search only brings all possible configurations, no disable.

you mean disable it in esphome so it won’t write log on uart? simple:

logger:
  baud_rate: 0
1 Like

Okay, now i have it on my breadboard, i can messure the 5V and pull it to ground 0 Volt but nothin ist seen in Homeassistant. It is shown as a switch. Switching ist does nothing as expected

The code

esphome:
  name: esp01-1way
  friendly_name: esp01-1way

esp8266:
  board: esp01_1m

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  encryption:
    key: "null"
ota:
  - platform: esphome
    password: "null"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp01-1Way Fallback Hotspot"
    password: "null"

captive_portal:

switch:  #HA -) ESP -) Pin
  - platform: gpio
    pin:
      number: 2 #Internal LED switching ON OFF
      inverted: True
    name: "esp01-2way-a Internal LED"
    id: internal_led

  - platform: gpio
    pin:
      number: 0 #Output 0
      inverted: True
    name: "esp01-2way-a Out 0"
    id: output_d0

  # Konfiguration des TX-Pins (GPIO1) als Eingang
binary_sensor:
  - platform: gpio
    pin:
      number: 1
      inverted: True
      mode:
        input: true
        pullup: true
    filters:
      - delayed_off: 10ms
      - delayed_on: 10ms        
    name: "esp01-2way-a In 1"    

Got it, i made a realy stupid mistake: a swicth is not a sensor

The code is now corrected