Using Bluetooth And File in the Same App Problems

I am trying to send data from my Arduino to my app via Bluetooth (HC-06), and from there save it onto an excel file. My problem is that every time I connect to the Bluetooth my "set the excel file name" button locks up when pressed and won't unclick. The same thing happens if I enter the Excel filename before connecting to the Bluetooth, but in reverse order. Each component works well independently, it does create an excel file, and it will connect to the bluetooth, but when I combine the two my app stalls out.

I guess your app is not only made the blocks you attached to your post.
Where is the receiving function ? (Normally put into a timer). Something like here below...

Hi Uskiara

numberOfBytes to receive should be set with a math Block: -1
The BytesAvailableToReceive Block is just a flag that says "there are bytes", whereas -1 means "receive all bytes".

Also, your code assumes the value delimiter is a bar "|" (a very good choice) but if course it's dependant on the Ardunio Sketch which we have not seen. Etc.

1 Like

Hi Cole

We need to see all of your Blocks (right mouse menu) and your Arduino Sketch.

Hi Chris,
yes, my blocks were just an example to say that we need more info to get the root of the problem :slight_smile:

As a matter of fact the explanation of BytesAvailableToReceive in the
says that it returns the number of bytes still to be read in the BT buffer as per picture below:


In my use, I "poll" the BT line until data are available, and when the stream from Arduino stops, I let the App do something else. As you correctly say, it depends on my Arduino sketch and how it is synchronized with the car ECU. :smirk:

Definitely we need info from Cole_Bailey to help him...

Cheers, Ugo.

Hi Ugo

Whoops - that's an error in the documentation, thanks for letting us know.

1 Like

Hi Chris, my code is working by (some) miracle ?
:grin: :grin: :grin:
This means that when the lockdown will finish (I'm from Turin, Italy) I will go to my country house and change the software on my old convertible car.....ah ah ah....

there is no error in the documentation, see also my bluetooth chat example App Inventor Tutorials and Examples: Bluetooth Chat | Pura Vida Apps


Thank you all for your help, and advice, I appreciate it, and I was finally able to figure it out. It surprisingly happened to be the global variable in button 5 that was holding it up.