I'm building a project that requires monitoring the activity of a 3.5 mm audio line and I'm trying to use the smallest sized processor possible. The "micro" sized Arduino would be perfect. In looking at products like your Adafruit Audio FX Sound Boards, I see that they list a "stereo line out" but don't advertise any ability to read incoming data.
Do you have anything like what I'm looking for? Is it possible to read incoming data from the stereo output jack?
Thanks for your help!
Micro Arduino with 3.5mm Audio Input?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67391
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Micro Arduino with 3.5mm Audio Input?
The FX Board only plays audio tracks. It doesn't handle audio input at all.
What specifically do you mean by 'monitoring' the signal? It's a lot easier to track general amplitude than to sample audio for reproduction.
What specifically do you mean by 'monitoring' the signal? It's a lot easier to track general amplitude than to sample audio for reproduction.
- RoosterMcNut
- Posts: 51
- Joined: Sun Mar 22, 2015 5:17 pm
Re: Micro Arduino with 3.5mm Audio Input?
Thanks for having a look at my question, Mike.
I'm using the analogRead() function to fire off certain tasks based on the magnitude of the sound signal. I've already built a working version of the hardware/software using an Arduino Uno and an audio shield but I'd like to shrink the footprint of the processor. That's why I'm looking for something around the size of an Arduino micro.
Does Adafruit make a micro-sized processor (or shield) with a 3.5mm audio input?
I'm using the analogRead() function to fire off certain tasks based on the magnitude of the sound signal. I've already built a working version of the hardware/software using an Arduino Uno and an audio shield but I'd like to shrink the footprint of the processor. That's why I'm looking for something around the size of an Arduino micro.
Does Adafruit make a micro-sized processor (or shield) with a 3.5mm audio input?
- adafruit_support_mike
- Posts: 67391
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Micro Arduino with 3.5mm Audio Input?
We don't have anything with a built-in audio jack, but we have a jack whose pins are on 0.1" spacing:
https://www.adafruit.com/products/1699
and the Feather 32u4 Basic has a prototyping area it will fit into:
https://www.adafruit.com/products/2771
https://www.adafruit.com/products/1699
and the Feather 32u4 Basic has a prototyping area it will fit into:
https://www.adafruit.com/products/2771
- RoosterMcNut
- Posts: 51
- Joined: Sun Mar 22, 2015 5:17 pm
Re: Micro Arduino with 3.5mm Audio Input?
Thank you for your reply, Mike. I already have both of the items you've linked to but I don't know how to make the connection properly and reference it with code.
I'm great at soldering and have already written code for monitoring an analog feed but I just don't know how to add on to a prototyping board like this. Can I just solder it anywhere it'll fit? How would I reference the port?
I really appreciate your help and patience!
I'm great at soldering and have already written code for monitoring an analog feed but I just don't know how to add on to a prototyping board like this. Can I just solder it anywhere it'll fit? How would I reference the port?
I really appreciate your help and patience!
- RoosterMcNut
- Posts: 51
- Joined: Sun Mar 22, 2015 5:17 pm
Re: Micro Arduino with 3.5mm Audio Input?
Over the past couple of weeks, I've read a lot of articles about how to hook up a 3.5 mm Audio jack to an Arduino. There appears to be no consensus and a ton of variations.
For example, some folks use 3 wires coming from the jack but most use two. Some folks say that you absolutely must use a resistor while other folks say that it's not at all necessary.
I've tried pretty much all of these variations but couldn't get any of them to work, which is why I wound up going with shields instead of hooking up audio jacks directly. I don't mind soldering and would love to skip the expense of purchasing an audio shield, if it's possible. If there's anyone here who can tell me how to wire at this audio jack to a prototype board, I would be tremendously grateful.
I've attached a picture here of what I'm guessing is the correct approach. I've never added on to a prototyping board, so this is a bit of a guess. I've got a green wire coming from ground and (hopefully) connecting to the left-outer pin on the audio jack. The red wire is going from (hopefully) the right-outer pin and connecting to Analog 3. I've done nothing with the middle pin on the audio jack. Is this correct?
Many thanks in advance for any help. None of the connections in the picture are soldered, so if I've done it wrong, no worries.
For example, some folks use 3 wires coming from the jack but most use two. Some folks say that you absolutely must use a resistor while other folks say that it's not at all necessary.
I've tried pretty much all of these variations but couldn't get any of them to work, which is why I wound up going with shields instead of hooking up audio jacks directly. I don't mind soldering and would love to skip the expense of purchasing an audio shield, if it's possible. If there's anyone here who can tell me how to wire at this audio jack to a prototype board, I would be tremendously grateful.
I've attached a picture here of what I'm guessing is the correct approach. I've never added on to a prototyping board, so this is a bit of a guess. I've got a green wire coming from ground and (hopefully) connecting to the left-outer pin on the audio jack. The red wire is going from (hopefully) the right-outer pin and connecting to Analog 3. I've done nothing with the middle pin on the audio jack. Is this correct?
Many thanks in advance for any help. None of the connections in the picture are soldered, so if I've done it wrong, no worries.
- Attachments
-
- Feather.jpg (22.45 KiB) Viewed 1364 times
- adafruit_support_mike
- Posts: 67391
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Micro Arduino with 3.5mm Audio Input?
The first thing you need to do is identify the signals on the plug that will go into the jack.
If you're using a standard tip-ring-sleeve audio plug, GND will be connected to the sleeve, which connects to pin #1 on the audio jack: dead center and offset from all the other pins. The ring will carry the right channel of an unbalanced audio signal, and connects to pin #2 on the audio jack: the pin farthest to the left when you look into the opening of the jack. The tip will carry the left channel of an unbalanced audio signal, and connects to pin #5 on the audio jack: the pin farthest to the right when you look into the jack.
For a cable carrying a single, balanced audio signal, the sleeve will still be GND, and the tip and ring will carry signals that go in opposite directions.
For the sake of vocabulary, an 'unbalanced' signal puts the whole waveform on one wire, and puts a reference voltage (usually GND) on the other wire. That usually means there's a DC offset from the reference voltage to the average signal voltage. Unbalanced signals are common in systems that have 0v-to-5v (or some positive voltage) supply rails.
A 'balanced' signal uses two signals with the same average voltage going in opposite directions. Each signal serves as a reference value for the other, and the actual signal is simply the difference between the two inputs. Balanced signals are more common in professional audio gear, and systems that have positive and negative supply rails.
For a cable carrying mono unbalanced output from a computer, GND is on the sleeve, the audio signal is on the tip, and the ring carries 5v which can be used to power the device being plugged in. That's where the "you must use a resistor" thing usually comes in.
Find out what kind of signal is coming though the cable, and from there you'll have more information about the connections you need.
If you're using a standard tip-ring-sleeve audio plug, GND will be connected to the sleeve, which connects to pin #1 on the audio jack: dead center and offset from all the other pins. The ring will carry the right channel of an unbalanced audio signal, and connects to pin #2 on the audio jack: the pin farthest to the left when you look into the opening of the jack. The tip will carry the left channel of an unbalanced audio signal, and connects to pin #5 on the audio jack: the pin farthest to the right when you look into the jack.
For a cable carrying a single, balanced audio signal, the sleeve will still be GND, and the tip and ring will carry signals that go in opposite directions.
For the sake of vocabulary, an 'unbalanced' signal puts the whole waveform on one wire, and puts a reference voltage (usually GND) on the other wire. That usually means there's a DC offset from the reference voltage to the average signal voltage. Unbalanced signals are common in systems that have 0v-to-5v (or some positive voltage) supply rails.
A 'balanced' signal uses two signals with the same average voltage going in opposite directions. Each signal serves as a reference value for the other, and the actual signal is simply the difference between the two inputs. Balanced signals are more common in professional audio gear, and systems that have positive and negative supply rails.
For a cable carrying mono unbalanced output from a computer, GND is on the sleeve, the audio signal is on the tip, and the ring carries 5v which can be used to power the device being plugged in. That's where the "you must use a resistor" thing usually comes in.
Find out what kind of signal is coming though the cable, and from there you'll have more information about the connections you need.
- RoosterMcNut
- Posts: 51
- Joined: Sun Mar 22, 2015 5:17 pm
Re: Micro Arduino with 3.5mm Audio Input?
Thank you very much for your detailed response, Mike. Using your info, I hope/expect to be able to hack this out.
Take care!
Take care!
- RoosterMcNut
- Posts: 51
- Joined: Sun Mar 22, 2015 5:17 pm
Re: Micro Arduino with 3.5mm Audio Input?
Thanks again for having a look at my issue, Mike. I've got a headphone jack hooked up but there's so much noise on the line that it's impossible to separate the data from the noise. I've attached a picture of how it's hooked up. I'm not sure why the picture is upside down here - sorry!
The only thing "wrong" with the picture is that I've got the power (red) cable going to the headphone jack pin that's 2nd from the left, not the furthest on the left.
In a nutshell, my setup is like this:
3.3V power comes from the FeatherWing (red cable)
Ground comes from either the center pin or the right-side pin nearest the center. The outcome is the same either way.
From there, I'm splitting the ground output between the Analog 1 port (via the green cable) and the FeatherWing's Ground (via the black cable).
If I don't add in a 10 ohm resister, I analog readings as high as 1032. If I add in the resister between the green and black cables, I get the values down to about 1-5 when hooked up to an iPhone and 1-40 when hooked up to an Alexa.
Either way, adding audio from those sources does not create any data values larger than what's produced as background noise. As a result, I'm unable to detect signal input from the audio sources.
If anyone can help me with this issue, I'd be tremendously grateful. I've been trying to solve this problem for weeks. It shouldn't be this hard to hook up an audio jack to an Arduino and I must be missing something. I'd even pay someone a nominal fee if they could provide a working solution to this issue.
Here's my code, fwiw:
The only thing "wrong" with the picture is that I've got the power (red) cable going to the headphone jack pin that's 2nd from the left, not the furthest on the left.
In a nutshell, my setup is like this:
3.3V power comes from the FeatherWing (red cable)
Ground comes from either the center pin or the right-side pin nearest the center. The outcome is the same either way.
From there, I'm splitting the ground output between the Analog 1 port (via the green cable) and the FeatherWing's Ground (via the black cable).
If I don't add in a 10 ohm resister, I analog readings as high as 1032. If I add in the resister between the green and black cables, I get the values down to about 1-5 when hooked up to an iPhone and 1-40 when hooked up to an Alexa.
Either way, adding audio from those sources does not create any data values larger than what's produced as background noise. As a result, I'm unable to detect signal input from the audio sources.
If anyone can help me with this issue, I'd be tremendously grateful. I've been trying to solve this problem for weeks. It shouldn't be this hard to hook up an audio jack to an Arduino and I must be missing something. I'd even pay someone a nominal fee if they could provide a working solution to this issue.
Here's my code, fwiw:
Code: Select all
int analogPin = 1;
int val = 0; // variable to store the value read
void setup()
{
Serial.begin(9600); // setup serial
}
void loop()
{
val = analogRead(analogPin); // read the input pin
if (val > 0){
Serial.println(val);
}
}
- adafruit_support_mike
- Posts: 67391
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Micro Arduino with 3.5mm Audio Input?
You shouldn't need a 3.3v connection to an audio jack. You just need GND and a connection to the contact that carries the audio signal.
Connect GND to pin 1 on the audio jack (center), then connect analog input A0 to jack pin 2 and analog input A1 to jack pin 5 (outer edges of the jack).
Read both A0 and A1 to see where the signal is.
Connect GND to pin 1 on the audio jack (center), then connect analog input A0 to jack pin 2 and analog input A1 to jack pin 5 (outer edges of the jack).
Read both A0 and A1 to see where the signal is.
- RoosterMcNut
- Posts: 51
- Joined: Sun Mar 22, 2015 5:17 pm
Re: Micro Arduino with 3.5mm Audio Input?
I really, really appreciate your time and advice, Mike. Thank you very much.
I tried your advice but with so much background noise, it's hard to tell if the new wiring configuration is working. For example, with absolutely nothing plugged into my Feather, I'm getting Analog readings between 0-135ish. Is it odd that I have so much background noise? It's making it impossible to detect line/audio readings.
For what it's worth, I've had similar results with other boards, such as the Uno. I don't think it's an issue with the Feather proto board, per se.
I've attached a screenshot of what it looks like with nothing at all plugged into the board.
I tried your advice but with so much background noise, it's hard to tell if the new wiring configuration is working. For example, with absolutely nothing plugged into my Feather, I'm getting Analog readings between 0-135ish. Is it odd that I have so much background noise? It's making it impossible to detect line/audio readings.
For what it's worth, I've had similar results with other boards, such as the Uno. I don't think it's an issue with the Feather proto board, per se.
I've attached a screenshot of what it looks like with nothing at all plugged into the board.
- RoosterMcNut
- Posts: 51
- Joined: Sun Mar 22, 2015 5:17 pm
Re: Micro Arduino with 3.5mm Audio Input?
I've found a number of posts online where people are reporting the same problem with background noise. Some of them are claiming that introducing a .1 uF decoupling capactitor will help.
I'm out of town at the moment but will report back with my findings in a few days.
I'm out of town at the moment but will report back with my findings in a few days.
- wernerXventer
- Posts: 7
- Joined: Tue Apr 11, 2017 3:29 am
Re: Micro Arduino with 3.5mm Audio Input?
Would also love to know how to just this...
Nothing fancy, is there audio or not
Nothing fancy, is there audio or not
- erumazeez
- Posts: 1
- Joined: Fri Aug 25, 2017 4:29 pm
Re: Micro Arduino with 3.5mm Audio Input?
Hello,
I just purchased the adafruit headphone jack and want to know how to connect it to an Arduino 101. I'm trying to use a breadboard to play a sample tone melody from the Arduino libraries that I want to hear with my iPhone headphones.
I have been looking online for instructions on how to do this, but found nothing. Please advise.
Thank you!
I just purchased the adafruit headphone jack and want to know how to connect it to an Arduino 101. I'm trying to use a breadboard to play a sample tone melody from the Arduino libraries that I want to hear with my iPhone headphones.
I have been looking online for instructions on how to do this, but found nothing. Please advise.
Thank you!
- tarbear123
- Posts: 74
- Joined: Sat Feb 17, 2018 5:10 pm
Re: Micro Arduino with 3.5mm Audio Input?
will the same hookup work with the 3.5 breakout board?adafruit_support_mike wrote:You shouldn't need a 3.3v connection to an audio jack. You just need GND and a connection to the contact that carries the audio signal.
Connect GND to pin 1 on the audio jack (center), then connect analog input A0 to jack pin 2 and analog input A1 to jack pin 5 (outer edges of the jack).
Read both A0 and A1 to see where the signal is.
Please be positive and constructive with your questions and comments.