Tell when Bluetooth module connects on Arduino

前端 未结 4 2053
感动是毒
感动是毒 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:28

    From the HC-05 datasheet we see that the connection status depends on the output from PI09. Apparently sending "AT+BIND?" to the module will return the status of PI08 & PI09 in the form, "+ POLAR=PI08,PI09" however this makes no sense to me because in order to get this you must enter AT mode and entering AT mode will disrupt the paired connection, hence it will always send PI09 marked as "not connected".

    THUS in order to see if the connection is still live from the arduinos POV I can only see 2 feasible ways:

    • Program arduino to, every so often, send a "hello?" and if it doesn't receive the expected "Hi back" response, then it is to assume that it isn't connected.
    • Connect PI09 to an arduino input pin and read it's value whenever you want to check if the connection is live or not

提交回复
热议问题