Read Values from a Speaker

Hello Forum,

I am using Arduino UNO and did a project to sync LED to audio. I am not sure how to read a value from a speaker.

I connected a LED to Pin 9 (PWN) with 220ohms and ground. I connected A0 pin to a speaker pin and ground pin the other pin on speaker. I used the Smoothing example of arduino input and modified the code a bit to output to LED. The speaker I used was with an old Phillips Music System and had only two pins. I played the music and led synced perfectly and everything worked fine. The project was a success.

Today I wanted to try to connect to a home theater (5.1 Sony HT-IV300 Model). This speakers also have same 2 pins. So I did everything same. A0 to Speaker pin 1 and Ground to Speaker pin 2. But suddenly the Music System went to power protect mode and A0 is stuck at ~1000 (975 - 977). I connected the arduino again with the Phillips Music System (Same setup) but A0 is always gives ~1000 value. Connecting to A1 and changing the code works perfectly fine!

Where did I go wrong? I cannot understand what happened to A0 pin? What is the correct way to read speaker values?

Thank You. Abhi

Hi,

The home theatre probably uses differential output to drive the speakers, the both terminals of the speakers are active, rather than one being connected to earth.

When you connected the arduino you earthed one of the active outputs and it went into fault mode.

You should get a good signal from one of the speaker terminals to the input of the arduino and the gnd of the arduino and the gnd of the amplifier.

I'm not sure what your circuit is between the speaker and the arduino. But you will have to make sure that the negative part of the audio signal is blocked from getting to the arduino as it cannot handle negative voltages. Also that the input voltage at the arduino input pin does not get above 5V.

Tom... :)

circuit is just two wires. I just want the value the speaker gets when an audio plays.

Circuit is this GND - Speaker Black A0 - Speaker White

this fried my A0. anyway to fix it?

And is there a better circuit?

You just completely ignored a really good answer.

Okay speaker dose have a negative voltage (connected each speaker wire separately to multimeter gives a + and - 0.15 volts each, i guess thats negative...)

So connecting one of these wire to arudion through a 10k resistance is enough to read the values? where should I connect the ground? No amplifier is used the speakers are driven by sony home theater setup box!

Thank You

aarg: You just completely ignored a really good answer.

Not ignoring it exactly... Taking time to understand :P Not much knowledge on Amplifiers...

abhishrant: Not ignoring it exactly... Taking time to understand :P Not much knowledge on Amplifiers...

Well then you're going to learn the hard way. :) Some people prefer it. I had to learn some things that way, but when you toast something expensive, it can take all the fun out of it.

Microphones cost a fortune here and I cannot use it as it would block the speaker in normal use.

Anyway, All I understood from the answer is that arduino cannot handle negative voltage (which explains why it fried input pin while connecting to Sony Home Theater speaker but not when connecting Phillips Music System speaker)

Secondly, There is no circuit between the arudio and speaker
This is all I have
Sony Home Theater Amplifier outs two wire for Speaker – Two wires to speaker – speaker to Arduino

Voltage is not going above 5volts, stays constant at 0.15 volts even when playing a song in the Home Theater.

All I need is to connect the speaker to Arduino to read the signal to drive a LED accordingly. Which works perfectly with the Phillips Music System.

aarg: Well then you're going to learn the hard way. :) Some people prefer it. I had to learn some things that way, but when you toast something expensive, it can take all the fun out of it.

I am even not getting the point to learn what exactly :/

this fried my A0. anyway to fix it?

No it is dead.

So connecting one of these wire to arudion through a 10k resistance is enough to read the values?

No.

(which explains why it fried input pin while connecting to Sony Home Theater speaker but not when connecting Phillips Music System speaker)

The voltages were diffrent, the impedance of the source was different. You probably damaged the Arduino on the Phillips system and along came the Sony and blasted it.

Voltage is not going above 5volts, stays constant at 0.15 volts even when playing a song in the Home Theater.

I don't think so, how did you measure this. A multimeter will not give a sensible reading on a music signal. You need to use an oscilloscope to measure the signals you have.

You are way over your head with this project. I am not sure if you are even up to the level of getting advice but this is what you have to do.

1) AC couple your audio into the Arduino A0 input, that means connecting it through a capacitor. 2) Generate a virtual ground on the A0 input with two 10K resistors pulling up and down. 3) Clamp the A0 input to each rail using diodes. 4) If you avrage the music signal correctly you will get a reading of 512 for anything you play. You sure you want that? If not you have to add an envelope follower circuit to the A0 input.

Grumpy_Mike: The voltages were diffrent, the impedance of the source was different. You probably damaged the Arduino on the Phillips system and along came the Sony and blasted it.

