I have started learning about arduino
and just bought a bluetooth
module, HC-05. From where i bought, it says it has range of approx.10 meters. I made hc-05 connection with arduino
in below described ways
I am using it as a slave with default configurations, 9600 baud rate and HC-05 name with pin 1234
GND of HC05 -> GND of `arduino`
VCC of HC05 -> 5V of `arduino`
TX of HC05 -> RX of `arduino`
RX of HC05 -> TX of `arduino` via voltage divider network 2k---|---1k
Below is my arduino
code
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
// Connect the HC-05 TX to Arduino pin 2 RX.
// Connect the HC-05 RX to Arduino pin 3 TX through a voltage divider.
int pin = 13;
char c = ' ';
void setup()
{
Serial.begin(9600);
Serial.println("Arduino is ready");
pinMode(pin,OUTPUT);
// HC-05 default serial speed for communication mode is 9600
BTserial.begin(9600);
Serial.println("BTserial started at 9600");
}
void loop()
{
if (BTserial.available()>0){
c = BTserial.read();
Serial.println(c);
switch (c){
case '1' :
digitalWrite(pin,HIGH);
break;
case '2' :
digitalWrite(pin,LOW);
break;
default: break;
}
}
}
Following things happening to me:
- When I power the module I am able to discover it with my phone but only when I hold my phone very near to the module. If I move away from the HC05 module, for example 3-4 feet, I am not able to discover it.
2.After connecting with it (while holding phone near to the module), I am able to send data to it but again, if I move away , only a few steps, I am unable to send data and I disconnect from it automatically. Also if I change direction of the antenna even then no communication happens.
My purpose is to control my home's lights and TV with the help of this module and Relays. But HC05 is useless so far. I was hoping that I would code it and wire it and hang it on a wall and interact it with and andoird
app.
Is it suppose to happen like this? or there's something wrong with my module's antenna
thank you.