Interfacing android and arduino through an audio connection.

Saturday 10 December 2011

Bidirectional communication implemented

The prototype implementation is completed. The system can communicate android with arduino in both directions. This poor quality video show the prototype sending and receiving a message.


Source code will be published soon.

Thursday 3 November 2011

Androino is already Playing!!!









Next Step: Link Android & TicTacToe using Jack modem for Android

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.



Monday 12 September 2011

Demodulation in Android device (II): Reading sound.

After being ablo to record sound with the LG-GT540, I needed to read the data that I obtained from the MIC.

In order to do this, I used the ByteBuffer class:

public ByteBuffer wrap (byte [] array, int start, int byteCount)

Creates a new byte buffer by wrapping the given byte array.
The new buffer's position will be start, limit will be start + byteCount, capacity will be the length of the array.
 
Parameters
array the byte array which the new buffer will be based on.
start the start index, must not be negative and not greater than array.length.
byteCount the length, must not be negative and not greater than array.length - start.
Returns 
     The created byte buffer.
 

public abstract short  getshort()

Returns the short at the current position and increases the position by 2.
The 2 bytes starting at the current position are composed into a short according to the current byte order and returned.
Returns
      the short at the current position.
ByteOrder class:

public static final ByteOrder LITTLE_ENDIAN

Little endian means that the first byte (lowest address) is the least significant, and the last byte (highest address) is the most significant.

With all these classes and functions, I was able to analyze what I recorded.



Friday 2 September 2011

They are here!!

After one month waiting for it, I already have here my Audio Jack modem for Android (and iPhone).   
   
                                                 



With this board, data communication between Arduino and Android become possible . The communication speed is 1225bps. It is suitable for a small amount of data communication like switch inputs and sensor information.

The audio jack is included in this kit but not pre-soldered. Also, you may need a pin header or a pin socket to this board. But neither pin header nor pin socket is included, so you have to prepare it by yourself. 

Disclaimer

* Because data communications with this device uses audio, data corruption may occur sometimes. I consider incorporating checksum processing and retrying.
* Please set the device's volume maximum.

Connection

Please use gold plated shielded cables. The shorter the cable, the better. In order to minimize the communications error


