Connecting Arduino to Android
To connect your Arduino board to an Android device, you need an Amarino toolkit. Amarino is a project developed at MIT to connect Arduino and Android via Bluetooth. It has been released under GNU GPL v3.
The Amarino toolkit consists of three main components:
1. Android application called Amarino
2. Arduino library called MeetAndroid
3. Amarino plug-in bundle (optional)
You can download these toolkit components from http://code.google.com/p/amarino/downloads/list. Moving on, if you want to work with Amarino, you need an Android-powered device running version 2.x, though it supports version 1.6 too. Moving on to the Arduino board, you can have a Lilypad or Duemilanove, with a Bluetooth shield such as BlueSMiRF Gold and Bluetooth Mate, or an Arduino BT, which comes with Bluetooth attached to it already.
Installing Amarino is simple. After you’ve downloaded ‘MeetAndroid’ library, extract and copy it to ‘Arduino Libraries’ directory. Install ‘Amarino.apk’ package to your Android device by downloading directly to it or by calling ‘adb install Amarino.apk.’ Make sure your device is connected to the computer via USB, and the PATH is set correctly for ‘Android SDK Tools’ directory.
Now follow these steps to get the Arduino board connected to Android:
1. Authentication. Open the installed Amarino application and click ‘Add BT Device’ to search for your Arduino BT device. Make sure that it is turned on. But before the two can talk to each other, they must be authenticated. Select the device and confirm pairing with it from the notification bar. Typically, the pin number is 1234, 12345 or 0000. Once your Arduino BT device is authenticated, it’s ready to go. See Fig. 2.
2. Creating events. Next, install the plug-in bundle (AmarinoPluginBundle.apk) from http://code.google.com/p/amarino/downloads/list. Thereafter you can head to event creation. Start the Amarino application and launch ‘Event Manager’ of your Arduino BT device. Click ‘Add Event→Test Event.’ This is a test event—a demo that sends a random number (0-255) every three seconds. Now your Android device is ready to communicate with the Arduino board, so set up the latter.
3.SettingupArduino. Open your Arduino software and select ‘File→Examples→MeetAndroid→Test.’ When the project opens, change the baud rate of your Bluetooth module from 57600 to 9600, as highlighted in Fig. 3. Upload the sketch to the board. If there is no LED on the board, you can attach one to pin 13.
Running the test program
Now your Android device and Arduino board are ready to talk to each other. In the Amarino application on your Android device, click ‘Connect’ to communicate with the Arduino board. As soon as Android connects to Arduino, it starts sending a random number every three seconds, and that lights the LED for one second. You can monitor the process by pressing ‘Monitoring’ on the main screen of the application.
This concept of connecting Android to Arduino can be very handy in making electronics projects more useful by increasing their flexibility. It can easily be used in home automation controls, power consumption meters, Bluetooth-controlled robots, managing devices from the computer and much more. There is little doubt that Amarino brings us more power by helping us connect Arduino with Android.
Reproduced from November 2012 issue of Open Source For You