Skip to first unread message

龔昱庭

unread,
Sep 26, 2017, 12:28:23 AM9/26/17
to MIT App Inventor Forum

Hardware : Arduino uno (motherboard) + HC-06 (Bluetooth) + AD8232 (ECG received)
Software : App Inventor 2 (mobile phone side drawing)

Using serial plotters in Arduino (1.6.9 or later) can display the ECG instantly, but it can not be "instantly" displayed when it passes through Bluetooth to the phone.
I understand the need to prepare the first time to receive the first data, but with the transmission time getting longer, the longer the delay (When I unplug Arduino power and HC-06, the phone still continue to draw ECG for a period of time and then it stop).
I have set the TimerInterval of the clock component on the App Inventor 2 to 1 (0.001 seconds to receive the ECG signal and draw the voltage point), but it seems to be adjusted to about 30 (0.03 seconds to receive ECG signal and draw the voltage point) is the limit of phone display.
My mobile phone is HTC U11 (Bluetooth 4.2), Bluetooth-side HC-06 (Serial.begin (9600)), theoretically the transmission speed should be no problem.

My problem is that the phone display (App) and the computer display (Arduino serial plotter) is not synchronized.

gerrikoio

unread,
Sep 26, 2017, 8:35:36 AM9/26/17
to MIT App Inventor Forum
It may be better for you to switch to a BLE device such as HM-10/HM-11. Then you could create and use a heart rate notify GATT service.

Otherwise to ensure less latency when streaming data from HC-06 you would need to use a blocking routine, when connected, such as while-test-is-true-do to process incoming byte stream. Usually not recommended but in this case, this should ensure data is processed quicker. Of course, make sure you have a way to exit out of the blocking loop.


Ghica

unread,
Sep 26, 2017, 10:20:54 AM9/26/17
to MIT App Inventor Forum
To use a blocking routine is a sure was to crash your app sooner or later. And using a timer interval of 1 (1 millisecond) drown the app with requests it cannot handle. How fast is your device sending data to the phone? I think that should determine the timer interval. If you can make it 50 or 100, you will have more chance of succeeding.
Gerrikoio is right that BLE would give you more possibilities to communicate with the app, but the software on your Arduino will be rather more complicated, unless you can find examples you can use.
Cheers, Ghica
Reply all
Reply to author
Forward
0 new messages