Android Question Trying to connect to HC-05 BT module

andyp

Member
Licensed User
Hi. Trying to connect to HC-05 BT module. To get me started, I am using this example https://www.b4x.com/android/forum/threads/hc-05-classic-bluetooth.66677/#content (just the android code) to try and achieve a connection to a HC-05 BT module.

The BT module is connected to an Arduino + GPS module - the Arduino is sending Lat + Long over BT using the HC-05. I can use an app from the Play Store (Bluetooth Terminal HC-05) to see the serial data - so I know the Arduino / GPS / HC-05 is working.

Using this example, I needed to change the target SDK in the manifest to 26, otherwise I have made no changes to the example code.

I would think this should let me achieve a connection?

There is no log error - simply trying to connect times out.....

Any ideas? Thank you!
 

emexes

Expert
Licensed User
Hi. Trying to connect to HC-05 BT module ... There is no log error - simply trying to connect times out.....
Is there any log at all? Especially from:
B4X:
Private Sub admin_DeviceFound (Name As String, MacAddress As String)
    Log($"Device found: ${Name}"$)
If not, then add these Log lines and give it another go:
B4X:
Sub Service_Create
    serial.Initialize("serial")
    admin.Initialize("admin")
    Log("Initialize done")    '<== add this line
End Sub

Public Sub Connect
    admin.StartDiscovery
    Log("StartDiscovery done")    '<== add this line
    connecting = True
    CallSub(Main, "SetState")
End Sub
 
Upvote 0
Top