Yeah no access to an oscilloscope sadly. I was only asking as if it was a case of "It'll die immediately. If not then it's fine" then I'd have no issue as it's running okay... If there's any risk of it possibly happening down the line I'll pop a diode in to be safe.
After a bit of research it sounds like it might not be an issue if the active buzzer includes it's own circuitry and built-in oscillator (as you've alluded to). I'm not sure if my model has that based on the minimal datasheet sadly, I'd have thought so but can't say for certain.
Could you tell me where the diode would sit in relation to the buzzer circuit please - after the resistor, before the buzzer with cathode facing buzzer direction?
Okay thanks, I'll leave this open for a few days to see if anyone has any input on if it's required. I've spotted the markings "TMB12A05" on the side of the buzzer if that helps anyone.
The part is indeed a buzzer as per the above discussion, my test was getting the buzzer working on a secondary D1 mini (which it does) with the intention of adding it to an existing circuit to create the circuit in the original post.
Who needs help with this, if not you? You must try to do your own research, not rely on others to do it for you, otherwise they won't want to help you when you are really stuck.
Google found the data sheet for that part number on the first page! You could have at least find and posted a link, even if you needed help interpreting the data sheet.
I'm not sure if it's an "active buzzer", it might be just just a speaker. That needs an audio frequency signal in order to make a sound.
What function did you use to get a sound? digitalWrite() or tone()?
Hi Paul, maybe there's been some confusion here. With great help from Perry I was able to get the answer to my original question but he raised a good point RE possible voltage spikes for this which neither of us were 100% sure on.
I've read the data sheet multiple times and have no problem locating it on Google but I put the part number in just in case anyone had any input on the voltage spike concern for the given part number. It's not obvious from the data sheet (or to me it's not) so it was more of a case of if someone happened to read the post and knew from past similar experience (if even possible without testing the actual part I have with an oscilloscope).
In terms of the buzzer, there's nothing leading me to believe it's not an active buzzer as the kit lists it as one and the sound is given when the pin is HIGH. Below is the test code I used:
const unsigned char Active_buzzer = 14;
void setup () {
pinMode (Active_buzzer,OUTPUT);
}
void loop () {
digitalWrite(Active_buzzer,HIGH) ; //Turn on active buzzer
delay (1000);
digitalWrite(Active_buzzer,LOW) ; //Turn off active buzzer
delay (1000);
}
If you want to run it as intended by the manufacturer, and minimise any stress on the Wemos, you can use an ordinary NPN transistor such as bc337 as a switch. Buzzer between 5V and the Collector, Emitter to ground and 1K between the Wemos pin and the Base.
Is the transistor necessary? Based on the above posts I was able to power the buzzer directly from the GPIO pin with a resistor limiting the current to less than the pin provides to avoid the buzzer drawing too much. It seems to work that way and avoids the need for the transistor. I think my only question now is the diode required for voltage protection from the magnetic buzzer.
The you don’t have a TMB12A05, no matter it is marked as such. From the TMB12A05 data sheet:
This is not a true piezoelectric speaker but behaves similarly. Instead of a piezoelectric crystal that vibrates with an electric current, this tiny speaker uses an electromagnet to drive a thin metal sheet. That means you need to use some form of alternating current to get sound. The good news is that this speaker is tuned to respond best with a square wave (e.g. from a microcontroller).
Emphasis mine.
So that’s why I wanted to see the program you used.
But I never argue with success or the empirical process.
I will say that often it is a mix up of buzzer, beeper, squeaker or tweeter operating type that slows ppl’s progress.
It's a piezo buzzer. Include the diode just in case; it costs almost nothing and saves you the trouble of tracking any problem that may or may not occur at some point.
I'd also recommend driving this with a transistor (BJT or MOSFET). A microprocessor is not a power supply.
Btw, I'm currently using the exact same buzzer (TMB12A05) in a project of mine where it's controlled by an ESP32. I drive it through a BSS123 small signal mosfet. Works like a charm. The buzzer runs off 5V to ensure the volume is sufficiently loud also when the PCB is mounted inside its housing. I have to admit it's not much less loud at 3V3 though.
Getting quite a few conflicting comments here! I don't think it's a piezo buzzer and is just a magnetic buzzer based on the data sheets and from what I have working so far. Putting that aside anyway..... I'll hook up a diode to just be sure, I have some lying around anyway. Just might make squeezing it into the case a little harder.
I'd prefer to avoid the transistor unless I'm going to have issues not using one. From a power supply perspective and from what I have so far it appears I'll be okay without one (pin providing 12mA, buzzer happily taking 10mA with resistor) and the GPIO pin provides enough power to the buzzer/speaker/noise unit to get the volume I require for this project.
That description is not included in the data sheet I linked to. But it is shown in the seller's product page you linked to. Given how @burg is able to use it, (digitalWrite() rather than tone()) I think the product page is incorrect.
You wanted to know how to drive it. You know, and nobody disputed, you can drive it directly from a DC power source and it'll consume up to a couple dozen mA depending on voltage. There's also no dispute that I can see either on that it would be wise to drive it through an external transistor.
The only thing conflicting are the external datasheets and product pages, which, for a Chinese product, isn't very surprising.
Yes. In fact a product page calling it a speaker links to a demo page that uses it as a beeper or buzzer, that is something that makes noise with simple application of 5 volts.
The Chinese data sheet that looks most plausible and thorough is, um, hard to read, but seems to indicate the truth as learned by testing.
Which makes me feel bad for anyone actually looking for a little speaker that looks like this. I have some, carefully labeled as such, but it looks like I'd have trouble being sure I was going to get more just by ordering them based on sales info, product page or datasheet.
No. If you're happy with the volume of the buzzer at ~10mA, then ok. If not, you could make it a little louder by connecting it between 3.3V and the Wemos pin and reduce the resistor a little to get around 14~16mA. ESP pins can sink a little more than they can source, I seem to remember reading, max 20mA I think. If course, it's always wise to stay below 75~80% of such maximums, to avoid shortening the life of any component. If still not loud enough, then use 5V and a transistor.
If anything it's still loud enough with the sticker over the top at 10mA so I'm fine on the volume front. All solved then thanks all! More or less the original diagram with an additional diode across the buzzers leads.