I have this piezo buzzer module:
I tried with this config:
output:
- platform: ledc
id: buzzer
pin: GPIO18
rtttl:
output: buzzer
id: my_rtttl
gain: 50%
switch:
- platform: template
name: suona
turn_on_action:
then:
- rtttl.play: 'siren:d=8,o=5,b=100:d,e,d,e,d,e,d,e'
turn_off_action:
then:
- rtttl.stop:
The problem is the sound is barely audible and also the volume control behaves weirdly, I get the max volume with gain at 50%, but if I set higher (for example 90%) or lower (for example 20%) it actually gets quieter…
So I desoldered the actual piezobuzzer (the black circular thing) from the small board and connected directly one leg to GND and the other to one GPIO (as stated by esphome documentation, read the code), and copy pasted the following configuration:
# Configure the output
output:
- platform: ledc
######################################################
# One buzzer leg connected to GPIO12, the other to GND
######################################################
pin: GPIO18
id: buzzer
inverted: True
switch:
- platform: template
name: suona
turn_on_action:
then:
######################################################
# Must be turned on before setting frequency & level
######################################################
- output.turn_on: buzzer
######################################################
# Frequency sets the wave size
######################################################
- output.ledc.set_frequency:
id: buzzer
frequency: "1220Hz"
######################################################
# level sets the %age time the PWM is on
######################################################
- output.set_level:
id: buzzer
level: "50%"
turn_off_action:
then:
- output.turn_off: buzzer
But the problem is the same. I would think that the buzzer itself is quiet but the fact that increasing the volume in configuration make the actual volume lower makes me think I’m doing something wrong.
Any suggestion?