Arduino analogue input from headphones

analogarduinovoltage

I want to use the electric signal from the headphones (2.5mm) of a NOKIA E51 phone as an input to Arduino. My intention is not to process the audio signal but rather to be able to detect when there is a signal, specifically to detect when the phone rings. I want to use this to activate an elektromotor by calling the phone. I am new to arduino so I would like to know to adjust the proper voltage levels so they can be used as an analogue input. Suggestions to what circuits should I use wold very much be appreciated.

Thank you!

Best Answer

I think we've established your question is 'how to connect a cell phone headphone jack output to an Arduino analog input'. Not the question written as "Arduino analogue input from headphones". However, you can do what you are asking to do either way. By direct connection or by using a headphone element as a dynamic microphone.

So to give an answer to your question as written, I would suggest you can use the element of a magnetic ear bud style headphone as a small microphone, connected to your Arduino analog input, if you placed it directly over your cell phone speaker. If the phones ring tone is selected to produce a sound output that is loud enough and at a frequency that is in the sweet spot of frequency response of your ear bud, you will get signal out of the ear bud you can use. as for adjusting your signal level, you can simply adjust your volume control to get an output that is safely in the 0-5 volt input range of the Arduino's analog input.

Not the cleanest implementation but workable as one approach. I will suggest some finer points and refinements below that will apply to either approach that would make things work better after I address the direct connection approach next.

Likewise, a direct connection, (connecting the cut off headphone wires from the phone to the Arduino analog input) will get you your signal. As this will produce significantly more signal amplitude, I again caution you about exceeding the 0-5V input range. (there a number of ways to limit this signal with circuitry like a diode clamp or zener diode clipping, or a resistor voltage divider,etc.) but this is beyond the direct scope of this question, so I'l assume you will use the volume control method to limit your input level.

That basically covers your question...

Now for those refinement suggestions I promised.

Since the signal of a ringtone can be any wave shape of the sound you happen to select as your tone and it may be quite complex and have many different frequency characteristics.

I would recommend a couple things:

  1. Go find yourself a sine wave tone at a reasonable frequency that your phone output can reproduce. (typically 300Hz-3Khz works well for phones) Use that as your ring tone sound.

  2. Although you can digitize that waveform directly,and get a signal you detect the presence of for triggering your motor control event, the output of your signal will look like a series of random numbers depending on the frequency of your tone and the sample rate of your software loop.

If you'd like a a more consistent number value for your signal to compare against your trip point (motor trigger threshold), I would suggest you should rectify your now sine wave signal into a DC voltage value. (You can do this using a single half wave rectifier circuit with a single diode and capacitor, or a full wave rectifier circuit and capacitor, etc...) This will produce a voltage value that will be more or less consistent when digitized, and that can be adjusted with your volume control to a comfortable number for your input preference. ( keep in mind you will have to make sure you have sufficient voltage amplitude to over come your diode forward voltage drops to get any out voltage across you capacitor. For most small signal Silicon diodes like a 1n4148 or 1n914 that will typically run .6-1V. you'll need to make sure you have a few volts output. (Due to this voltage drop, you may not be able to use this for the first 'headphone as a microphone' example above)

  1. (And thirdly!) If you've gone so far as to create a DC voltage you can either adjust it to look like a logic input level, or better still, you can add a transistor logic level buffer circuit to ensure only a logic output ( 3.3-5V) can be passed to your Arduino input, you can use a logic input instead of an analog input for your trigger.

This has the advantage of not having to digitize and compare the input against a threshold value at all. It's now either High or Low logic state driven. Motor On, Motor Off.

Coding that will be easy, concise, and fast. Should be very robust and work constantly for you.


OK, quick recap... I'd recommend:

Direct connect cord to circuit With a sine wave ring tone waveform (300Hz-3KHz). Rectified through a diode(s) into a capacitor. Volume adjusted to get a DC value in range of 3.3-5V DC. Which I'd use as input to a logic buffer ( inverting or non-inverting, simple transistor or FET circuit will work nicely). and use the logic output of the circuit as your Logic input to to your Arduino instead of digitizing the analog signal.

Hope you found this helpful.

I'm not a regular poster on this site but stumbled on your question and had some time to kill. If you have further questions about my answer I may not be able to respond but I'm sure many will be able to comment or help with implementation details. You should be able to find all the simple circuit information I've described online, and you can build some version of what I've described with as little as 5 to 10 components, (including your cut off headphone cord)

Good luck!