View unanswered posts | View active topics It is currently Tue Jan 28, 2020 1:58 am

Reply to topic  [ 5 posts ] 
Sending data to the BLEShield and Arduino 
Author Message

Joined: Tue Mar 05, 2013 1:45 pm
Posts: 6

i need help: i try to send one single number between 0 and 9 from my iPhone to the BLE Shield and then to the Arduino.

My Code on the Arduino is working. Tested via USB an CoolTerm's "Send Serial command" feature.
But when I send data from the BLExplr iPhone app (from the AppStore) the data will be "corrupted" until it will be received by the Arduino code.

Here is my code:

<service uuid="482AFEB3-47F7-4992-9359-D4CE424AA3E3" advertise="true">
<description>Test Service</description>
<characteristic uuid="8D701095-B8C9-4150-BB8A-55FE65425420" id="xgatt_test">
<properties read="true" write="true" />
<value length="1" value="hex" variable_length="false"></value>


dim test(2)
event attributes_value(connection, reason, handle, offset, value_len, value_data)
memcpy(test(0), value_data(0), 1)
if handle = xgatt_test then
test(1:1) = $31 #49 dezimal # = 1
#call attributes_write(xgatt_test, 0, 1, test(0:1)) #save data in GATT
call system_endpoint_tx(system_endpoint_uart1, 2, test(0:2)) #send data to Arduino
end if

I just want to send 1 Byte of data to my Arduino. To explain my code: when the attributes_value event occurs, I copy the value_data to my "test" variable. Then I set a second byte ($31) to my "Test" variable. The reason for this is my Arduino code: there I want to differ between several data attributes. There first byte explains the value of my data and the second byte the type. For example "91" means power=9 and type=1
btw: if you have a better solution please tell me. but as far as I understood the Arduino Serial reads only byte by byte.
The problem is that when I am doing a in my Arduino code I will always receive strange data. I am not able to receive the data from the bgscript. for example instead of receiving "11" I get ".J" or other strange values.

So what is going wrong here?
And what about the issue of not to use the USB cable from my PC to the Arduino as long as I am using the BLE Shield ontop of the Arduino: can that cause this issue? but on the other hand I already tried that but that doens't helped me neither... :(

And I there a possiblity to debug the BGScript in general?

Regards, Marco

Tue Mar 19, 2013 12:41 am
Site Admin

Joined: Thu Aug 02, 2012 11:36 am
Posts: 166
Hello Marco,
have you tried to send the data from BLExplr as HEX/Raw data?

The only way to debug BGScript would be to use the BLE112 Eval board, attach a USB Cable to and send debug strings over USB to a serial terminal. Since the BLE-Shield is not equipped with an USB Port, debugging is not possible using this setup. But since you are connected to an Arduino why are you not debugging using the Arduino?

You can send recevied data to the PC/Mac using Serial.println(...) for instance.


Thu Mar 21, 2013 10:33 am
Profile WWW

Joined: Tue Mar 05, 2013 1:45 pm
Posts: 6
Thanks for your reply.

I tried HEX or String in BLExplr but no difference.
Unfortunately I have no Eval board. I am using the Arduino Serial.println for sure, but in this way you cannot debbug and see what the BGScript is doing all the time.

However, can I use a USB connection and the Shield and the same time, or should I use a battery: see: viewtopic.php?f=1&t=536&p=652&hilit=battery#p652
and have you ever heard about strange and weird data?

Thanks, Marco

Thu Mar 21, 2013 10:45 am
Site Admin

Joined: Thu Aug 02, 2012 11:36 am
Posts: 166
Hello Marco,
you can leave the Arduino connected to USB in order to debug, but then you need to set the S1 Switch to 2/3 and use SoftwareSerial to access the BLE-Shield.
This way the data is not messed up and it does not behave strange :-)


Wed Mar 27, 2013 12:17 pm
Profile WWW

Joined: Tue Mar 05, 2013 1:45 pm
Posts: 6
Now it got it :)
Thank you so much!

Tue Apr 02, 2013 11:55 pm
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.