The Buzzer shield

The Hardware

The buzzer shield implements a passive buzzer with frequencies up to 1 kHz - 3 kHz. By default it uses data line D5 corresponding to GPIO 14 but can be configured to a different GPIO line.

wemosBuzzer.png

In order to make the device work a solder bridge for the data line must be installed ( see the 4 double solder blobs on the left hand side of the module. One of these pairs of blobs must be connected).

The software

The buzzer needs a frequency passed to it through a GPIO line (by default the upper solder pair blobs connected corresponding to D5 or GPIO 14. To test the device I wrote a very simple micro Python script sending a 500 Hz square wave to it. This can easily be done through the micro Python PWM class.

Here is the code:

https://iotworkshop.africa/pub/AFNOG/BuzzerShield/firstTest.py.txt

Dave Hylands has written some micro Python buzzer scripts to play ringtone melodies defined in the RTTTL (Ring Tone Text Transfer Language). These scripts are written for the PyBoard and must be modified to run on the WeMos D1 mini which use the ESP8266 CPU. I found another problem in the ESp8266 PWM driver code for micro Python, limiting the maximum frequency to 1 Khz, too low to play the tunes correctly. It turns out however that the driver can run at frequencies up to ~ 2 kHz and simply modifying the limit to 2 kHz solved the problem. Of course micro Python must be recompiled and re-flashed to enable these higher frequencies.

And here are the scripts playing the ringtones: esp8266Buzzer is the main program relying on the RTTTL class defined in rtttl.py and the songs on RTTTL format defined in songs.py:

https://iotworkshop.africa/pub/AFNOG/BuzzerShield/esp8266Buzzer.py.txt

https://iotworkshop.africa/pub/AFNOG/BuzzerShield/rtttl.py.txt

https://iotworkshop.africa/pub/AFNOG/BuzzerShield/songs.py.txt

-- Uli Raich - 2019-03-22

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt esp8266Buzzer.py.txt r1 manage 0.7 K 2019-04-05 - 15:05 UliRaich  
Texttxt firstTest.py.txt r1 manage 0.2 K 2019-04-05 - 15:05 UliRaich  
Texttxt rtttl.py.txt r1 manage 3.8 K 2019-04-05 - 15:05 UliRaich  
Texttxt songs.py.txt r1 manage 6.2 K 2019-04-05 - 15:05 UliRaich  
PNGpng wemosBuzzer.png r1 manage 101.1 K 2019-03-22 - 14:15 UliRaich  
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r2 - 2019-04-05 - UliRaich
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback