I am building an ultrasonic garage parking sensor. It will serve as a guide to aid in parking. I am using a Wemos D1 Mini and the HC-SR04 Sensor. I want to also have 3 LEDs Red, Yellow, Green.
The code works great with one LED. I started with the Red LED and programed it to come on when the distance is less than 1m.
I’m working on connecting the Yelllow and Green LED, but encountered an issue when programming. The code won’t allow for two different outputs.
esphome:
name: van-parking-sensor
esp8266:
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "redacted"
ota:
password: "redacted"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Parking-Sensor-Test4"
password: "redacted"
captive_portal:
#RED LED CREATION
output:
- platform: gpio
id: red_led_van_sensor
pin: D7
sensor:
- platform: ultrasonic
name: 'van_parking_sensor'
id: van_parking_sensor
trigger_pin: D1
echo_pin: D2
accuracy_decimals: 1
update_interval: .25s
timeout: 4.0m
pulse_time: 10us
on_value:
then:
- if:
#Light Red LED when too close- Turn off Yellow and Green
condition:
sensor.in_range:
id: van_parking_sensor
above: .1
below: 1
then:
output.turn_on:
id: red_led_van_sensor
- if:
condition:
sensor.in_range:
id: van_parking_sensor
above: 1
below: 1.5
then:
output.turn_off:
id: red_led_van_sensor
Do you have any suggestions on how to add a second LED that can be controlled independently of the first LED?
@nickrout I thought I tried that and it was giving me the ole “Pin D6 isn’t available for GPIO”. But I tried it again and it is working. Thanks for the help!
I’m configuring everything on the wemos d1 mini node in ESP Home. Not triggering anything within HA. Just adding the sensors to HA after the config is done in ESP Home.