This tutorial will show you how to configure an Ardunio to communicate over bluetooth with an Android device.
It assumes you have a basic knowledge of the Arduino, the Arduino IDE and installing Android applications from Google Play.
For this tutorial you will need the following items:
- An Arduino board.
- An Android device with bluetooth.
- A bluetooth serial board capable of connecting to the Arduino.
- An Android bluetooth terminal program
You will also need the Arduino IDE. The Android SDK and a breadboard are not required but are helpful.
What I used:
- A breadboard Arduino with a Modern Devices USB BUB.
- An Acer Iconia Tab A100 running Ice Cream Sandwich 4.0.3.
- A Sparkfun Bluetooth Mate Silver.
- BlueTerm by pymasde.es available on Google Play.
Connect GND, VCC, RX and TX from the bluetooth device to the appropriate Arduino pins. For my setup I connected GND to GND, VCC to +5V, RX to D5 and TX to D6.
The Arduino sketch makes use of the SoftwareSerial library to communicate via two digital pins to the bluetooth device. You will need to make sure you set the SoftwareSerial baud rate to match the baud rate of your bluetooth device.
You will a program on Android that can connect to the bluetooth and host an SPP connection. I used BlueTerm from Google Play but you should be able to use another bluetooth terminal.
Run your bluetooth terminal. If you are using BlueTerm follow the steps below:
Select the three vertical dots to get the menu.
This next step is optional. To make typing on your Android device easier you may want to turn on local echo. Press preferences
and then select Local Echo.
Return to the menu screen by pressing previous and select Connect Device.
Select your bluetooth device. Mine is named mymate. If you are using the Sparkfun Bluetooth Mate when you successfully connect your Android device to it the blinking red LED marked "Stat" (red arrow in the above picture of the breadboard Arduino) will turn off and the green LED marked "Connect" (green arrow in the above picture) will turn on.
Compile and run the Arduino sketch and you should see output in BlueTerm and the Arduino serial monitor.
If you type characters on the Android device they should show up in the Arduino Serial Monitor.
- As the SDK Emulator doesn’t emulate bluetooth and probably wouldn't be able to make a connection even if it did this example will not run in the emulator.
- This example is built upon the work of others. I post it here not as an example of original work but rather as a complete working example for reference. If I didn't appropriately credit you for your work please let me know and I will add you.