Electronic – Sending data using 4 pin 3.5mm jack into smartphone


I have been looking around for some time and haven't found helpful information on how this is done. I am working on a project that intends to send data through the headphone jack to be processed by a smartphone. More specifically, I want to measure the temperature of water using an IR sensor. The voltage of the sensor will be sent to a smartphone where it can be analyzed to tell me what the temperature is. Is this a feasible idea?

I don't know too much about how 3.5mm connectors work on smartphones so links would be helpful as well. I know this is a vague description of the project and I'm just looking for some sources to steer me in the right direction. The project requires the usage of the headphone jack on smartphones so I can't use USB.

Side note: I am a novice undergrad engineer that might be in over his head.

Best Answer

It shouldn't be too hard to solve this problem in a way which is fairly platform-agnostic and flexible across the possible variations of your application need.

First, you need to find a circuit for injecting an audio signal into the headset jack; as headsets with wide compatibility (iphone, most android devices, and probably more) are available on the market, this is clearly possible. I believe it has been covered here before.

Then you need a means of data transmission which is easy to implement, and which is fairly immune to variations in the phone model, components, temperature, etc.

Trying to send an analog voltage level directly would likely not be - the phone (or at least input circuit you use) will likely block DC, and even if it does not you have a hard time knowing the precise gain on the phone's input circuit.

So something which encodes information over time is probably going to work better. A simple solution would be a voltage-to-frequency converter, or voltage-controlled audio oscillator. By producing a tone with a frequency proportional to your signal, and then measuring the strongest frequency in software on the phone, you'll have a fairly reliable system. It will be somewhat subject to the accuracy of your modulator though - for example, if you hack something up with a 555 it may depend on non-precision capacitors whose value varies from example to example and over temperature.

Another option to look at would be a digital modem - for example frequency shift keying. You could simply pull the specs for a 300 baud telephone modem and approximate such a signal with a square wave output from a little processor such as an ATtiny, PIC, MSP430, etc, using the processor's ADC to read the sensor and come up with a number you want to encode. If you don't need to take measurements very quickly, you could lower the baud rate still further and make the decoder easier to write.

In summary, by modulating some aspect of the signal such as frequency which is less subject to device-to-device variation, you can build a system which will be fairly universal - only requiring that you create a build of your demodulator software which can be linked into the structure of a basic audio record-to-buffer type application in the SDK of each type of phone you want to support.

Related Topic