Ever thought of controlling any of your electronic devices with your smart phone? Your robot or any other device? Won’t it be cool to control them with your smartphone? Here is a simple and basic tutorial for interfacing an Android Smartphone with Arduino via Bluetooth. Arduino bluetooth Basic Tutorial!
What are the stuff required to do this project?
Hardware
- Bluetooth Module HC 05/06
- Arduino & Battery (with cable)
- LED
- 220Ω Resistor
- Android device
Software
- Arduino IDE
- Android Studio.
The android studio is not really required here, since I will provide you with the android application I made. You can install the given .apk file to use the application.
How does it work?
There are three main parts to this project. An Android smartphone, a bluetooth transceiver and an Arduino.
HC 05/06 works on serial communication. Here the android app is designed to send serial data to the arduino bluetooth module when a button is pressed on the app. The arduino bluetooth module at other end receives the data and sends it to the Ardunio through the TX pin of bluetooth module(connected to RX pin of Arduino). The code uploaded to Arduino checks the received data and compares. If received data is 1 the LED turns ON. And it turns OFF when received data is 0. You can open the serial monitor and watch the received data while connected.
STEP 1: Connecting the Arduino Bluetooth hardware
The circuit is so simple and small. There are only four connections to be made between Arduino & Bluetooth module!!
Arduino Pins Bluetooth Pins
RX (Pin 0) ———> TX
TX (Pin 1) ———> RX
5V ———> VCC
GND ———> GND
Connect an LED positive to pin 13 of Arduino through a resistance(valued between 220Ω – 1KΩ). Connect its negative to GND. And you are done with the circuit!
Note : Don’t Connect RX to RX and TX to TX of Bluetooth and Arduino. You will receive no data. Here TX means Transmit and RX means Receive.
STEP 2: Upload Sketch to Arduino
char data = 0; //Variable for storing received data
void setup()
{
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
}
void loop()
{
if(Serial.available() > 0) // Send data only when you receive data:
{
data = Serial.read(); //Read the incoming data and store it into variable data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n"); //New line
if(data == '1') //Checks whether value of data is equal to 1
digitalWrite(13, HIGH); //If value is 1 then LED turns ON
else if(data == '0') //Checks whether value of data is equal to 0
digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
}
Upload the given sketch to Arduino using the Arduino IDE software, you can also get it from here: Github
STEP3: Install the android application
In this tutorial, I will not be covering Android app development. You can download the android application from here and the source code of the entire project.
- Download the Application from Amazon App Store or Github
- Pair your device with HC 05/06 bluetooth module:
- 1. Turn ON HC 05/06 bluetooth module by powering the Arduino.
- 2. Scan smartphone for available devices.
- 3. Pair to HC 05/06 by entering default password 1234 OR 0000.
- Install LED application on your android device.
- Open the Application
- Press paired devices
- Select your Bluetooth module from the List (HC-05/06)
- After connecting successfully, press ON button to turn ON LED and OFF button to turn OFF LED.
- Disconnect button to disconnect from bluetooth module.
This is just basic tutorial on interfacing bluetooth module with Arduino. This project can improved to higher level like Home automation using smartphone, Smartphone controlled robot and much more.
You can watch the video tutorial over here:
View more at: http://bit.ly/1XReQFr
Post a Comment