How difficult is it to turn an analog sensor into a USB device?

A lot of smartphones are losing their headphone jacks, which I think is the last remaining port that smartphones have for interfacing to the analog world. Now any kind of sensor, even a simple microphone, would need to go through the USB or Lightning port on the phone, which is entirely digital, right?

What are the general steps necessary to take, say, a simple photoresistor or microphone and turn it into a USB device?

Obviously you would need an A/D converter and possibly an amp of some sort.

A/D converters read the voltage of a signal, but what about a photoresistor where the resistance is read instead?

What about drivers that the Android, Windows, or Apple OS would use to run the device? Driver signing requirements?

Is it basically a huge can of worms?

Bluetooth is the intended replacement for such devices, not USB. You will find much better support for that.

aarg: Bluetooth is the intended replacement for such devices, not USB. You will find much better support for that.

What about in the case of audio? Audio signals like those from a microphone have the additional issue of very precise timing. The Bluetooth device would need to amplify the incoming voltages, sample them at 48,000 times a second at a 16-bit resolution, compress, and send out the data via packets. And the receiver needs to unravel all of that while still preserving the exact timing of the source audio. Do modern bluetooth chips automatically do all this for you?

What audio? Smartphones already have a microphone.

jremington: What audio? Smartphones already have a microphone.

Recording audio from an external, off-camera microphone is almost always superior in quality to using a recording device's built-in microphone.

Good to know, thanks!

Yeah, audio in particular presents a very particular set of problems:

  • External mics are pretty much mandatory for good audio quality, especially because mics must be placed as close to the audio source as possible to maximize the signal/noise ratio. As in "an inch outside of the frame of the camera" or "hidden inside the frame of the camera."

  • Mics output only millivolts, so amplification must be done and shielding from noise is a big consideration.

  • The pre-amps on cameras are notoriously noisy and can add a ton of background hum, so amplification of the mic signal should always be done off-camera.

  • Audio needs to be synchronous to the video source, or at least consistent in its latency. The process of A/D conversion, bluetooth compression, packet transmitting, packet receiving, decompression, and saving into the recording device can add lag, possibly even inconsistent lag throughout one audio file.

So... yeah.

But I think that turning the analog signals from the mic into digital as soon as possible is a good idea in terms of preserving audio quality since digital signals are much more tolerant of noise than analog signals.

What are the general steps necessary to take, say, a simple photoresistor or microphone and turn it into a USB device?

A photoresistor is super easy! (At least it's easy with a computer.... I'm not sure what's required to connect the Arduino to a phone.)

...Just add another resistor to make a [u]voltage divider[/u], then run some code similar to [u]Analog Read Serial Example[/u], and you're done! (The potentiometer used in the Analog Read Serial Example is a variable voltage divider.)

For audio you can get a microphone board which has a mic, preamp, and bias circuit. Or for line-level or headphone-level signals you an make a bias circuit (2 resistors and a capacitor) so you can read the negative-half of the signal voltage and you're good to go. (Of course you have to write some code to set the sample rate, etc.)

But, the Arduino can't sample fast-enough for "CD quality" audio and it only has a 10-bit DAC. And, it's not going to be seen as a soundcard by the computer, and the standard soundcard drivers are not going to work. Bottom line - You can't make a soundcard with an Arduino.

Recording audio from an external, off-camera microphone is almost always superior in quality to using a recording device's built-in microphone.

Of course, that would depend on the quality of the external mic... ;)

There are good stereo microphones and audio interfaces for the iPhone ([u]example[/u]). There doesn't seem to be as much for Android.