How to read/send data using the Android Devices 3.5mm headset jack?
Asked Answered
H

2

30

I was just stumbling around EE Stack and found this post: What protocol does a headphone jack use. And it sparked some curiosity in me, and I figure, if the iPhone can do it, I want to as well.

Does any one know of any projects that are doing this now or whether or not it's even possible?

UPDATE

RIP

Homeopathic answered 28/10, 2011 at 15:44 Comment(9)
I'm confused, aren't these just analog signals down the cables? You can do whatever you want with them - only question is what?Sputter
Right, I know that. I'm wondering how do I read (or output) data? I haven't found anything in the documentation on handling TRS input (output).Homeopathic
Can't we use a MediaRecorder and carry out signal processing?Sputter
If I read the documentation correctly, I don't think so. As far as I can tell MediaRecorder can only receive data from that camera and mic. Not the TRS socket.Homeopathic
On that note, I think that AudioRecord may be the solution. I will look into it.Homeopathic
@AedonEtLIRA were you able to do this? I'm facing a similar problem now, can you please share how you managed to read data using the headset jack? #13594574Grose
@gameower I ended up dropping it. It was easier and cleaner to just use bluetooth. Wireless is also a plus.Homeopathic
I did not test, but is an interesting approach.Ellmyer
@Homeopathic Isn't Android TRRS?Limpopo
W
42

You are basically asking how to turn the microphone input into a modem input. A variant of this clever technique is used commercially by Square for their magstripe readers on both iOS and Android devices.

To do so requires getting access to the raw PCM stream from Android and decoding the input. Luckily for you, someone has already done it and thrown the source out there. See this Hack a Day linked project for sample Arduino and Android code for transmitting only.

I couldn't find example Android code to receive, but there are rather extensive notes on doing FSK with iOS in this Arduino forum post.

(Though it wasn't your question, an easier way to get data in and out of an Android device is the new USB Host and Accessory support. It requires a newish phone and OS, so not as flexible as the audio route.)

Whoop answered 31/10, 2011 at 16:21 Comment(4)
That is interesting to output 9600 baud data, but it does not address the reception of data.Preterite
Good point, I updated the comment. I was confusing it with another project (added link), which has iOS libraries.Whoop
Right, trust me, I definitely and heavily considered USB, but what I'm working on I would like to run on 1.6 or greater. Thanks for your input though, the article was good for the gander.Homeopathic
@KonstantinPribluda Right, the vast majority are 2.2/2.3 (including my test device). But both of those versions lack the USB Capability. Further, as far as I know, every device will have a 3.5 jack; not all are guaranteed to have a compatible USB device.Homeopathic
R
5

I've written a C library which can send and receive data through an audio cable at 64kbps. https://github.com/quiet/quiet

As far as modulation techniques, it supports a wide range, as it uses an SDR library to perform its modulation.

If you'd like to try it out, here's a live demo https://quiet.github.io/quiet-js/lab.html

Repine answered 30/3, 2016 at 18:26 Comment(1)
Cool, Thanks : Just to note for the "loop-test" demo on Windows make sure you disable sound effects on the microphone otherwise feedback cancellation will inhibit the reception of what is being sent through the speakers. Control Panel→ Sound → Change Sound Settings → Recording –> Properties –> Enhancements –> Check Disable all sound effects.Legation

© 2022 - 2024 — McMap. All rights reserved.