HC-05 Bluetooth module Arduino Uno problem

Hi
I have bluetooth module HC-05 and I C=connect with my Uno
Tx->Rx
Rx->Tx
5v->5v
GND->GND
I have code from youtube

int ledPin = 13;
int state = 0;
int flag = 0;

void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);

Serial.begin(9600);
}

void loop() {

if(Serial.available() > 0){
state = Serial.read();
flag=0;
}

if (state == '0') {
digitalWrite(ledPin, LOW);
if(flag == 0){
Serial.println("LED: off");
flag = 1;
}
}

else if (state == '1') {
digitalWrite(ledPin, HIGH);
if(flag == 0){
Serial.println("LED: on");
flag = 1;
}
}
}

I connect with my xperia l by ArduDroid app, I can connect and get data from arduino but I can't send any data, when I open serial monitor at Arduino Ide and send 1 or 0 led is on or off but by android app i can't ;/
I don't know why that is.
Please help me :slight_smile:

kse1:
Hi
I have bluetooth module HC-05 and I C=connect with my Uno

I connect with my xperia l by ArduDroid app, I can connect and get data from arduino but I can't send any data, when I open serial monitor at Arduino Ide and send 1 or 0 led is on or off but by android app i can't

I guess you already know that there is nothing wrong with the code, and the wiring sounds fine. I don't know what an xperia is, or anything about ArduDroid, but it sounds like you are using an Android devicee, and are going through the right procedure. If the LED on the Bluetooth is solid, you are connected, and Android should tell you that anyway.

Your code works fine when using Bluetooth Terminal on my Android phone. I suggest you try that.

I guess you already know that there is nothing wrong with the code, and the wiring sounds fine. I don't know what an xperia is, or anything about ArduDroid, but it sounds like you are using an Android devicee, and are going through the right procedure. If the LED on the Bluetooth is solid, you are connected, and Android should tell you that anyway.

Your code works fine when using Bluetooth Terminal on my Android phone. I suggest you try that.

I download Bluetooth Terminal on my Android device, I can't send 1 or 0.
When I send 1 at Serial Monitor led is on and at Bluetooth Terminal I get "LED: on"
I think my RX pin at Arduino is damaged ;/
Led on hc-05 is blink but when I connect with my Android device is blink twice and off for 2 seconds.

Can I make RX and TX at another pin ?

Thx for answer :slight_smile:

kse1:
I download Bluetooth Terminal on my Android device, I can't send 1 or 0.
When I send 1 at Serial Monitor led is on and at Bluetooth Terminal I get "LED: on"
I think my RX pin at Arduino is damaged ;/

You could be right

Led on hc-05 is blink but when I connect with my Android device is blink twice and off for 2 seconds.

I'm afraid I don't understand this

Can I make RX and TX at another pin ?

Yes you could try using software serial. This allows you to pins other than D0,D1 and this is the only time when it makes sense to do so. There are several examples around. You will need the software serial library

I read about SoftwareSerial and upload this code to Arduino

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX

void setup()
{

Serial.begin(9600);
mySerial.begin(9600);
}

void loop()
{
if (mySerial.available())
Serial.write(mySerial.read());

if (Serial.available())
mySerial.write(Serial.read());

}

I write something at SerialMonitor and get this at Bluetooth Terminal on Android device and write on Android and get at SerialMonitor.
But when I make code like this

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX
int stan;
int led = 13;
void setup()
{

Serial.begin(9600);
mySerial.begin(9600);
pinMode(led, OUTPUT);
}

void loop()
{
stan = Serial.read();
if (mySerial.available())
Serial.write(mySerial.read());

if (Serial.available())
mySerial.write(Serial.read());

if(stan = 1) {
digitalWrite(led, HIGH);
}
if(stan = 0){
digitalWrite(led, LOW);
}

}

I send 1 from Bluetooth Terminal and get this at Serial Monitor but led is off

So.....
You have two programmes there, both using software serial. Are you saying the first runs OK and the second does not?

It seems that the only difference is the LED control and it might be time to suspect the LED. You can test this with a blink programme. I don't know anything about LEDs or software serial, but your original programme works OK. If the first programme with software serial works OK, at least you have proved the bluetooth module is OK.

Ok I upload this code

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
int ledPin = 5;
int state = 0;

void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
mySerial.begin(9600);
Serial.begin(9600);
}

void loop() {

if(mySerial.available() > 0){
state = mySerial.read();

}

if (state == ‘2’) {
digitalWrite(ledPin, LOW);
Serial.println(“LED: off”);

}

if (state == ‘1’) {
digitalWrite(ledPin, HIGH);
Serial.println(“LED: on”);
}
}

and all work good :slight_smile:
thx

hi, if u having trouble in making into AT mode of HC-05 (ZS-040)(especiall if one having en/wakeup up pin instead of key pin) and trouble in transfering data between two hc05 module . Follow they bellow procedure
Power off HC-05 module.
Press and hold small button above EN pin.
Power on and keep pressing small button.
Small LED should start to blink slowly about once every 2 seconds.

for more info visit below site:

another good reference for making it into master mode is here:

aftermaking connection if you stuck in transmitting data from one module to another see below:
http://www.martyncurrey.com/connecting-2-arduinos-by-bluetooth-using-a-hc-05-and-a-hc-06-easy-method-using-cmode/

I am working on a project on TPMS. since I am not using android or computer. I need suggestion on using just bluetooth modules to transmit data and receive them using another bluetooth module.

I assume you mean Arduino<>Arduino via bluetooth.

You might get something useful at

also, I believe Martyn Currey has done work in this arena.

Use 'Arduino BlueControl' app.
Link:

kse1:
Hi
I have bluetooth module HC-05 and I C=connect with my Uno
Tx->Rx
Rx->Tx
5v->5v
GND->GND
I have code from youtube

I connect with my xperia l by ArduDroid app, I can connect and get data from arduino but I can't send any data, when I open serial monitor at Arduino Ide and send 1 or 0 led is on or off but by android app i can't ;/
I don't know why that is.
Please help me :slight_smile: