Hello everyone, I am an EspHome newbie.
I have created a project that uses an MQ-2 sensor and three LEDS, a green one that power on when the gas values are normal, a yellow one that lights up when the gas values are in an alert range and a red one when the gas values are dangerous.
In the latter case, the project also includes a buzzer sound.
I have managed to program the automations in esphome to do all this, the only thing I cannot do is the continuous buzzer sound.
At the moment it sounds for a few seconds and then stops, I would like it to sound for as long as the red led is on.
Another problem is that the volume of buzz is low, how I can up it?
Can you help me with this.
I paste the code I have created:
esphome:
name: esp-tutorial
platform: esp8266
board: d1_mini_pro
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "084ee2a40de4502d812f603bf7d39c18"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.131
gateway: 192.168.1.1
subnet: 255.255.255.0
dns1: 192.168.1.1
dns2: 8.8.8.8
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp-Tutorial Fallback Hotspot"
password: "op5zTE1POuUc"
captive_portal:
output:
- platform: gpio
id: "green_LED"
pin: D3
- platform: gpio
id: "red_LED"
pin: D2
- platform: gpio
id: "yellow_LED"
pin: D1
- platform: esp8266_pwm
pin: D5
id: passive_buzzer
rtttl:
output: passive_buzzer
##########
light:
- platform: binary
output: "green_LED"
id: "green"
- platform: binary
output: "red_LED"
id: "red"
- platform: binary
output: "yellow_LED"
id: "yellow"
###########
sensor:
- platform: adc
pin: A0
id: "gas"
name: "valore gas"
update_interval: 1s
filters:
- multiply: 100
unit_of_measurement: "%"
icon: "mdi:percent"
on_value_range:
- above: 40
then:
- light.turn_on: red
- light.turn_off: green
- light.turn_off: yellow
- rtttl.play: 'long:d=1,o=5,b=100:e6'
- above: 30
below: 40
then:
- light.turn_on: yellow
- light.turn_off: green
- light.turn_off: red
- rtttl.stop
- below: 30.0
then:
- light.turn_on: green
- light.turn_off: red
- light.turn_off: yellow
Thanks for help and ciao