I recently bought this mini speaker from Pimoroni to use with my BBC:Microbit.
I’m trying to create a loud beep but the audio level is disappointingly low but according to the data sheet it has a typical output of 95db. To test it I’ve been using this simple code and it’s so faint:
import music
music.play(music.NYAN)
Am I doing something wrong? ( I read somewhere that buzzers/speakers have a resonate sound which might make it louder if I knew what that was).
It’s likely a combination of two things, the low output signal of the Micro Bit and the “mini” speaker.
I switched to this, https://shop.pimoroni.com/products/thin-speaker and its not bad. It’s like whats in those talking greeting cards.
You still won’t get really loud sound unless you switch to an amplified speaker though, Maybe something like this, https://shop.pimoroni.com/products/speaker-for-micro-bit
I say “maybe” because I don’t currently own one.
The one you linked too looks more like a piezo buzzer than speaker. It states it audible around the 2K Hz range so try sounds more at that frequency.
How are you powering your Micro-Bit? I ask because when powered by USB you are very limited by how much current you can draw. You’ll get much better results if powered by batteries via the JST jack. https://tech.microbit.org/hardware/
Scroll down to the power supply section. Basically, if you power it via the USB port, 5V gets regulated down to 3V , but that regulator is very limited in how much current it can supply. Power it via the battery jack and you bypass the regulator. There are still some limits on current per output pin but your total current draw can be a lot more if running on battery.
Thanks for the suggestion to try using write_analog(511). I’ve read the docs but am struggling with code, how to actually play a tone using write_analog(511)? Any clues you could give me?
pin0.write_analog(511) gives me a low buzz.
This gives me an ok tone that does sound more resonant.
tune = [“C7:40”]
music.play(tune)
Many thanks. I’ve been using usb but have now been trying with my battery pack. Still working on the code to try and make a tone before I know if it’s louder.
Just compared my Piezo buzzer from this kit, https://shop.pimoroni.com/products/sidekick-basic-kit-v2 with the thin mini speaker I have and loudness wise they are about the same. The speaker definitely sounded better but wasn’t really any louder. Not that my ears could tell. I can hear it quit plainly from a few feet away though. music.play(music.BIRTHDAY,pin=microbit.pin0, wait=True, loop=False)
Mine is definitely a buzzer more so than a speaker. If I connect it to the +3V and ground it emits a continuous tone. So that explains why my speaker sounds better. http://wiki.seeedstudio.com/Sidekick_Basic_Kit_for_Arduino_V2/
A buzzer is an audio signaling device, which may be mechanical, electromechanical, or Piezoelectric. It produces various audio signal based on the oscillation of the material used in it. They are commonly used in alarms and timers.
The buzzer can be connected to digital outputs, and will emit a tone when the output is high. Alternatively, it can be connected to an analog pulse-width modulation output to generate various tones and effects.