How would I connect a Nano board to 8 OHM 3W speakers with a PAM8403 amplifier chip without frying the Arduino?

I have an Arduino Nano with me at the moment, along with two 3W 8 OHM speakers. I'd really love to connect just one of these to the arduino to test out tone(), but given I am a beginner to much of this, I am afraid of frying my Arduino

I am told (from what I have read on this forum) that the speaker (just one of them alone) will draw far more current than the Arduino can safely spit out through a pin
Running Ohm's Law, P = VI
3 = 5I
Therfore, I = 0.6 A, well past the safe limits of the Arduino

However, none of the posts really feature the usage of a PAM8403 Class D amplifier chip board which came with my speakers, so I am not sure how to go about using it in such a way that I don't fry my board

Conveniently enough, I happen to have a pack of 150 Ohm resistors on hand, so using these, I should be able to limit the current enough that I don't fry my Arduino right (Though given R = V/I, I am not sure if the resistor limits voltage or if it limits current across it) ?

On that note, here is the attached image of my PAM8403 chip
image

Assuming I am using just one speaker, I connect its input pins to either L or R output (Let us assume it to be R)
I then connect my Arduino input and GND to R Input and GND. I noticed some inputs to the right hand-side, GND(5V) and 5V(5V). This means that it needs a 5V power supply to control and power the speaker right?

But since the Arduino would get overloaded, I use another power supply for this right? My idea was to take a USB-A to USB-A cable, connect one end to my laptop's USB port, and run the power pins on the other end to GND(5V) and 5V(5V). This is a super jerry-rigged solution so I am wondering if there is a better way to supply power to the amp board?

Or would just using my resistors in series with the MCU and speaker suffice? I don't want to run the speakers at max power mind you, just audible enough without frying the board

Thank you in advance

Power the amplifier separately, and be sure to connect the grounds. A 5V 1A phone charger or regulated wall wart should provide enough current for the amplifier.

Please post a link to the product page for the amplifier module.

1 Like

@pwmpin - you know ohms law; if you put a 150 resistor in series with your "8ohm" speaker, What current would be flowing? (5V / 158 ohm) (30mA)
What would the voltage across the speaker be? (250mV)
What power to the speaker? V * I (7.5mW)
or with a square wave (3.75mW) - not enough to hear.

Here is the link to the product: here

I do have a 5V 1A charger on hand, but how do I go about wiring it to the amplifier? The charger has an USB input, so do I plug a USB cable into the charger, and wire the power pins of the other end of the USB cable to the amp board?

I read up further and from what I'd understood, the 8 OHM refers to the impedance of the speaker. If that is the case, we can't plug in the 8 OHM value into Ohm's law as a direct substitute for resistance right?

Also, I am a little confused, how did you get the 250 mV value for the speaker?

Connect the black wire to -5V
Connect the red wire to +5V

Also, 5V from a GPIO is too high an input voltage for the PAM8403, it will result in severe distortion.
You need to use a volume control between the Arduino and the Amplifier

1 Like

Well, no.
Here is an explanation
https://www.jensentone.com/speaker-impedance-power-handling-and-wiring

However in the audio range it is designed for, in a suitable enclosure, ... etc
an "8 ohm speaker" will have an impedance of around 8- 16 ohms. And its not purely resistive.
Can you do quick example calculations on that basis?

Ohms law 30mA * 8 ohms.

Very good that you are asking before really wiring things together.
Do you have a digital multimeter? If not you should really buy one.

With a digital multimeter you could check a lot of things how they will "work out" through measuring. Including how voltage is at this point of my circuitry and how much current flows at this point of my circuitry.

You will have to learn the basics of how to do this. Especcially when measuring currents you have to be careful to not create shortcuts.

I want to explain the basics.

An Arduino can't create high power output. This is the reason why you use an amplifier.
The amplifier make a small and very weak signal strong enough to drive a speaker. By what the name says amplifying.

In your case amplify to drive a 3W speaker.

It is the same basic principle for any kind of amplifier. A portable radio, HiFi-equipment with 30W, 50W, 200W or stadium 100.000 people live-concert with 10000 Watt or what do I know how many watts amplifiers.

The good suited signal into such amplifyers is a signal with 0.7 V to 1V.
This is the reason why you have to dampen down the signal coming from an IO-pin. Because this signal created by the ton()-function has 5V.
A voltage-divider in the 1 to 5 kOhm-range will do.

