Dec 2011 03

In this post I’ll show how one can use Android to send commands to Arduino via a BT module.

Prerequisite : 

Before getting started download and configure all the applications on Android and ArduinoIDE as given in Amarino Toolkit.

One should have :

  1. Android phone with above applications loaded.
  2. BT Module.
  3. USB Cable to burn program to Arduino.
  4. LED

Target : 

Android phone will send random numbers from 0-255 to Arduino every 5 second via BT module. This Will light up the LED attached to port 13 on Arduino. This is done with the help of an application called Amarino. Amarino has several test data which can be used for data transfer. Here event named Test Event  will be used.

Assuming that one has done prerequisite will proceed.

Step 1 :

Open Arduino IDE and select “File->Examples->MeetAndroid->Test”

733546_orig

 

Note : You will see above path only if you have followed prerequisites given at the top.

Since the BT Module and Arduino I’m working with is responding at 9600, so tweak the code and change Serial.begin(57600); to Serial.begin(9600); If you working with other BT Module then change the baud rate accordingly.

Now you need to verify and burn the code to Arduino :

219462_orig

9970580_orig

 

Done then move to next step.

Step 2 :

Attach BT module to Arduino as  on 9600 Baud Rate :

Pin :

  1. RST : To Reset the BT module.
  2. VCC : 5V Supply. This module works on direct 5V supply. Other module might have different requirements.
  3. GND : Ground.
  4. TXD : To Transfer the data.
  5. RXD : To Receive the data.

7631609894801

 

 

 

 

 

 

7881550

3609860

 

 

 

 

 

 

 

 

 

Note : Red LED on BT Module will be constant while Yellow one will blink continuously until it gets configured with other BT device.

Step 3 :

Attach the LED to Pin 13 :

7459562 2195648

Step 4 :

Pairing and adding test data to be sent via Android.

1) Open Amarino Application (One should have it as prerequisite explains how to install on Android phone).

8105202 5584302

2) This is How the Amarino application looks :

 

55005031124065

Click on the Red icon at top left.

Amarino contains sample plugin/event which let’s Android send sample data. As written above in post “random numbers from 0-255″ is what targeted to be delivered to  Arduino. Such data is called Event in Amarino.

3) After clicking Red icon next click on Add Event icon and in next screen scroll until one finds Text Event. This Event does the task to sending data via BT of Android till BT on Arduino. At the use Save Option.

408765

1891256 4754216

 

 

 

 

 

 

 

 

 

4) After above step Amarino will be diverted to Home screen. Now use the connect icon. This will pair the Android BT to BT on Arduino. Enter the passkey if asked.

6645074

5) As soon as one hits connect  : Android pairs and starts sending data with the help of Test Event which was configured earlier. Now every 5 seconds a random number is forward to Arduino and it flashes LED for 1 sec and this continues for ever till one disconnects Android from Arduino.

At Amarino home one can see icon named Monitoring.  Click that one can see how Android communicates to Arduino.

6470874 252290

65645

 

5031301

 

Amarino is a very interactive application which one can use to built connection between an Android Phone and an Arduino. It has number of plugins which are built on top of Amarino and provides easy solution to many problems. Guess what if one wished they go ahead and improve the code. It’s open source and hosted here.