Simple schematics and implementation:
And now some software tips. For this to work it is recommended to have pre-generated data samples, mostly because of the timing.
In this case, raw binary data of serial ASCII packets (start bit, payload, stop bit). You might make them like this:
ofstream outfile;
char * buffer = new char [55];
// Start bit (low)
for (int i = 0; i < 5; i++) {
buffer[i] = 25;
}
// What you need here in binary (low is 25, high is 230), just remember to reverse the order!
// Stop bit (hight)
for (int i = 45; i < 50; i++) {
buffer[i] = 230;
}
outfile.open ("snd.raw",ofstream::binary);
outfile.write (buffer,55);
outfile.close();
Written for C, assuming the sound sampling frequency is 48000, because then one bit is 5 samples in length.
All of that produces this nifty image on the oscilloscope (blue being Schmitt trigger output and the yellow being serial output) :
Now to use it in an Android app:
- we need direct access to the PCM stream and a buffer to generate what we want to output from the pre-generated samples:
private static final Integer minBufferSize = android.media.AudioTrack.getMinBufferSize(48000, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT);
private final AudioTrack oTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 48000, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT, minBufferSize, AudioTrack.MODE_STREAM);
private byte[] sndBufferTrack = new byte[minBufferSize];
- next we need an array for the samples (because of the faster read access) and then to read them in:
try {
inputStream = getResources().openRawResource(R.raw.snd);
inputStream.read(sndSamples[0]);
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
//You'll all figure out how to do this for the rest 255 of them
- then we fill the buffer with the generated data and play it:
for (int i = 0; i < 50; i++) {
sndBufferTrack[i] = sndSamples[0][i];
}
oTrack.write(sndBufferTrack, 0, minBufferSize);
oTrack.stop();
oTrack.release();
And all of this, with right polarity, correctly generated samples and the right amount of volume finally produces consistent and mostly artefact's free data transfer:
Please, post all source code and LTSpice schematics. It is very help me.
ReplyDeleteSend me an email, since I'm disinclined to host files on the blog.
ReplyDeleteHi can u share source code..
DeleteActually i want to convert Audio data in actual data
comment != email
DeleteHi, Can you mail me the source code?
Deletekitsooftlk@gmailcom
Hello, i am also very interested on the source code.
DeleteMy mail is ingold.alvaro@hotmail.com
In addition to that, i would also like to know how to make it work the other way around, that is, to receive data in the headphone jack and digitalize it on the phone.
THANKS!
Hi, Can you mail me the source code?
Deletei have project read controller
email: khanhleviet.hut@gmail.com
hi, can you please share source code?
DeleteI`am working on a android project which tries to gather signal from
a 3.5mm jack , find your work might be useful
email:rayallen3001@gmail.com , thanks
Hi. I read this blog thoroughly.
DeleteBut I could not your email, where is it?
I would like to your source codes, please send me those.
(mhbae@utarex.com)
Thanks for your working.
If this works for my band, you'll surely be credited.
Deletepageau4@gmail.com
Very cool! Thanks for sharing this. I wonder if some simple checksum or some error correction code algorithm would make it 100% artifact free?
ReplyDeleteHi,
ReplyDeleteI've been searching for days, would you please email all source code and LTSpice schematics to my email...
ramyalisawi at hotmail point com
I also would love to see all of the source code schematics for this. If you could email me that would be great. Thank you very, very much.
ReplyDeleteghast09 at hotmail dot com
I was wondering if you have tried to get serial communication both ways. I'm trying to get serial input to the android using the microphone input but am having trouble. Did you attempt to try serial to the android and do you have any suggestions. thaaanks
ReplyDeleteI'd love to check out the source code if you would email it to me. It's tyresume at gmail dot com. I've written a fun app to remotely open my garage door via bluetooth and and have some other ideas for remotes but the range of bluetooth is too short. I'd love to implement what you have. Check out my video if you like.
ReplyDeletehttp://www.youtube.com/watch?v=Ec4xj1VBrlo
If you dont mind, can you send it to me too? thanks! my email is edfungus at gmail dot com
ReplyDeleteHey! Very cool!!
ReplyDeleteI´ve tried to do this some months ago, but I had timing problems caused by audio-generation on the android device. Atm I´m using the Bluetooth-Module "btm-222" but I would prefer your solution.
Can you send me the android-project and if possible the C-Code, too?
Thank You!
my e-mail is janr.desire at googlemail dot com
ReplyDeletewhere is the source ??
ReplyDeleteyou can send to my email?
ricardo.jl.rufino@gmail.com
could you forward the source my way as well. Your help would be highly appreciated. Thanks.
ReplyDeletechhabra.abhin at gmail dot com
Again, thank you very much.
Very impressive. Could you send me the source code and schematics, it is very help for me.
ReplyDeletepqqoeh@gmail.com
Thanks for sharing..
This is very cool, I was just wondering if it was possible. Please send the source code and schematics.
ReplyDeletebirkebjerg|gmail.com
Hi... I've been searching a solution like this for days. Please send the code and schematics to: fbayoff@newlinebuilders.com
ReplyDeleteThanks.
Hello! You have an awesome post here. Can you please send me the complete source code? pdrocb@gmail.com
ReplyDeleteThank You!
If you are still around and able, I'd love for you to send me the source code as well please?
ReplyDeleteThanks.
Picmes@Yahoo.com
Hello, would you please send me the source code & schematics to: crabryan@ gmail dot com
ReplyDeleteThank you very much!!!
Hi, Please share me that source code: nguund@gmail.com.
ReplyDeleteThank you so much!
Hi. Nice Work! Really useful for dummies like me! Pls mail me the source: mahesh.bsb@gmail.com
ReplyDeletePlease mail me the Schematics and full source code
ReplyDeleteI need this for my project of android based robot
my email : zubairbh@gmail.com
www.mzubair.com
would like the source, too!
ReplyDeleteaschapupaya[at]gmx.de
interested in source code and schematics
ReplyDeleteandrea.manzato92@gmail.com
I want to read the audio jack(as in squareup)
ReplyDeleteConnect the input data line to microphone connector on the jack. Then record the input and demodulate it.
Deleteinput data line?
Delete"input data line?"
DeleteYes, the line which contains the data from the device you want to read trough the audio jack.
How will I set MediaRecorder.AudioSource as audio jack?
DeleteWow, awesome post, hey could you please send me the source code at sanjupahari at gmail dot com please.
ReplyDeleteCommendable job friend
A beer on me, let me know how to send
Please send me the source code and schematics vinartrulz@gmail.com
ReplyDeleteappreciated...
I would also love to have the source code and schematics, if you wouldn't mind. This would be perfect for a project I want to work on. Thank you!
ReplyDelete(Email to dylandroid.20.trauts@xoxy.net )
Please email Source info@greenbox.lv . Thank you!
ReplyDeleteHi, looks like a great project.. can you please email me the source too, looking forward to experimenting with it.
ReplyDeleteavireider@gmail.com Thanks!
Ohh great example. Please email me the source to try with this one. ricardo.castro.rada [at] gmail.com
ReplyDeletePlease, send source code to risele0@gmail.com
ReplyDeletethanks!
Very cool! Great sample.
ReplyDeleteCan u please email the source code and schematic to me?
chanlokchuen@gmail.com
Can you please email the source code?
ReplyDeletehitesh24by365@gmail.com
Great Work!! Exactly what i search to begin my project.
ReplyDeleteCan you email the source code?
svenh817@gmail.com
Thank you.
This is Great!, Can you please email the source code and schematic.
ReplyDeleteikash.malik@gmail.com
Love You.
awesome work. please mail me the source code..
ReplyDeleteat neelkanth.jha@gmail.com
Wow! Very nice!
ReplyDeleteCan I get your code and schematic?
suwangjang@gmail.com
Thank you!
hi,
ReplyDeletei'm trying to do something similar, just the other way round (audio in on android, get digital data from analog audio stream).
could you send me the source-code?
herbert.hartkor@gmail.com
thanks,
lukas
Wow! Very nice!
ReplyDeleteCan I get your code and schematic?
aruncheela@gmail.com
Thank you!
intresting I like to view your code too
ReplyDeletem.heydar.elahi@gmail.com
It is very interesting! Could you share the the full source code?
ReplyDeletejasher.itzarel777@gmail.com
Thanks!
looks amazing!
ReplyDeletelove to have the source and schematic :)
eman4489@gmail.com
I'am doing same kind of project. Can you send me source and other nessasary details. (like how to make that circuit....)
ReplyDeleteThanks in advance..
my mail is : isharafe@gmail.com
Hi, I am suffer on this issue, and would like to learn from your source code. could you please mail your source code.
ReplyDeleteThanks in advance,
my mail is tonylu880042@gmail.com
Can you please email the source code and schematic?
ReplyDeleteedsonbysat@yahoo.com.br
Can you please email the source code as well?
ReplyDeletegrasserlaurent@gmail.com
Nice work and really great idea!
ReplyDeleteCan you please email the source code and schematic?
rtrampenau@gmail[dot]com
Nice work
ReplyDeletecan you please email the source code and schematic to me?
nlalitn@gmail.com
Please send me the source code, thanks.
ReplyDeleteI am just wondering that you allocate a buffer with length 50, but tried to generate a snd.raw with length 55. `outfile.write(buffer,55); `. Is it a typo or I missed something? I'd be very appreciated, if you can share the source code with me (sx.away[at]gmail.c0m)
ReplyDeleteVery cool, I am trying to get data from Android phone jack, but it's not easy to get the right frequency of input data. Could you send me the source code to refer if you don't mine? My email is up2uhclg@gmail.com.
ReplyDeleteMany thanks!
Tom
Very nice piece of work! I've been looking for a way to hook into the android's mic and headset. Have you tried going the other way. That is data into the mic jack? Could you send schematics and source. I really appreciate it. My e-mail is bishop.ellison at gmail.com.
ReplyDeleteMany Thanks,
Bishop
Please can I have circuit and source as it looks interesting.
ReplyDeleteThanks.
Please e mail me bobbybuilder90 at gmail dot com
Hi, could ypu please shere the source via azakalyukin@gmail.com ?
ReplyDeleteHello, would you please send me the source code & schematics to: blueberry.org.in@gmail.com
ReplyDeleteThank you very much in advance!!!
Hi Jernej,
ReplyDeleteI know you posted this some time ago, but I'm hoping you still monitor this post and respond to questions. As, I'm really interested in giving this a try and want to try to adapt it to work with Arduino.
Could you please email me the schematic and source? lukegmATgmailDOTcom
I also have a few questions mostly about the schematic, which I hope you'll have the time to answer:
- Is the serial connection duplex (in both directions) or is it only Android to PC?
- Are V1 & V2 are the headphone socket/s? If they are input & output, which is which?
- There appear to be 2 headphone sockets on your board (V1 & V2?), 1 at the bottom of the photo and the other at the top next to the 9pin Dsub (serial port). Is that correct or am I a bit confused?
- If there is a second headphone socket, why didn't you use either the second channel or microphone connection in the first one? Or did not have a 4 pole socket lying around, so you've used 2 and then joined them in the cable?
- What component/s did you use for U1 & U2?
- Lastly, on schematic it looks like there is only a single connection going to the PC serial port, not even ground/common. Is that correct?
Thanks in advance for taking the time to answer my questions, I hope I haven't taken too much time out of your day.
Regards
Lukegm
Hey there Jernej,
ReplyDeleteI too hope you are still keeping up on the blog and would love to take a look at your code for this project. My email is nickcres13@gmail.com. Thanks a bunch!
Peace from ukraine. Need sources and schematics to see how abroad colegue works =) progressman757@gmail.com
ReplyDeleteHi! Nice work! Could you please send me the source code & schematics to: neuronea.development [at] gmail dot c0m ?
ReplyDeleteHi Jernej,
ReplyDeleteAmazing work! I would be very glad if you could send the source code to my mail: shahaf.bassan@gmail.com
It would help me very much on a project I'm currently working on.
Thank you very much!
Hi Jernej
ReplyDeleteNice work and really great idea!
If it is possible, could you send me the source-code?
minsus79@gmail.com
thank you very much
Hey Jernej!
ReplyDeleteReally cool stuff here. I know its been a while but if you can, could you send me the source code? It would help a lot with a project that I'm currently working on!
jimmy.lee.chen@gmail.com
Thanks so much!
hi, hope you still see this. this is a very cool stuff. could you please also send me the code and schematic? many thanks.
ReplyDeleteansonchan911@gmail.com
hi can you send me the source code it'll be a real help to me
ReplyDeletesaeeid.ehsani@gmail.com
Hey Jernej!
ReplyDeleteCan you send me the source code it'll be a real help to me. Thanks so much!
Rostislav_tt@mail.ru
Thanks for such a wonderful and brilliant idea....please if possible send me the code and schematics
ReplyDeleteEmail: davies.segera@gmail.com
This comment has been removed by the author.
ReplyDeleteHi,
ReplyDeletePlease, send to me source code, it will be a real help to me. Thanks so much!
tunguyen90vn@gmail.com
This comment has been removed by the author.
ReplyDeleteHi nice Project, I would like to have the source code and schematics to create a project that saves the output to an audio file julio7k (at) gmail (dot) com
ReplyDelete