Interfacing android and arduino through an audio connection.

Friday, 5 August 2011

System Architecture

This project aims to build an Arduino-powered interface to get data from any real-world, analog sensor into a smartphone (Android device) using the audio port as the communication channel between both platforms.

Sensor: obtain some values we want to know, they can be temperature, pressure, humidity, amount of light... These values are related to a voltage, a continuous value that is measured in certain periods of time.

We can measure current temperature of the environment using a simple temperature sensor LM335 and an Arduino with the help of a small circuit and a simple Arduino code.

Arduino: the values generated from the sensor are modulated by the microcontroller, using ADC. Using an Arduino library called SoftModem, I am able to configure the microcontroller in order to obtain a FSK modulation of the values. Wherein data bits are communicated by modulation and demodulation — basically encoding data in specific audio tones sent over an audio channel. Some of you oldsters might remember the weird sounds emanating from the early telephone modems? That was FSK

With this what we obtain is an analog signal related to the value from the sensor, this is the modulation part.

Now we want to work with this signal in our mobile device, as we already decided and commented here, this is going to be done through the audio port. That's why we need and are going to use the Softmodem board, which allows us to connect the arduino board and our mobile device with an audio jack cable.

Five terminals to connect to the Arduino (FSKOUT · GND · VCC · FSKIN · AIN) has been equipped with a pin jack plug into the 3.5mm plug 4 poles for connecting to a cellular phone.

Using compatible FSK libraries on both the Arduino side and the Android side, we can actually accomplish bi-directional communication between our sensor rig and our mobile device. The Arduino gives us the onboard computing power to be able to both write and read data using FSK. As a first example, we’ll try to establish a unidirectional connection, sending data from the sensor to de Android device only. Still, we need to do FSK on both the Arduino side (modulation, or encoding the sensor data as audio) and the Android side (Application) (demodulation, or decoding the audio as data). So, all the raw materials are here for a bi-directional connection.

We need to decide in which frequencies we are going to encode:

This library is setup to encode data in shifts between audio frequencies 4000Hz (LOW) and 8000Hz (HIGH).

First, you need the sensor, Arduino and supporting circuitry for gathering data. For this we connect the sensor which will feed the Arduino.

You will also need to build some simple circuitry and load some code onto the Arduino.

Final objective: Android device <- (softmodem)->Arduino<-(rs232) are communicating said configuration->PC.

1 comment:

  1. Great explanation. Could you provide more details on the android library for demodulation?