-1

Basically, I want to connect the HC-05 to a specific mobile Bluetooth(whose address is known) and when the connection is established I want to turn on a LED on the breadboard. I am totally clueless how to write the code. Can you please help me with it as it is a part of my project.

I know the various AT commands and have scanned the Bluetooth address with AT+INQ command.

  • 1
    You know how to configure the HC-05 with AT commands (as you wrote). What is the problem with just letting the Arduino send these commands over the Serial? Be more specific in what the actual problem is. – chrisl May 18 '18 at 10:22
  • I want to connect the HC-05 to a specific mobile Bluetooth and when the connection is established I want to turn on a LED on the breadboard. So I want help with its coding. – Shivam Thakur May 18 '18 at 16:58
  • 1
    If you don't have a clue how to start: Start with an empty sketch with setup()? and loop() function. In the setup() function initialize the connection. Send the AT commands over Serial. Do Serial.begin() with the correct baudrate (the same as when you scanned with AT+INQ command). Send all necessary AT commands like Serial.print() or Serial.write(). Check with Serial.read() for the modules answer. If you get an understandable answer, you have a functioning serial connection to the module. Try it and come back, when you have a specific problem, that you cannot solve. – chrisl May 18 '18 at 19:02
1

If you are using an Arduino board with HC-05 for AT commands over serial, you can follow the below flow :

  1. Setup HC-05
  2. Check for available nearby devices AT+IRQ
  3. Check the response to check is the desired device is enlisted in the nearby devices
  4. If device is enlisted, use AT+BIND=<Bluetooth address> to connect to the other device
  5. Check the response of the AT+STATE? command until you receive “CONNECTED” (you can go for a while loop here)
  6. Once the connection is successfully established here, you can send a confirmation now as per your requirement.

The above scenario is applicable only when you are sure with the Bluetooth address of the device you want to connect to. If the scenario is something different, comment and let us know with the actual requirement.

  • I want to connect the HC-05 to a specific mobile Bluetooth(whose address is known) and when the connection is established I want to turn on a LED on the breadboard. So I want help with its coding. – Shivam Thakur May 18 '18 at 16:59
  • Then in that case the above procedure might help you to the fullest. – Sumit Panse May 21 '18 at 4:18
  • Thanks a lot. It helped me a lot and even I m almost done with the coding part. – Shivam Thakur May 22 '18 at 14:37
  • Your welcome Shivam Thakur. I just want to remind you that if you find any answer that helped you with your problem, just mark it as Accepted so that the one who helped could earn reputation score & also, it could help others. – Sumit Panse May 23 '18 at 8:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.