Arduino Mega - How to lower current voltage and intensity of digital pin output?

Hello,

I’m trying to send tone signal from a digital i/o pin to a buzzer.

The buzzer works under 3V voltage and <=35mA intensity.

I got this information from the docs:

If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.

However I’m not sure whether this applies to Arduino Mega as well, and how much intensity does the digital pin output for the Mega board.

Also I don’t know how to lower or set as maximum the voltage from 3.3V to 3V, as well as the intensity to 35mA.

Does anyone have any idea?

Probably the best solution is to use a transistor. Base to Arduino pin via resistor, emitter to ground, buzzer between 3.3V and collector.

I'm not the expert but a BC547 will probably do; resistor 1k Ohm.

Components draw as much as they need, no need to limit the current.

According to the mega spec, you can draw 50 mA from the 3.3V pin. Test it, if the 3.3V regulator gets too hot, use an external power supply.

Can you post a link to the buzzer's specs?

//Edit
overlooked the 3V, you might need a dedicated power source for that but the buzzer might survive 3.3V.

sterretje:
Probably the best solution is to use a transistor. Base to Arduino pin via resistor, emitter to ground, buzzer between 3.3V and collector.

I'm not the expert but a BC547 will probably do; resistor 1k Ohm.

Components draw as much as they need, no need to limit the current.

According to the mega spec, you can draw 50 mA from the 3.3V pin. Test it, if the 3.3V regulator gets too hot, use an external power supply.

Can you post a link to the buzzer's specs?

//Edit
overlooked the 3V, you might need a dedicated power source for that but the buzzer might survive 3.3V.

The specs are there.

BTW, I think that I can't use the 3.3V power pin because I have to use the tone api, I think I need an I/O digital pin + GND pin.

Stick 2-3 diodes in series between the IO pin and the buzzer. Check the voltage dropped across their output with a meter before connecting the buzzer.

kaisbensalah:
BTW, I think that I can’t use the 3.3V power pin because I have to use the tone api, I think I need an I/O digital pin + GND pin.

The transistor is controlled by a IO pin, the power for the buzzer can (or can not) be supplied by the 3.3V pin. Below the idea.

bc547_buffer.jpg

It will probably work fine at 5V. If you actually bought a package of 20, go ahead and connect one to 5V... Worst-case you fry one. :wink: (If you buy from reputable suppliers you'd get a link to the real datasheet and you could look-up the maximum voltage, but you'll pay more.)