Nothing got damaged exactly. I can still use A0 as output via digitalWrite.

Grumpy_Mike: I don't think so, how did you measure this. A multimeter will not give a sensible reading on a music signal. You need to use an oscilloscope to measure the signals you have.

I do not have oscilloscope nor its available here to buy.

Grumpy_Mike: You are way over your head with this project. I am not sure if you are even up to the level of getting advice but this is what you have to do.

1) AC couple your audio into the Arduino A0 input, that means connecting it through a capacitor. 2) Generate a virtual ground on the A0 input with two 10K resistors pulling up and down. 3) Clamp the A0 input to each rail using diodes. 4) If you avrage the music signal correctly you will get a reading of 512 for anything you play. You sure you want that? If not you have to add an envelope follower circuit to the A0 input.

I got lost at step one...

If I give all the required info then can you make a circuit to connect to arduino which is all I need.

The signal going to the speaker is ac so it swings -ve and +ve. You won't see it on your meter. Let's say you are delivering 8 W to the 8 ohm speaker. That would be 8V at 1A rms for a sine wave, it would be swinging between just over 11V in both the positive and negative directions - easily enough to fry the Arduino input. The peak voltages on music are even higher.

Russell

russellz: The signal going to the speaker is ac so it swings -ve and +ve. You won't see it on your meter. Let's say you are delivering 8 W to the 8 ohm speaker. That would be 8V at 1A rms for a sine wave, it would be swinging between just over 11V in both the positive and negative directions - easily enough to fry the Arduino input. The peak voltages on music are even higher.

Thanks Russell, I got the Problem... I will try to find another source then.

Nothing got damaged exactly. I can still use A0 as output via digitalWrite.

So the analogue input side is nothing?

Do any of the other analogue inputs work? Because there is only one A/D converter in the Arduino and it is multiplexed to provide several inputs. So if you have blown the actual A/D no analogue inputs will work, if you are lucky you might just have blown the input to the internal multiplexer and then the other analogue inputs might work.

A resistor and a pair of [u]protection diodes[/u] can protect your Arduino from negative voltages or voltages above 5V. (I'd change the resistor to 10K and then the circuit would work with a speaker signal, a headphone signal, or a line-level signal without loading-down the audio signal.)

Like russellz says, a home theater system can easily go over 5V peak. A sine wave that peaks at +/- 5V is about 1.5 Watts into 8 Ohms. And, a power amp has plenty of current capability to fry the Arduino when the signal swings negative or goes over +5V.

Nothing got damaged exactly. I can still use A0 as output via digitalWrite.

Your Arduino may not be dead, but it's permanently disabled.

"My car didn't get damaged in the accident. The door won't open any more, but I can still climb in-and-out of the window." :D :D :D

abhishrant: If I give all the required info then can you make a circuit to connect to arduino which is all I need.

Many of the people on this forum can. That is their "Day Job", in other words, they get paid to do it. I think you can post in Gigs and Collaborations for this kind of service.

Grumpy_Mike: So the analogue input side is nothing?

Do any of the other analogue inputs work? Because there is only one A/D converter in the Arduino and it is multiplexed to provide several inputs. So if you have blown the actual A/D no analogue inputs will work, if you are lucky you might just have blown the input to the internal multiplexer and then the other analogue inputs might work.

All input work fine, except A0 which only works as output now (odd output though) It is stuck at High when I use it as Input.

Nothing has happened to arduino except one pin!

DVDdoug: A resistor and a pair of [u]protection diodes[/u] can protect your Arduino from negative voltages or voltages above 5V. (I'd change the resistor to 10K and then the circuit would work with a speaker signal, a headphone signal, or a line-level signal without loading-down the audio signal.)

Like russellz says, a home theater system can easily go over 5V peak. A sine wave that peaks at +/- 5V is about 1.5 Watts into 8 Ohms. And, a power amp has plenty of current capability to fry the Arduino when the signal swings negative or goes over +5V. Your Arduino may not be dead, but it's permanently disabled.

"My car didn't get damaged in the accident. The door won't open any more, but I can still climb in-and-out of the window." :D :D :D

Thanks for the tip I will try that when I get a new Atmega328 for Uno (I will try it on old one). For now my TV has a headphone jack, so I will try to route the audio to it so I can use the jack to get the values!

For the Car, it indeed met with an accident and I can go in and come out. Headlights also switch on.Engine starts. Steer works. Brake works. But I lost a Door Handel but I still manage to Open the Door other way around! :P

Paulcet: Many of the people on this forum can. That is their "Day Job", in other words, they get paid to do it. I think you can post in Gigs and Collaborations for this kind of service.

Thanks for the info! I will try that out if my TV solution dose not work!