Ads

Thursday 8 October 2015

Arduino + Bluetooth module HC05, Serial Communication With LAPTOP? Simple!

Connect Bluetooth module to laptop is quite easy, because there are many open source software available on internet now. If we want to send or receive Data between Arduino and computer, firstly we need to make a Communication link to Definition Arduino Board to the computer. A software called Tera Term to show the data received or what we want to send through it. You can get the software here:


(https://en.osdn.jp/projects/ttssh2/releases/) Arduino support something Called Software Serial , which allow You to change any arduino board pin to serial pin. http://arduino.cc/en/Reference/SoftwareSerial To link your bluetooth module with laptop:
  1. power up HC-05 using Arduino
  2. for Windows user, go to control panel and "Add Device"
  3. the default password for HC-05 is "1234"
  4. after pairing up, you can compile and upload the code to Arduino
  5. sometimes you may fail to upload the program to Arduino board. Try to disconnect or turn off the bluetooth module while uploading the problem. After that, connect or power up the bluetooth module again.
  6. Open Tera term software (have to install it first from the link above), go to file > new connection. From the pop-up window, choose "serial" and related serial port.Screenshot (49)
  7. Congrats, you have done!
Here is my result:
Capture


 
 Arduino Code:// This program shown how to control arduino from PC Via Bluetooth
// Connect ...
// arduino>>bluetooth
// D11 >>> Rx
// D10 >>> Tx
// you will need arduino 1.0.1 or higher to run this sketch
#include <SoftwareSerial.h>// import the serial library
#define temp A0  // I used a potentiometer to replace it
SoftwareSerial Genotronex(10, 11); // RX, TX
int ledpin=13; // led on D13 will show blink on / off
int BluetoothData; // the data given from Computer
int tempValue = 0;
void setup() {
// put your setup code here, to run once:
Genotronex.begin(9600);
Genotronex.println("Bluetooth On please press 1 or 0 blink LED ..");
pinMode(ledpin,OUTPUT);
pinMode(temp,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (Genotronex.available()){
BluetoothData=Genotronex.read();
if(BluetoothData=='1'){ // if number 1 pressed ....
digitalWrite(ledpin,1);
Genotronex.println("LED On D13 ON ! ");
}
if (BluetoothData=='0'){// if number 0 pressed ....
digitalWrite(ledpin,0);
Genotronex.println("LED On D13 Off ! ");
}
if (BluetoothData=='2'){// if number 2 pressed ....
tempValue = analogRead(temp);              // read the value from potentiometer
Genotronex.print("Current temperature:");
Genotronex.print(tempValue);
Genotronex.println("Celcius");
}
}
delay(100);// prepare for next data ...
}
(putty can be used instead of tera term)

No comments:

Post a Comment