Atom lite + mini passive buzzer

Hi folks,

Just wondering, has anyone done any automations using one of M5stack’s mini passive buzzers and the atom lite? I’ve only just started looking at these devices and not sure how to go about it.
I have added the atom lite to home assistant, but not sure how to add the buzzer.

I use the LEDC platform and RTTL with my passive buzzers - that gives a bit of flexibility.

If you don’t want the fiddling with the RTTL component, it can all be driven using LEDC and on and off commands. There is an example in the LEDC page:

1 Like

Nice, that gets me half way there! Thank you.
Should the buzzer come up as a sensor or something when looking at the atom device on home assistant? If not, how would I go about incorporating it?

If you followed the example it won’t show up. output: is internal only, you need to reference it with a switch and the switch has to have a name:

output:
  - platform: gpio
    pin: 25
    id: 'generic_out'
switch:
  - platform: output
    name: "Generic Output"
    output: 'generic_out'

I managed to figure that out, so I have a switch now, but the buzzer just “blips” when I toggle the switch. Do I control the behavior of the buzzer from an automation, or from the atom lite itself?
Sorry for all the questions, I’ve only just started using esphome, so still trying to figure out how things work.

This depends on what you are trying to achieve.

How long do you want the buzzer to sound for? Is ir reacting to something happening on another device or is it local to the ESP?

I’m currently messing around, to see what I can do, but had a thought to use it as an audible alert.
So it’d be reacting to another device.

Then I suggest an automation in HA that switches on the switch to start the alarm and switches it off when cancelled.

Are you saying the buzzer does not sound continuously with the switch on? If not then you have something not working correctly.

It doesn’t sound continuously. I shall look at your example and see what I did wrong.
Thanks for the assistance. I appreciate it. :slight_smile:

Also have a play with frequency and duty cycle.

Finally got it working.
Once again, thanks for your help. I’m only starting down the Esphome rabbit hole, but I’m liking what I see so far.

Here’s the code

output:
  - platform: ledc
    pin: 26
    id: buzzer_1

switch:
  - platform: output
    name: "Buzzer"
    output: 'buzzer_1'
    on_turn_on:
      then:
      - output.turn_on: buzzer_1
      - output.ledc.set_frequency:
          id: buzzer_1
          frequency: "2000Hz"
      - output.set_level:
          id: buzzer_1
          level: 50%
    on_turn_off:
      then:
        - output.turn_off: buzzer_1