Skip to first unread message

Sven Onderbeke

unread,
Apr 6, 2019, 3:12:54 PM4/6/19
to MIT App Inventor Forum
Hi everyone, 

I have Arduino with a bluetooth module that sends data every 500ms. 
Secondly I have an App inventor app that connects to the bluetoothdevice end receives the data. 
My problem is that after I select the bluetooth device and connect to it, I get a lot of (old) data that's comming in rapidly and after that I receive data at an expected rate.
So my guess is that I have to flush the bluetooth buffer before I start viewing my data in the app. 

I tried following code block to flush the data : call bluetoothClient1.Receivetext numberOfBytes -> call bluetoothClient1.BytesavailableToReceive but this didn't seem to have any effect.
Does someone has a suggestion?

Kind regards, Sven

tanjamaya

unread,
Apr 6, 2019, 5:07:44 PM4/6/19
to MIT App Inventor Forum
read this if it helps ...I had a similar problem like yours 

also make two timers for receiving data, first one to get the old rubbish data, and store it to some invisible "Buffer lable" 
the timer is going to be much quicker like 10ms so it gets all the rubbish qucklu
then enable the real timer for the real stuff, this can be 500ms.

Capture3.JPG




Chris Ward

unread,
Apr 6, 2019, 9:41:38 PM4/6/19
to MIT App Inventor Forum
Hello Sven

It could be the device buffer? In your .ino Sketch, setup() function, last code:

Serial.flush();
Reply all
Reply to author
Forward
0 new messages