Tell when Bluetooth module connects on Arduino

前端 未结 4 2051
感动是毒
感动是毒 2021-01-25 16:45

I\'m working on a project with Android and Arduino and am trying to figure out how on the Arduino side to tell if the Bluetooth is connected or not.

I\'m using one of

4条回答
  •  一向
    一向 (楼主)
    2021-01-25 17:06

    Unfortuntaely, the HC-05 will switch states when paired, but won't output a 1 until it's actually connected to something.

    For instance, I can unpair my phone from the HC-05, pair again, and then the LED will change state, but the output of the STATE pin is still 0. If I open up an app, and connect to the device manually then the LED, and STATE pin will change state. The LED will periodically blink twice, and the STATE pin outputs a 1 to the Arduino.

    If you would like to read the the value of the STATE pin, connect a wire to any of the inputs to the arduino, and code Serial.println(digitalRead(inputPin)); inputPin being the wire to the input of the Arduino.

    I've been fighting this thing for months, and have yet to find a way to make this thing automatically connect to my phone. It won't even allow for me to connect to it from my phone to the HC-05 unless I download an app onto my Android. It's possible to bind the HC-05 to a certain address, but even this did not work for me. I want to mess with the "AT+CLASS" command, but the documentation behind the instruction has hindered me thus far.

提交回复
热议问题