Basic project with HC05 Bluetooth

Hello,
I'm tryoing to connect from my PI4 to the Arduino using HC05.
basic led on\off by sending "1""0" from the pi.

I have connected the HC05 to the Arduino
TX-> Rx
RX-> Tx
Vcc - 5V
Gnd- GND

the HC05 is blinking , when I scan I can see it from my phone\python code
98:D3:C1:AA:8B:22 - HC-05
but I can't connect to it
also I can't see anything in the Serial Monitor

2 questions:

  1. do I need to change something in the HC05 defualt setting (I just took it out of the box and start using it , didn't change any setting using AT command)
  2. is the code correct?
/*
    Bluetooh Basic: LED ON OFF - Avishkar
    Coder - Mayoogh Girish
    Website - http://bit.do/Avishkar
    Download the App :
    This program lets you to control a LED on pin 13 of arduino using a bluetooth module
*/
char Incoming_value = 0;                //Variable for storing Incoming_value
void setup()
{
  Serial.begin(9600);         //Sets the data rate in bits per second (baud) for serial data transmission
  pinMode(13, OUTPUT);        //Sets digital pin 13 as output pin
  Serial.println("Setup Finish!");
}
void loop()
{
  if (Serial.available() > 0)
  {
    Incoming_value = Serial.read();      //Read the incoming data and store it into variable Incoming_value
    Serial.print(Incoming_value);        //Print Value of Incoming_value in Serial monitor
    Serial.print("\n");        //New line
    if (Incoming_value == '1')           //Checks whether value of Incoming_value is equal to 1
      digitalWrite(13, HIGH);  //If value is 1 then LED turns ON
    else if (Incoming_value == '0')      //Checks whether value of Incoming_value is equal to 0
      digitalWrite(13, LOW);   //If value is 0 then LED turns OFF
  }
  else
  {
    Serial.println("No Data");

  }
}

all I get is No Data

Thanks,

Check this connection again.

thank you ,
I thought I will see something in the terminal even if the connection is refuse or soemthing
it's seem that the HC05 doesn't send nothing on errors.

This is unhelpful and obscure, and could be the cause of your problem. Use a standard Android Bluetooth terminal programme after properly pairing with Bluetooth in the phone settings. Don't bother trying to explain why you are using python, you might have good reason for doing so eventually, but you certainly don't at the moment.

The code you post is probably kosher, but you might try disconnecting Bluetooth and seeing if it works by just using the PC keyboard.

It is good practice to use a 1k/2k resistor divider between Arduino Tx and Bluetooth Rx, but this is not likely to be the cause of your problem.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.