I have done quite a few things with Arduino and ESP8266 but I’m quite a noob with ESPHome.
I’m making a door lock position sensor. Detection is based on hall sensor in the analog pin of esp8266 and it outputs as resistance about 0.74 V / 1600 Ω (750 RAW) when unlocked and less than 0.4 V / 800 Ω (400 RAW) when locked. How could I output that as binary locked value?
I also have a status led that I’d like to turn on if the door is unlocked. I tested that as switch but it should probably be output since it does not need to be switched by user. So how do I hook that with the sensor value?
Many thanks if someone more knowledgeable could help me a bit!
Currently the config looks like this:
esphome:
name: esp-side-door
esp8266:
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "3ef4hiZ8gQbOfbvur9CDAIfBDdQ4bSDM3of4IagOpUM="
ota:
password: "c1488287f6ed561d8ad184b27f6259f9"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "Door Fallback Hotspot"
password: "ue1MRs75mgl1"
captive_portal:
sensor:
- platform: resistance
sensor: hall_sensor
configuration: DOWNSTREAM
resistor: 5.6kOhm
name: Lock Sensor
- platform: adc
id: hall_sensor
update_interval: 5s
pin: A0
#raw: true
switch: #change to output
- platform: gpio
pin:
number: GPIO4 #D2
name: "Warning Light"