The current is determined by voltage and the effective resistance of the device ([u]Ohm's Law[/u]).

And, if the device is linear (if the resistance doesn't change with voltage) current will increase proportionally so that's 58mA at 5V which exceeds the Arduino's "absolute maximum" current of 40mA.

So you should use a transistor (or MOSFET) driver. [u]Here is a transistor driver circuit[/u]. You can leave-out the inductor since the load in non-inductive. And at low currents, almost any NPN transistor should work. (The buzzer goes in place of the solenoid and of course you'll connect it to 3.3V.)

...because I have to use the tone api,

If the description is correct you can't use tone(). It's a "buzzer" with it's own built-in oscillator (not a transducer/speaker) and it runs from DC.

arduarn:
Stick 2-3 diodes in series between the IO pin and the buzzer. Check the voltage dropped across their output with a meter before connecting the buzzer.

I'm sorry, because I don't have a meter right now. I will try this soon.

sterretje:
The transistor is controlled by a IO pin, the power for the buzzer can (or can not) be supplied by the 3.3V pin. Below the idea.

bc547_buffer.jpg

ok, understood. Thanks for the clarification. I’m going to try this tomorrow.

kaisbensalah:
I'm sorry, because I don't have a meter right now. I will try this soon.

The other suggested solutions are better, but the diodes may be a quick and somewhat dirty solution. I brain-farted the current issue: you would also need to add a series resistor to limit the current to ideally less than 20mA to keep things safer for the Mega.That will likely impact the buzzer volume.
As pointed out already, that buzzer is likely the wrong device if you want to use the tone function, though the description is slightly conflicting.

DVDdoug:
And, if the device is linear (if the resistance doesn't change with voltage) current will increase proportionally so that's 58mA at 5V which exceeds the Arduino's "absolute maximum" current of 40mA.

I'm sorry to say, but I really didn't understand.

DVDdoug:
So you should use a transistor (or MOSFET) driver.

What do you mean by 'driver'?

What do you mean by ‘driver’?

A transistor or a mosfet.

Grumpy_Mike:
A transistor or a mosfet.

Ok, thanks. But @DVDdoug has clearly pointed out that when he said 'transistor (or MOSFET) driver'.

What I didn't understand indeed, is the meaning of 'driver' in electronics. Because I know about a different meaning in programming.

DVDdoug:
If the description is correct you can't use tone(). It's a "buzzer" with it's own built-in oscillator (not a transducer/speaker) and it runs from DC.

OK. understood. But how is it possible to control the volume from DC?

What I didn't understand indeed, is the meaning of 'driver' in electronics.

A driver is something that supplies the voltage or current to a device which is controlled by typically a micro processor that has limited voltage / current capabilities. A driver is a circuit that bridges that gap.

kaisbensalah:
Ok, thanks. But @DVDdoug has clearly pointed out that when he said 'transistor (or MOSFET) driver'.

What I didn't understand indeed, is the meaning of 'driver' in electronics. Because I know about a different meaning in programming.

Conceptually it is more or less the same thing, a driver program is a code piece that knows how to talk to something (like an ethernet board or a serial port) and presents an API to the programmer.

In electronics a driver (as in "LED driver") is a component or circuit that knows how to talk to something and presents you with a way to tell him what you want to do.
In this case the transistor is a driver because it gives you an interface (the base pin) that you just have to switch HIGH or LOW, when you switch that pin HIGH the transistor will switch on and current will flow trough the buzzer, when you switch that pin LOW the transistor will switch off.

So, you don't need to worry if your Mega sends 3.3 or 5 V, the driver circuit will provide the correct voltage to the device. Of course that in this case of a very simple driver you'll have to build it yourself making sure that it will provide the voltage that your device need, so, in Electronics, the final user will have to know more about the device it is working with than a programmer that's only using an API.

Grumpy_Mike:
A driver is something that supplies the voltage or current to a device which is controlled by typically a micro processor that has limited voltage / current capabilities. A driver is a circuit that bridges that gap.

Understood, Thanks :wink:

ocsav:
Conceptually it is more or less the same thing, a driver program is a code piece that knows how to talk to something (like an ethernet board or a serial port) and presents an API to the programmer.

In electronics a driver (as in "LED driver") is a component or circuit that knows how to talk to something and presents you with a way to tell him what you want to do.
In this case the transistor is a driver because it gives you an interface (the base pin) that you just have to switch HIGH or LOW, when you switch that pin HIGH the transistor will switch on and current will flow trough the buzzer, when you switch that pin LOW the transistor will switch off.

So, you don't need to worry if your Mega sends 3.3 or 5 V, the driver circuit will provide the correct voltage to the device. Of course that in this case of a very simple driver you'll have to build it yourself making sure that it will provide the voltage that your device need, so, in Electronics, the final user will have to know more about the device it is working with than a programmer that's only using an API.

Understood, thanks for the great explanation.

sterretje:
//Edit
overlooked the 3V, you might need a dedicated power source for that but the buzzer might survive 3.3V.

I think that the 50mA intensity generated by the 3.3V power pin, is too high for the buzzer (in the specs the maximum supported intensity is 35mA). Do you think that 50mA can cause damage to the buzzer?

Your power pin does not "push out" 50 mA. It delivers as much as is needed which in this case will be 35 mA.

Think of it this way. The electricity system in your house can deliver 16A (@230V). If you connect a 60W lightbulb (roughly 0.25A), does it blow up?

sterretje:
Your power pin does not "push out" 50 mA. It delivers as much as is needed which in this case will be 35 mA.

Think of it this way. The electricity system in your house can deliver 16A (@230V). If you connect a 60W lightbulb (roughly 0.25A), does it blow up?

Understood. Thanks.

sterretje:
The transistor is controlled by a IO pin, the power for the buzzer can (or can not) be supplied by the 3.3V pin. Below the idea.

bc547_buffer.jpg

I’ve already tried to implement this buzzer driver, using UNO, BC547 transistor, 2K ohm resistor and an active buzzer (different buzzer).

This is the schematic I used for the implementation:

I’m pretty sure that the new buzzer works under 3.3V (I tested it).

However after connecting the buzzer to the board using the driver described above, no current gets flowed to the buzzer. And of course, I can’t hear any beep.

I’m really stuck at this point - I can’t know what’s causing the problem …

Do you have any idea?