At the beginning I just connected the buzzer to PIN8 and to GND. The volume is not bad but I need more accoustic level.

My first surprise is when I measured the current. Tester in AC mode says the current is about 0.1 mA!

So I thought, ok, lets improve the current adding a transistor. I used a 20year-old BD139. Base connected to PIN8, Emissor to GND, Collector connected to the buzzer, and buzzer connected to 5V. Still worst! I almost cannot hear any sound.

So my questions are:1) How can I increase the volume using the same buzzer?2) Why PIN8 is giving me so low current? Is there any way to increase it? Theoretically output PINs can load up to 40mA.

PS: the program I'm using is just the "tonemelody" example provided by the framework.

You don't "push current". You put-out a known voltage, and the amount of current depends on the voltage and the resistance/impedance. (i.e. resistance is "resistance to current flow".)

Quote

So I thought, ok, lets improve the current adding a transistor. I used a 20year-old BD139. Base connected to PIN8, Emissor to GND, Collector connected to the buzzer, and buzzer connected to 5V. Still worst! I almost cannot hear any sound.

The transistor needs to be connected to a higher voltage. The 5V from the Arduino (through a current limiting resistor) into the base of the transistor turns-on current flow through the collector & emitter of the transistor, and through you buzzer.

It's the higher voltage that increases the current, and the transistor basically protects the Arduino from the higher voltage, whichoud damage it if you connect it directly.

Sorry, by AC I mean that the buzzer doesn't have an internal oscilator so it doesn't work with DC (Direct Current). Fortunately the Arduino "tone" sentence creates a squared signal.

Quote

Ohm's Law. You don't "push current". You put-out a known voltage, and the amount of current depends on the voltage and the resistance/impedance. (i.e. resistance is "resistance to current flow".)

By Ohn's law I had expected a current of 16mA, as the voltage is 5V and the buzzer internal impedance is 300 ohms.

Quote

The transistor needs to be connected to a higher voltage. The 5V from the Arduino (through a current limiting resistor) into the base of the transistor turns-on current flow through the collector & emitter of the transistor, and through you buzzer.

I cannot connect the buzzer to a higher voltage, it is a constraint of the design. That's why I wanted to increase current and so power, I thought it would be possible to increase volume (power) by using the same voltage and increasing current with a transistor. I can change the buzzer, but all the design must be as lighter as possible: it will fly in a structure of 150gr, and currently the electronics are adding 50 extra gr, including battery.

I don't quite understand these specs, as 24.000 pf [same as 24,000 to US'ers] indicates a piezo buzzer [I think], whereas I'm not sure how Z=300 ohm factors in, since

Xc = 1/(2*pi*3500*24nF) = 1900 ohms.

Another possibility is going to a magnetic "buzzer" rather than piezo. The ones I have measure 44 ohms "dc resistance", and I'm sure that with an NPN inverter driving them at 5V, they'd probably chase me out of the room.

A common complaint here on the forum is that "my LEDs are very dim", and the problem is usually resolved by calling pinMode(pin, OUTPUT); - supplying the forgotten initializer. Inputs make very weak outputs.

I haven't seen any code yet, so I have to ask: can we verify that this is not the problem in this case?

I believe it's a 'raw' pizo element with a resonate frequency of 3.5 khz. As such it acts more like a capacitor and you shouldn't think of treating it as a DC component, as it will not pass DC current. A step-up audio transformer of the correct impedance ratio would be a good way to drive this device with the digital output pin connect to a series capacitor to the primary of the transformer, thus creating a larger symmetrical AC voltage of the proper amplitude to drive this element to it's rated output, but only if you are sending it a frequency close to it's resonant frequency, too high or low a tone frequency and the sound amplitude will fall off quickly. These are just not good components for direct connection to digital output pins.