Bluetooth Serial Communication with Arduino

I have problem with serial communication from Bluetooth module to Arduino. I am giving the input from Android device to Bluetooth module and it sends to Arduino to operate two motors.

Before couple of weeks the same code worked well. Now I'm using new Arduino board. I don't know how to fix this. Struggling from last two weeks. What might be the problem?

Connection is perfect. When I enter the value in Serial monitor textbox motors are running. Not running via bluetooth. My code always taking the else part of if condition.

if(Serial.available())
{
}
else
{
//Serial Error
}

My code is attached below.

Thanks in Advance.

BlutoothMotorTest.ino (1.44 KB)

What Arduino were you using when it worked, and what are you using now?

How is the Bluetooth device connected to the Arduino?

...R

I'm using Arduino UNO and Bluetooth HC-05. The code worked with the old Arduino UNO(clone) board. It damaged and I get a new same Arduino UNO and a Bluetooth from shop and tried it was not working.

The connection is,

  1. RX to TX
  2. TX to RX
  3. Then Power

I'm sure about the connection of motor IN and OUT pins.

void setup() {
// pinMode(13, OUTPUT);
Serial.begin(9600);
}

void loop() {

if (Serial.available()){

Serial.println("Entered Serial");
delay(1000);
}

else
{
Serial.println("Serial Error");
delay(1000);
}

}

Even this code is also not connecting with serial monitor via Bluetooth. I unable to find what is the issue in my project. In the new Bluetooth module it has a button in red color named sw1. What does it mean?

I attached the both old Bluetooth and new Bluetooth module(HC-05) below.

abish_r01:
I'm using Arduino UNO and Bluetooth HC-05. The code worked with the old Arduino UNO(clone) board.

Even this code is also not connecting with serial monitor via Bluetooth. I unable to find what is the issue in my project.

If the old one worked, it would appear that you are just getting forgetful. You can't share the serial monitor with bluetooth. You can prove the code with bluetooth disconnected, then use a proper terminal like RealTerm via bluetooth.

You might find the following background notes useful

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

Thanks for your response. We can see the serial monitor in android app itself. That app has been removed from play store. Arduino Buetooth Terminal is the app, from which we can see the serial monitor.

I found the solution for the serial communication problem. Me upload the code via cable and unplugged the cable for Arduino's power. So the serial communication refuses to connect via bluetooth. Then I powered the Arduino with external power source the bluetooth serial communication started working.

Now I have some other issue. The android app is not responding after few inputs passed. It refusing to send command. After 5 or 6 commands transferred successfully the Arduino not receiving any inputs. What might be the problem?

Suggest how to fix this problem.

What do you mean by external power? I hope it is not a 9v battery.

Does LED on bluetooth start blinking again? If so, you have lost connection and it is more likely to be an Android problem. It might not be serious, just user error.

If LED is still solid, it is probably an Arduino problem. It could be wiring.

If no LED, you have lost power.

What is the difference between all below Bluetooth modules?
All are in difference prices. I need to connect Arduino, Staring from

Web page-->(via Internet)Android Device-->(via Bluetooth)Arduino Bluetooth-->Arduino

What is the Bluetooth needed to buy to do this?

JY-MCU HC-06 v1.40 Bluetooth Transeiver RF Module 5V

JY-MCU HC-06 Slave Bluetooth Serial Port Transeiver

JY-MCU Wireless Bluetooth Interface Board Serial Transceiver

JY-MCU V1.02pro Serial Bluetooth Interface Board Bluetooth

JY-MCU Arduino Bluetooth Wireless Serial Port Module

JY-MCU V2 Bluetooth Wireless to Serial RS232 TTL Module

Thanks in Advance.

Nick_Pyner:
What do you mean by external power? I hope it is not a 9v battery.

Does LED on bluetooth start blinking again? If so, you have lost connection and it is more likely to be an Android problem. It might not be serious, just user error.

If LED is still solid, it is probably an Arduino problem. It could be wiring.

If no LED, you have lost power.

12V battery is the external power.

Yes Bluetooth LED is always glowing. Not blinking type in that board. I don't think it is an Android problem. I'm using log whether it is passing the data. It successfully sends data to the Bluetooth. Again if I run the same Arduino code with some other Android app, it is running perfectly. So it states no circuit error also.