I’ve been working on having my Android phone talk to my Arduino wirelessly with Bluetooth. I want to do it because I think it is pretty cool how powerful smartphone gesture interaction is- swipes and taps on a touchscreen is compelling- and I am surprised there are not more products and things around us that can talk to smartphones through local wireless communication- even basic consumer electronics. Once something is connected to a smartphone, the possible functions expands. Most simply, just consider any electronic object being able to interface not just with touch gesture, but also with the web through tethering.
First – getting the bluetooth set up properly I found this tutorial useful : http://www.mutexlabs.com/r-bluesmirf-silver-intro.html. Remember that when you first hook up the bluetooth, it will blink fast and then after a minute slow down. While it is going fast, you must connect to it. Once it slows down, switch it off, then on. For some reason there is this time limit to connect. Sometimes the connection will just not happen, in this case turn off the module, and then on, and try again.
The default password is probably ’1234′ when you connect to the device in Bluetooth Preference. To talk to the module, I used Cornflake but you can use other things like ZTerm. You will need to do this to change the baud rate, which must be the same between the arduino and the bluetooth module (this will be more clear when going through the Amarino tutorials discussed below).
I researched quite a few methods to program Bluetooth connection between my phone and the Arduino. The creators of the SweetBT share a similar sentiment of connecting mobile phones locally to things around. They created a Processing library for Android Arduino Bluetooth interfacing. I first tried that route since I’m pretty comfortable with Processing, but I had trouble with my app crashing. I tried going through this tutorial: http://webdelcire.com/wordpress/archives/1045 on Processing, Android, and Arduino- but ran into similar phone freezing issues. One issue I noticed was that if I closed my test application after bluetooth connection, my phone would slow down and it took several minutes for any gesture to respond. The only way out of this was to pull out the battery (since there is not off switch on the phone, and the button did not respond when I held it down).
I came across the Amarino toolkit. It comes with an app to connect to the bluetooth module with your phone, and several example apps to run on an android phone and an arduino after the connection has been made. The SensorGraph tutorial covers reading values from the arduino and plotting them on the phone (so arduino –> android), and the MultiColorLamp tutorial covers sending data from the android to the arduino (so android –> arduino). So far the only issue I have found is that you have to hand type in the device address of the bluetooth module into the android app. In the future I hope to automate this procedure after a device is connected via bluetooth.
In the coming weeks I’ll share updates on what I’m prototyping with the android+arduino+bluetooth+Processing combination.
Note: You may wonder why I did not choose to use an android IOIO board. I did this mostly because I wanted to use a smaller Arduino- in future iterations I plan to switch to the Nano. IOIO includes android APIs to communicate with the board, but so far serial through Bluetooth is working fine for my purposes.Embed This