Interfacing android and arduino through an audio connection.

Tuesday, 27 September 2011

Finally it worked!

Finally I could establish Serial Communication using audio between Arduino and an Android device.  This can be done thanks to the FSK modulation, when the data '0 'is a low frequency carrier, when the data '1' will send a high-frequency carrier.


The communication is biderectional, it can go from the Arduino to the Android device and vice versa. When you start the application, it is ready to be sent and received in ASCII mode. The data received is stored in a buffer and then will appear on the screen, there is no real-time display.
After stablishing the communication in both ways, I decided to obtain real data from real world, so I decided to measure the temperature of my workroom.
I connected a thermistor to one of the Analog input pin in the arduino and using the data it obtains I am able to read them in my Andorid device through the audio port. The speed of communication I get is around 315 bps, it is not to much, but for the moment it is enough for the data I'm testing. In a future I will try to increase the amount of data I can send.



9 comments:

  1. congratulations and thanks for sharing :)
    I'd like to give it a try myself as well, but there is something I don't understand:
    the terminal window shown in the picture above is running on android right? which app is this? where do you get the .apk?
    could you give some more details on your setup?
    thank you!

    ReplyDelete
  2. Hi,
    great work, and thanks for sharing!
    How can i get the .apk?
    thanks

    Mat

    ReplyDelete
  3. ... or if the code is free, where can I get it? :)
    Thanks
    Mat

    ReplyDelete
  4. what you are asking me will be published when everything is complete, at the end of january.

    Thanks

    ReplyDelete
  5. Hi,

    This is really interesting and I would also like to see the source code at some point. Is there a chance you could give a bit more information before January?

    I'm really stuck on how to demodulate the sound within Java/Android!

    ReplyDelete
  6. AudioRecord(MediaRecorder.AudioSource.MIC, AUDIO_SAMPLE_FREQ, 2,AudioFormat.ENCODING_PCM_16BIT, AUDIO_BUFFER_SIZE);

    AudioRecord.startRecording();
    AudioRecord.stop();

    ByteBuffer.wrap(audioData, 0,audioData.length);
    buf.order(ByteOrder.LITTLE_ENDIAN);
    ByteBuffer.getShort();

    Look information about this functions and classes

    ReplyDelete
  7. bookmarked so that when (if?) i get an android phone i can hook up my Arduino + interface. Thnaks

    ReplyDelete
  8. Source code will be available soon and we expect to release a library in the first week of January.

    ReplyDelete
  9. Hello Alberto! I already have my softmodem :) but I'm having troubles building the project :S Can you plz help me. Do you have the source code for the android aplication? Thank you!

    ReplyDelete