Instructables
Picture of Connect Arduino Uno to Android via Bluetooth
IMG_20140426_104845.jpg

In this project a serial Bluetooth module is used to create a connection between Arduino Uno and an Android app that I created with MIT App Inventor.

Arduino listens for commands to light some LED's or show its status. In addition, a timer interrupt makes it check for temperature via a TMP36 sensor: if temperature is greater than a threshold a LED is lit; every n seconds (where n is a parameter set through the app) a status report is sent to the app. A simple command structure enables the app to send parameters and values to Arduino and the other way round.

There are many Bluetooth modules and even Arduino shields: my choice has fallen on JY-MCU that I bought from Hobby Components in the UK.

The JY-MCU is a class-2 Bluetooth module that acts like a serial port with no need of any software configuration on the Arduino. This module is available in several configurations, and this has been the first hurdle to overcome.

The one we need to make the connection between Arduino and the Android phone is a Slave Module. To make things very simple, there are two types of devices: Master and Slave; a Master can communicate with more than one Slave while a Slave can communicate with a single Master at a time, Master-Master and Slave-Slave communication is not allowed. Since the Bluetooth module in all smartphones is of Master type, the one we need for Arduino must be a Slave (this has nothing to do with client-server communication as we'll see later in the app description).

 
Remove these adsRemove these ads by Signing Up
1beertap1 month ago

I really like your code, but how can I change it to convert Celsius to Fahrenheit and display it?

pmosconi (author)  1beertap1 month ago

Sorry, for the delay. In this great Adafruit tutorial you can find all info you need: https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor#

Nevermind, I took the output of the Celsius temperature, using a formula I converted it to Fahrenheit, and saved the data to another variable I created and then printed the new data. Thanks for sharing!!!

can i use

Freeduino USB with Atmega8

http://www.electroncomponents.com/Freeduino-USB-Atmega8?filter_name=arduino

mcdrew2 made it!1 month ago

GREAT INSTRUCTABLE!!! This is the first time I have tried bluetooth so the detailed explanation was extremely helpful. Everything worked as described. I am planning to try and adapt this to a automatic door opener control as I am in a wheelchair.

First bluetoooth led.jpg
pmosconi (author)  mcdrew21 month ago

Many thanks :-) !! You might want also to check Bluetooth Low Energy (BLE, iBeacon, ...) technology to trigger proximity actions such as open a door when automatically when you're close by. The problem with it is that MIT App Inventor doesn't support it so you need to use "real" programming or prepackaged applications.

If I wanted to take out the interrupt feature so it only read the status when requested what specific code would I remove.

Thank you.

pmosconi (author)  mcdrew21 month ago

Hi, the interrupt routine is initialized between the instructions

cli(); // disable global interrupts

and

sei(); // enable global interrupts

at the end of setup() function, so just delete all lines from cli(); to sei(); included.

Also, you won't need any more the interrupt routine itself: delete the function ISR(TIMER1_COMPA_vect)

Hope this helps

Awesome! Thank you.