Android Question [SOLVED]Problem sending data from b4a to b4r via hc-05

Hilton

Active Member
Licensed User
Longtime User
Hi,

I have a B4R app running on arduino mega 2560 that gets data from up to 5 lidars. There is an HC-05 bluetooth card on the mega and is used to send the data to an app on B4A. The distances from the lidars are continuously displayed on a phone/tablet using B4A and all is working fine thanks to all the information on this site.

I want to send some configuration information from the B4A to the B4R to get rid of the need of a physical dip switch on the mega board. To that end I initialised the astreams in B4A as follows
B4X:
AStream.Initialize(serial.InputStream,serial.OutputStream,"astream")

On the B4R side I have
B4X:
hc05ass.Initialize(hc05ss.Stream,"hc05ass_NewData","hc05ass_Error")

The data that I send from B4A to B4R is
B4X:
    Dim xx As String = "name"
    Dim b() As Byte
    b = ser.ConvertObjectToBytes(xx)
    Dim ok As Boolean = AStream.Write(b)
    Log("Ok " & ok)
    Log("b written to arduino")

On the B4R receiving side i have
B4X:
Sub hc05ass_NewData(buffer() As Byte)
    Log("hc05ass_newdata")
End Sub
This was just to see if anything was coming back to B4R, at this stage I just want to see if data is arriving.

Because I am a novice with this iot stuff, I was not sure whether I should expect the data to arrive at the hc-05 or serial1, so I also check s1Stream_newdata. These events do not seem to be triggered.

I have spent many hours trying and reading material on the site, but cannot find the answer.

Any help from wiser heads would be appreciated,
Hilton.
 

Hilton

Active Member
Licensed User
Longtime User
Upvote 0

Hilton

Active Member
Licensed User
Longtime User
Just in case any one has a problem sending to HC-05, my simple mistake in the B4R program was to have 2 softserials open at the same time.
 
Upvote 0
Top