howto: Control passive buzzer

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
roost
Posts: 6
Joined: Wed Jan 16, 2019 10:15 pm

howto: Control passive buzzer

Post by roost » Wed Jan 16, 2019 10:28 pm

Hello,

I am quite new to Micropython and i can't figure out how to control a passive buzzer (https://www.aliexpress.com/item/GREATZT ... f4ece250eb) from Micropython.

I found out the PWM class, but this only supports up to 1khz.
On arduino i can just use the tone() library.

My question is, how can i get this to work in Micropython?

Thanks!

User avatar
philwilkinson40
Posts: 59
Joined: Tue Nov 14, 2017 3:11 am
Location: Perth, Australia

Re: howto: Control passive buzzer

Post by philwilkinson40 » Thu Jan 17, 2019 4:32 pm

PWM. This tutorial should give you a helping hand if you have an esp board. Esp boards do have a lower frequency limit, if you need higher try the pyboard.
https://micropython-on-wemos-d1-mini.re ... ml#beepers

User avatar
dhylands
Posts: 3227
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: howto: Control passive buzzer

Post by dhylands » Thu Jan 17, 2019 5:36 pm

This post has a link to some code I put together that works on the pyboard: viewtopic.php?f=14&t=2172&p=12291

roost
Posts: 6
Joined: Wed Jan 16, 2019 10:15 pm

Re: howto: Control passive buzzer

Post by roost » Mon Jan 21, 2019 11:25 am

Thanks for the answers!

It is working now. I am using a esp8266 btw, so not a pyboard.

The example on https://micropython-on-wemos-d1-mini.re ... ml#beepers is working. But there is one problem. If i set the beeper.freq to 0, there is a clicking sound. How can i fix this?

Post Reply