Problem to Send data from HM10 BLE to Phone Application (Receiving is OK)

284 views
Skip to first unread message

Paul FREYER

unread,
Nov 5, 2016, 12:05:02 PM11/5/16
to MIT App Inventor Forum
Hello,

I try to do a link between a HM10-BLE Bluetooth device and a PIC18F87J50.
I began to wrote an application with this BLE device and i successfully can send order to my PIC
in fact,it is not so easy as normal BlueTooth devices ..

I can only SEND String command from my phone to the Device
Connected
put  led On or OFF..
or disconnect 

but i can NOT receive on my phone,  some data trough BLE device  (data sended by my PIC..every 4 seconds.)
ie: i send status of 2 switches and an analog value.. collapsed in ascii (into a string)
B1=1;B2=1;E1=  199<CR><LF>

it seems that i don't use the correct UUID ?
i didn't find example on the web .

Please could you have a look on it
and give some advice to follow..

if necessary i can also join my MikroC program..

Best regards

BLE_18F87J50_161105.aia
BLE_18F87J50__blocks_161105.png
BLE_18F87J50_Designer.jpg

Paul FREYER

unread,
Nov 6, 2016, 1:23:23 PM11/6/16
to MIT App Inventor Forum
hello,

i successfully find out the solution
maybe it was too much easy !
simply to use the event 
When bluetoorthLE1 Stringvaluechanged ..

i found another probleme with the slider
When i get the position , i get 2 times values .. why not only one ?

what i get into my PIC18F:

B1=1;B2=1;E1= 197 ;V1= 634            <- this is what i send to Smartphone
IT UART2 -> SL=156;SL=164;           <- this is what i get when changing position of slider
53.4C.3D.31.35.36.3B.53.4C.3D.31.36.34.3B.00.00.00.00.00.00.
B1=1;B2=1;E1= 196 ;V1= 631




Abraham Getzler

unread,
Nov 6, 2016, 2:29:13 PM11/6/16
to MIT App Inventor Forum
Maybe you are reading from the UART less frequently that the AI2 slider changes?
In that case, there would be two writes from AI2, to the one read.

Situations like this are usually handled by including a delimiter like LF at the end of each message,
and specifying the delimiter value as an attribute in AI2 or as \n at the end of the text,
and programmatically in the micro vis commands like readln().

ABG

Paul FREYER

unread,
Nov 8, 2016, 5:30:08 AM11/8/16
to MIT App Inventor Forum
Hello ABG,

Thank's for this answer


I turned around this problem by using clock timer and Thumbenabled 
When i move the slider, it disappers one second and re appears just after moving the position
and so, i take only one slider value back to my PIC applicatiopn

Waiting BT Connection 10x4sec:
 Wait Step:    1
 Wait Step:    2
OK+CONN
HM10 BLE Connecté
B1=1;B2=1;E1=  141 ;V1= 454
B1=1;B2=1;E1=  203 ;V1= 654
IT UART2 -> SL=138;                              <- slider value 
B1=1;B2=1;E1=  213 ;V1= 686
IT UART2 -> SL=146;
B1=1;B2=1;E1=  203 ;V1= 654
IT UART2 -> SL=197;
B1=1;B2=1;E1=  201 ;V1= 647
B1=1;B2=1;E1=  210 ;V1= 676
IT UART2 -> SL=133;
B1=1;B2=1;E1=  205 ;V1= 660
IT UART2 -> SL=192;
B1=1;B2=1;E1=  203 ;V1= 654
IT UART2 -> SL=44;
B1=1;B2=1;E1=  212 ;V1= 683

Best regards

AI2_BLE_Slider_OK.JPG

Abraham Getzler

unread,
Nov 8, 2016, 9:09:27 AM11/8/16
to MIT App Inventor Forum
A nice simple solution.
Thanks for telling us what worked.
ABG

Reply all
Reply to author
Forward
0 new messages