Background
Keywords: iPhone, RS232, Serial Port, Audio Port, Android, Mobile phones.
These days mobile PDA phones are becoming widely available for reasonable prices. Such mobile devices usually have a good embedded OS and many connectivity options viz, Bluetooth, USB, Infrared, Wifi etc. Even then, making use of these connectivity options in a simplified way is almost impossible. One needs to have specialized tools and software to enable applications to use these features.
I always wanted a capability to transfer data from/to an electronic computing device using simple serial port or any other such connectivity option. Surprisingly simple serial port option is either not available or purposefully hidden from user access.
After searching for such options, I found that the only port available with easy user access is the Audio port. So I searched google to find if anyone has ever done such kind of data transfer over Audio port. That's when I came across this guy,
http://www.perceptdev.com/labs/content/iphone-rs232-1200-baud-no-jailbreak-required-using-20-sdk
The approach used by him is quite simple, FSK, which gives approximately 1200 baud.
Hmm, nice. That shows its possible to perform data transfer using Audio Port, with additional hardware. Since I have good experience with microcontrollers, I decided to seriously pursue this option.
Today almost all electronic devices with Audio and/or Video capabilities have an audio jack or audio port to facilitate connection to earphones or amplifier systems. Almost all mobile phones have an audio jack. Now, this sounds to me like a pretty good solution to devote my time to.
Audio Port Basics
Audio output port is primarily used to output sound signals. Usually the signals are bipolar.
Inside the electronic devices, the audio output is usually generated by a DAC (Digital to Analog converter) in combination with audio amplifier and filters. The output could be mono or stereo.
Audio input port is usually in the form of mic (microphone). Again this could be mono or stereo input. The electrical signals for this input have to be more attenuated. Its easy to damage the input port, if proper care is not taken.
For more information on audio electrical signals, refer to the wikipedia,
http://en.wikipedia.org/wiki/Line_level
Hardware Scheme
The design of my audio serial port is based on standard RS232 protocol. I am using the Audio output (Line-out) port as serial transmit from mobile phone to my microcontroller. The mic input (Line-in) port acts as serial receive from microcontroller to mobile phone.
A level converter is used to convert the bipolar signals to unipolar levels. This can be achieved by simple circuits as given in the following link,
http://www.wenzel.com/documents/waveform.html
The microcontroller implements a software UART (polling method) to read the serial bits from TX pin. Similarly the microcontroller outputs the serial data to the microphone input after sufficient attenuation.
Software Application
Basic understanding of wave file format is required in order to successfully implement the standard RS232 protocol over Audio channel. Briefly speaking, the wave file consists of individual audio samples with 8-bits per sample, output at a specified sampling rate, usually 44100 Hz.
In order for the microcontroller's software UART to understand the serial data, we need to play the wave file at a specific rate corresponding to the Baud-Rate of the serial port. Usually the serial port settings are given by 8N1, 9600 baud for example. Where 8 = Number of bits per character, N = No parity bit, 1 = Stop bit. The 9600 baud rate (bits per second) is considered common for slow connections. The most important piece of information is the baud rate, if this is not matched properly in the software UART and in the wave file creation then the microcontroller will not receive proper data. It will receive garbage.
Once the data is read successfully in microcontroller, it can be forwarded to a proper serial port peripheral to achieve connectivity with a Computer or other such device which has a dedicated serial port.
I was successfully able to perform data transfer between my iphone and microcontroller using this approach.
I hope this piece of information will help all those who wish to perform simple data transfer between a mobile phone and microcontroller, and who have the required skills to make a simple piece of hardware.
Enjoy!!!
(Patents are a bane for Human development. Its for people who are scared of competition and shield for weaklings. Lucky there were no patents when the Wheel was invented, otherwise most of us would have still been in stone-age)