Connect to Arduino as follows (right side is the Arduino's pin.)
FSKOUT → D3
GND → GND
VCC → VCC
FSKIN → D6
AIN1 → D7

Volume Adjustment

Measure the voltage on AIN1 with tester to make it (VCC / 2) + 300mV.
5V VCC: 2.7V AIN1
3.3V VCC: 1.95V AIN1

Thursday 1 September 2011

LG GT540 is alive!!!

After trying to use LG official software in order to upgrade my GT540, I had some problems as I already wrote down here. That's why I decided to use the KDZ UPDATER, in the next lines I will explain how I could make it:

Issues to consider:
  • I will NOT take responsibility for possible errors that could affect the device.
  • I suggest to back up every app, docs, contacts...
Steps:
  1. Download the firmware, you can choose from this list. I used and suggest: V20A
  2. Download and extract the KDZ UPDATER ENGLISH.
  3. Download and install the LG GT540 driver from offical website.
  4. LG GT540 -> Settings->Applications->Development-> Enable USB debugging.
  5. Settings->SD card & phone storage->Disable Mass storage only.
  6. Connect your LG to your computer with the USB link.
  7. Execute KDZ_FW_UPD.exe and select 3GQCT.
  8. Look for the archive KDZ that we previously downloaded and press the long button down there.
  9. The GT540 will star a process that might take for 5 minutes, the device will be set up in Emergency Mode several times, but don't worry about that. You don't need to do anything. DON'T TRY TO DISCONNECT THE DEVICE, DON'T INTERRUPT THE PROCESS, DON'T SHUTT IT OFF. Once it finishes the proecces it will be restarted by default. It will be like the first time you used it, like if it were recently made.
  10. KDZ Updater will anounce that the process is over, so here is when we can disconnect the GT540,
Links:
  1. lg.clubmobile.es
  2. android.modaco.com

Wednesday 31 August 2011

Upgrading LG gt540

As I wrote before, I had some problems during the upgrading of my LG gt540, while I was updating it my computer stuck and then I couldn't restart the device.
One solution for this trouble:

1. Unplug USB
2. Remove the battery
3. Hold the volume down button (LHS of phone) and reinsert USB lead at the same time
4. I then re-ran the update program.

LG Program Download
USB Driver Download

When you install the update be patient!!!!!! It takes forever

Wednesday 24 August 2011

Demodulation in Android device (I): Recording sound.

First of all, what I have to say is not everything goes ok at the first attempt, I'm telling this because I decided to upgrade my LG gt540 to 2.1 Android version, but something went wrong during the process :(

While I was updating it, my computer stuck so I had to restart it. Then I tried to power on my LG device and never came back on again, I could only see the LG logo. That's why I need to reboot my device, but I don't think this take my long time because there is a lot of information about it on the internet.

Well, while I try to fix this accident I'm working on how to demodulate the signals from the arduino in an Android device.

I'm trying some classes in API Level 3:
1. AudioRecord:
The AudioRecord class manages the audio resources for Java applications to record audio from the audio input hardware of the platform. This is achieved by "pulling" (reading) the data from the AudioRecord object. The application is responsible for polling the AudioRecord object in time using one of the following three methods: read(byte[], int, int), read(short[], int, int) or read(ByteBuffer, int). The choice of which method to use will be based on the audio data storage format that is the most convenient for the user of AudioRecord.
Upon creation, an AudioRecord object initializes its associated audio buffer that it will fill with the new audio data. The size of this buffer, specified during the construction, determines how long an AudioRecord can record before "over-running" data that has not been read yet. Data should be read from the audio hardware in chunks of sizes inferior to the total recording buffer size.

public AudioRecord (int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes)

int audioSource: MIC
int sampleRateInHz: he sample rate expressed in Hertz. 44100Hz is currently the only rate that is guaranteed to work on all devices
int channelConfig: CHANNEL_IN_MONO is guaranteed to work on all devices.
int audioFormat: the format in which the audio data is represented. PCM 16 bit per sample. Guaranteed to be supported by devices.
int bufferSizeInBytes: getMinBufferSize
1a. getMinBufferSize

public static int getMinBufferSize (int sampleRateInHz, int channelConfig, int audioFormat)

Returns the minimum buffer size required for the successful creation of an AudioRecord object. Note that this size doesn't guarantee a smooth recording under load, and higher values should be chosen according to the expected frequency at which the AudioRecord instance will be polled for new data.
  1. AudioTrack
The AudioTrack class manages and plays a single audio resource for Java applications. It allows to stream PCM audio buffers to the audio hardware for playback. This is achieved by "pushing" the data to the AudioTrack object using one of the write(byte[], int, int)and write(short[], int, int) methods.

public AudioTrack (int streamType, int samplieRateInHz, int channelConfig, int audioFormat, intBufferSizeInBytes, int mode)

int streamType: STREAM_MUSIC
int samplieRateInHz: 44100
int channelConfig: CHANNEL_IN_MONO
int audioFormat: PCM 16 bit
int bufferSizeInBytes: getMinBufferSize
int mode: MODE_STREAM

Monday 22 August 2011

Nice find: Getting source code from an APK file

Mr.Wizard and prankul garg:

"procedure to decoding .apk files---step wise method-->

step 1:

make a new folder and put .apk file (which you want to decode) now rename this .apk file with extension .zip (eg:rename from filename.apk to filename.apk.zip) and save it..now you get classes.dex files etc...at this stage you are able to see drawable but not xml and java file...so cont...

step 2:

now extract this zip apk file in the same folder(in this eg or case NEW FOLDER). now dowmload dex2jar from this link http://code.google.com/p/dex2jar/ and extract it to the same folder (in this case NEW FOLDER).....now open command prompt and reach to that folder (in this case NEW FOLDER)....after reaching write "dex2jar classes.dex" and press enter.....now you get classes.dex.dex2jar file in the same folder......now download java decompiler from http://java.decompiler.free.fr/?q=jdgui and now double click on jd-gui and click on open file then open classes.dex.dex2jar file from that folder...now you get class file...save all these class file (click on file then click "save all sources" in jd-gui)..by src name....at this stage you get source...but xml files are still unreadable...so cont...

step 3:

now open another new folder and put these files

  1. put .apk file which you want to decode

  2. download apktool using google and put in the same folder

  3. download framework-res.apk file using google and put in the same folder

  4. Open a command window

  5. Navigate to the root directory of APKtool and type the following command: apktool if framework-res.apk

  6. apktool d "fname".apk ("fname" denotes filename which you want to decode)

now you get a file folder in that folder and now you can easily read xml files also.

step 4:

it's not any step just copy contents of both folder(in this case both new folder)to the single one

and now enjoy wid source code... "

Video Tutorial APKtool

Found in: stackoverflow.com

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.

Friday 15 July 2011

Great Alliance

These days, the Campus Party, is taking place in Valencia, the biggest computing fans meeting . In these event usually carries out some important presentations about the most actual technological developments. This year, one of them has been the one which I present here:

Arduino and Telefonica alliance: "Is easy to connect to the world, any object. [Blodic.us]"





El internet de las cosas crece. [El País]
Arduino y Telefónica fácil conectar al mundo cualquier objeto. [Xataka]

Break time for 'Gadgeting'


After a time looking for a lot of useful info on the web, now I have in my hands a Chumby. It's the first time I heard about this gadget, so I decided to find out the different possibilities it offers.

The Chumby is an ambient consumer electronics product made by Chumby Industries, Inc. It's an embedded computer which provides Internet and Lan access via a wifi connection. Through this connection, the Chumby runs various software widgets. Roughly resembling a small clock radio, it consists of a small touch-screen with a leather and plastic exterior. It uses AC power and turns off if unplugged and moved.

The design has evolved over time, as well as its initial technical specifications, but without losing the essence of the first model.













At first sight, when I started to discover its performance, I thought, this is a modern clock/alarm clock, but later I found out more interesting options. Chumby can acts as:
  • Digital Photo Frame/web, where you can see your Facebook/Flickr photos.
  • RSS Feed/News Reader: You can be informed about the news around the world.
  • Gaming device: several basic games, Sudoku, sliding puzzles...
  • iPod speaker, thank to the speaker it has behind. (the only thing I didn't like, is that i couldn't connect my iPhone...)
Once I discovered all the performance it offers, I wondered, why isn't it developed with Android? It's important to take into account that this device came out into the market at the end of 2007, in those days Android didn't have such a big importance as nowadays. But this question made me find this new device:













It's called Webby and it's an evolution of the Chumby developed by Avantis. As I said, the main difference is the implementation of Android over a Linux kernel.

But this device was not the only one which came from the Chumby, Sony also decided to join this race with his SONY Dash, defined as "Your Personal Internet Viewer".

So, after knowing how this market was, I concluded that this sort of devices was a good alternative to the newest tablets that we can find such as iPad, Samsung Tablets... Chumby was original designed for a home use, that's why the device here commented can't be really compared to the ultimate tablets.

How can I connect Arduino to a smartphone (Android)?

One of the reasons I decided to develop this project was the needed to research about implementing two actual and strong technologies that are taking more and more importance nowadays.
Android is one of the most important open source OS related to mobile devices, is a platform that is growing by leaps and bounds, allowing to create many applications systems in order to interact with real world.
Arduino is, also an Open microcontroller platform which allows to interact with a bunch of sensors, so these devices can be easily implemented.

Now I'm going to present different options that I found on several blogs to implement the connection:

1.- Audio Port:
2.- USB Port:
3.- Bluetooth/WiFi

So, I decided to perform the connection through the audio port, because it's an universal port that exist on all the different devices that support Android, so this would allow phones to form the basis for many health and communications applications turning the mobile phone into a scientific data collector data or an environmental tool by connecting low-power sensors.

Tuesday 5 July 2011

Twitter Account

Hello,

I've created a Twitter account for this blog: @Tec_Androino, I think is a good way to share my work with everybody.

Hi everyone!!

Hi everyone,

After a time spent taking my last exams in college, I will have plenty time to develop this project as my Final Project.

First of all, I would like to introduce myself:

I'm Alberto Pascual, Telecommunications Engineering. I studied at the University of Navarra (TECNUN), in San Sebastián, and I also spent a period of six months in Sweden at Linköping Universitet this academic year. That's why I'll try to do my best writing this project in English.

I would like to annotate that I'm really excited with the project I chose, because I think that is a great opportunity to learn about some technologies that are taking a great impact nowadays.

I hope you enjoy this project as much as I do.

See you around here.

Thursday 10 March 2011

New project member

Alberto will joint to the project team for six months. Welcome !!!

Monday 24 January 2011

Looking for an internship candidate

If you are doing a degree in telecommunications, we're offering a six month internship to contribute to this project. More information here.

Thursday 20 January 2011