Hi
I have a little problem here.
I have bought HC 05 bluetooth module from Here.
I have everything connected correctly: RX to TX on board
TX to RX on board
5V+ to 5V and GND to GND
I'm using arduino MEGA 2560 board and this code:
void setup() {
Serial.begin(9600);
pinMode(8, OUTPUT); // put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()>0)
{
char data= Serial.read(); // reading the data received from the bluetooth module
switch(data)
{
case 'a': digitalWrite(8, HIGH);break; // when a is pressed on the app on your smart phone
case 'd': digitalWrite(8, LOW);break; // when d is pressed on the app on your smart phone
default : break;
}
Serial.println(data);
}
delay(50);
}
I can't control LED by Smartphone but when I use Serial Monitor I can normally control the LED without problems
Please help I have tried everything and nothing works
I can't control LED by Smartphone but when I use Serial Monitor I can normally control the LED without problems
If the program works over USB from the serial monitor, without the HC05 connected, but not from the phone when it is connected there are a few things to check. Working over usb serial tells you the code is correct.
Check/change the wires from rx>tx and tx>rx. The cheap pin end connector wires can be defective.
Is the phone paired with the module in the Bluetooth Settings of the phone?
What app are you using on the phone to connect to the module. Can you connect the app to the module?
On the Mega, you can use one of the additional hardware serial ports for the HC05 connection, but using Serial is not the main issue here. Using an alternative port will make it easier to download code and to use the monitor for input as well as the phone through the HC05.
It probably means that you have failed to get it into AT mode, or the command is illegitimate, or the HC05 is a fake. This last need not necessarily be a problem. Some fake HC-05 are fine but have limited AT commands.
It probably means that you have failed to get it into AT mode, or the command is illegitimate, or the HC05 is a fake. This last need not necessarily be a problem. Some fake HC-05 are fine but have limited AT commands.
I've tested The AT command that way , there was no problems
Connect EN,5V of Bluetooth module pin together at arduino 5v pin and ground pin to arduino ground pin.
Upload empty sketch.
connect RX and TX pin from Bluetooth module to arduino RX and Tx pin.
Remove arduino usb cable from laptop and you will notice one push button at Bluetooth module.
Press that Bluetooth module and don't let go, at that same time connect usb cable to laptop. Let go the push button and you will notice led at Bluetooth module will blink slowly which mean at AT-COMMAND.
Open IDE and click Serial Monitor. Change from no-line ending to Both NL & CR.
connect RX and TX pin from Bluetooth module to arduino RX and Tx pin.
Remove arduino usb cable from laptop and you will notice one push button at Bluetooth module.
Press that Bluetooth module and don't let go, at that same time connect usb cable to laptop. Let go the push button and you will notice led at Bluetooth module will blink slowly which mean at AT-COMMAND.