3W on 5V means 3W / 5V = 0.6 A. Which is too much for the Arduino onboard 5V-pin.
From the onboard 5V-pin you should draw a maximum of 50 mA. This is the reason why you have to use an external power-supply.

If you would like to learn more about Ohms law you could use this online simulator
You can change a lot of values and you can even set the battery (virtually) on fire through short-cut overload. But as it is just a simulation nothing can happen.
https://phet.colorado.edu/sims/html/circuit-construction-kit-dc-virtual-lab/latest/circuit-construction-kit-dc-virtual-lab_en.html

best regards Stefan

I’d use a USB cable with just the two voltage wires, like this one I got from eBay.

https://www.ebay.co.uk/itm/293863301518?var=592604940825

Also, 5V from a GPIO is too high an input voltage for the PAM8403, it will result in severe distortion.

Pardon me if my question is silly, I am new to all this. Why do we refrain from using 5V if the board itself labels the corresponding input as 5V? I am assuming a poor man's volume control here would be something that limits voltage somehow, so a resistor will be out of the question? I do have diodes on hand too, so I suppose they would work as a 'volume control' here? I am okay not having control over the volume as long as I don't fry anything

There are no "silly" questions. There are just simple questions.

This is a too unprecise description. The amplifier has a 5V"-input" which is the power-"input".
beneath the power-input there is the signal-input.

The most common application for such amplifiers is to be feeded from a MP3-player or a smartphone over a 3,5mm jack
The voltage-level of these kind of outputs is 0.7V to maximum 1V.

It is very unlikely that the signal-input in the picture they are called
Left Channel Input / Right Channel Input

is designed to use 5V.

The one and only purpose of the amplifier is exact that thing:
amplify the weak 0.7V / 0.1 mA audio-signal up to 5V / 600 mA to have enough power to make the speaker membrane move back and forth to create louder sound than you smartphone on volume 100%

And as the Arduino puts out a 5V PWM-signal this signal must be reduced down to 0.7 V otherwise you tone sounds like death-metal-noise because the signal makes the amplifier clipping all the time
Audio Clipping, Do You Really Understand The Concept?
best regards Stefan

1 Like

Thank you! So if I get this right, my amp should prevent overdraw of current from the Arduino, and a voltage divider (or diodes in series) to reduce voltage so I don't fry my amp?

What I don't understand is how the amp takes in a signal and makes it 'louder'? From what I learnt of amps before (as in BJTs), they have a middle 'pin' that lets it act like a valve, that is I can control how much flows out compared to what flows in

In other words, Power that flows out always <= power that flows in

I don't see how this amplifier works. It can take in power that flows in and make it bigger than it was?

I see no specification for the input voltage range. 5V is for the power supply, not the Left and Right audio input voltage range.
Applying 5V to the Left or Right input may damage the speakers and/or the amplifier.
Use a potentiometer like this:

1 Like

You are asking good questions that show that you want to understand it in detail.

There is this really small power of a standard audio-signal with only 0.7V voltage and only 0.0001 A current. which is 0.7V x 0.0001 A = 0.00007 W

This is the small amount of power coming from the audio-source

Then you have the extra and additional power-supply for the amplifier.

The amount of (electric) power that flows into the amplifier through the +5V connector is more than the electric power that goes out from the right-channel / left-channel output

But the very weak audio-signal coming through the input is amplified.

best regards Stefan

1 Like

Here is a mechanical analogon of what an amplifier does

From the left a weak signal (small waterflow coming from "B") is feeded in.

This small water-flow controls a bigger waterflow coming from "C" going to "E"

The additional power comes from the ADDITIONAL flow in from C (water coming from right upper corner)
(the +5V input of your amplifier)

voltages between 0.00V and 0.7V move the small gate up and down the right way.

If you would feed in 5V from left the thing would be fully opened most of the time and suddenly totally close if the voltage drops down to 0.00V
This changes the sound dramatically and make it sound bad

and here is a video that explains clipping

1 Like

1 Like

Not necessarily true. I’ve used the USB supply for two years as the power source for both the Uno and the DFR Player. Obviously that’s so much more convenient during development, when you’re constantly uploading edits

