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 [50];
// 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
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.