Only when I’ve wanted to use the volume() function set to 20 or above, with relatively high volume tracks, do I need to supplement the PC source with another regulated or battery 5 V supply.

But the speaker would still overdraw current from the Nano regardless and damage it right? If I reduce the volume like you've mentioned, would not the current still remain the same?

Thank you for your reply! I decided to read up on the topic more, and now I have another worry. I've heard about Lenz's Law. Change in current issues an opposing change in voltage in the presence of a magnetic coil or inductor (speaker in our case)

Which got me thinking. If I suddenly cut power to my speaker, won't this shoot a lot of power back to my amp or mcu and damage it? Would it be right to use a diode (Reverse biased wrt to the 'back voltage') so that electricity does not flow back and damage it?

No.

If you have the amplifiers 5V input connected directly to the extra 5V-powersupply

the big current flows in directly from extra-power-supply into the amplifiers 5V-input

The AUDIO-inputs named Left Channel Input / Right Channel Input have a
HIGH input-RESISTANCE. The current that can flow in there is limited down to microamperes throughg the big internal input-resistance.

No ! Because the potentiometer creates a voltage-divider.
Only a part of the voltage that comes from the GPIO-pin goes into the amplifier.
How big this part is depends on the potentiometers position.
Of course if you turn the potentiometer completely to the end where GPIO is connected
you still "give" 5V into the amplifier.

Anyway
current is always I = U / R
current = voltage / resistance
The input-resistance of the amplifier is minimum 100 kOhm = 100000 Ohm

current: 5V / 100000 Ohms = 0.00005A = 0.05 mA = 50 microampere

Your IO-pin can stand 20 mA = 20000 microampere

Not a lot of power because it is a small speaker with a small coil that has a small inductivity
= small "power"

But it is not the power. It depends on the voltage and the resistance.
Disconnecting power is not a problem because the speakers are still connected.
By Disconnecting the power the same happends as with power connected where the voltage goes up/down in the rythm of the AUDIO-signal.

The main purpose of an amplifier is to "move" up and down the voltage in the exact same way as the input-voltage "commands" Just with higher voltage-numbers.

And this up and down of the voltage causes an up and down going current.
This current change causes this reaction you described but as it is the intention of the amplifier to do exactly this all the time this is no problem.

I haven't done any calculations about this for speakers but as you can buy speaker-switches that connect / disconnect the speakers from the amplifiers output this can't be a problem with speakers.

It is a different case with stepper-motors. The coils of a stepper-motor can indeed cause high voltage-spikes that can destroy the stepper-motor-drivers.
These high voltage-spikes occur do two things:

  1. not switching of the powersupply but instead keep the powersupply switched on
  2. if you dis-connect the motorwires from the stepper-driver while the powersupply is still switched on

Through disconnecting the resistance of the circuit goes up from a few Ohms to millions of ohms.
The coil wants the current to continue to flow with the same vaue and increases the voltage very high.
Though the energy-source is disconnected no additional energy is brought in

result:

a very short voltage-spike as the energy stored in the coil as "magnetic" energy is "used" and gone in a very short time.

This applies ONLY to stepper-motors and their stepper-motor-drivers.
It does not apply to amplifiers

It is good that you want to learn so much.
Anyway if you are worried so much to damage anything you maybe should do intensive and a lot of simulations with software like P-Spice and Tinkercad

But all these simulations will distract you for MONTHS before you can come back to real life electronics.

So a middle way is to measure voltages and currents with a digital multimeter before wiring a component to your arduino

example:
taking your amplifier connecting the amplifier only to the speaker
then connecting the digital multimeter to measure current that flows through the 5V amplifier-input an then measure the current that flows in

  • if nothing is connected to the input
  • if some audio-source is connected to the amplifiers input making the amplifier playing the audio

too see what currents do flow.

Same thing for measuring the current flowing into the amplifier through the AUDIO-input
etc. etc.

And as a general safety-thing:
connecting your arduino to whatever other component over a 1000 Ohm resistor

This resistor will limit the maximum current down to
5V / 1000 Ohm = 0.005A = 5 mA.
Maximum current per IO-pin 20 mA. So 5 mA is 25% of 20 mA. A safe value.

In some cases the 1000 Ohm-resistor will cause a malfunction as pure "not functioning" but never as destroying anything.

best regards Stefan