When I first started working with the Bluno, I found the documentation didn’t really give me a clear idea how to talk to the Bluno.
DFRobot does provide example iOS and Android projects. However, as I was making my app with the Unity game engine. I could not use that directly.
So, I ended up going through the example Android and iOS project examples provided by DFRobot to “reverse engineer” information about the Bluno’s pass-though serial service/characteristic.
This post is a write up what I figure out (back when I first started working with the Bluno). This information should be useful for anyone who wants to connect to the Bluno by means other than a standard iOS/Android app.
(I’m writing this to answer Pablo’s question: http://www.cevinius.com/2015/09/19/detailed-mobbob-build-instructions/#comment-987. Let me know if this helps. I connecting using Bluetooth LE.)
At the time, I was brand new to Bluetooth comms and didn’t even really know how Bluetooth LE differed from regular Bluetooth.
The examples provided by DFRobot were based about using Bluetooth LE “GATT”.
After studying the supplied Android/iOS code, reading up on GATT, and some trial/error, I figured out how to use the Bluno’s GATT Services/Characteristics for doing serial communication.
The service and characteristic to use for serial comms is:
Service UUID : 0000dfb0-0000-1000-8000-00805f9b34fb
Characteristic UUID : 0000dfb1-0000-1000-8000-00805f9b34fb
Note, the above UUID were reported back by Android when I queried the Bluno. When I queried it from iOS, the Service/Characteristic were identified by:
Service : DFB0
Characteristic : DFB1
So how do you use these to communicate with the Bluno?
- Connect to the Bluno. I scan for devices that offer the above Service, and connect to that. (The device offering this particular service will be a Bluno!)
-
After connecting to the Bluno, the app needs to subscribe to notifications on the above Characteristic. This subscription is needed to receive data back from the Bluno.
- To send data to the Bluno, write the data to the above Characteristic
- When data is received from the Bluno, the App will receive a notification via the Characteristic subscription that we did on connection.
On the Bluno Side:
- To send data to the App, write it to Serial (e.g. Serial.write() )
- To receive data from the App, check for it on Serial (e.g. Serial.available(), Serial.read() )
That should be the main pieces of information you need to start talking to the Bluno!
For my app, I bought an asset from the Unity Asset Store (for about $10) which wrapped the iOS and Android Bluetooth GATT APIs into a platform independent API. I then used this library for doing communications between the Unity app and Bluno. (This enables me to deploy the Unity app to both iOS and Android.)
Hi which assets did you bought
If it is this, https://www.assetstore.unity3d.com/en/#!/content/26661
Do you have any tutorial on how to connect and send data to and from bluno using this plugin similar to MobBob
Hi there,
I have used that plugin. I find it’s reliable on iOS, but not so reliable on Android anymore. (It used to work fine on Android 5, but doesn’t seem as reliable since Android 6.)
I don’t have a detailed tutorial on this (and don’t have time at the moment to write one). However, this blog post I wrote a while back has the key information you need: http://www.cevinius.com/2016/08/17/serial-communication-with-the-bluno-using-bluetooth-le/
If you look at the example code that the plugin comes with, and then use the Service and Characteristic that I mentioned, you should be able to get it to work.
Basically, that Service and Characteristic are the Bluno’s way of providing a “pass through” serial service. I.e. It is designed to work like a plain serial connection that you can send/receive any data over.
Hope that helps!
Kevin
Appreciate your reply, I have stuck in bluetooth for a few weeks. I purchased the plugin and i am using bluno nano. which scene do you used from the plugin, I used Simpletest scene and have change the UUID of the service, read and write characteristic to DFB0, DFB1 and DFB1 respectively and also the device name to bluno .
And I would like to know more about the arduino code which is used to send to unity as the code is originally wrote for rfduino. And Because i am using the arduino code provided by the dfrobot. Currently nothing is happening.
Sorry about the slow reply! I think this was posted while I was visiting Japan, and I missed it when I returned.
To confirm, you are using iOS?
I used the example scenes as a reference to see how the plug in was used, but I think I didn’t keep much of that code in the end.
I suggest writing an interactive app first to try out all the commands and get the connection working. E.g. Make an app with buttons and
UI to go through all the steps of connecting, so that you can see what values you get returned, how long each step takes, etc.
Roughly, you need to:
Initialize()
ScanForPeripheralsWithServices()…
In the callback for ScanForPeripheralsWithServices… you need to check for when the Bluno is found.
Then call ConnectToPeripheral()when the Bluno is found.
Then in the callback for that, you need to use SubscribeCharacteristic()
After the connection is set up… you send data using WriteCharacteristic()
And you will receive data back in the callback you passed into SubscribeCharacteristic()
The Arduino code just writes data to the serial port. My Arduino code is shared on Github.
Hope that helps. When I have time, I will try to write a more detailed post on this.
Kevin
I am using android
If you are using Android, can you double check you’re using the correct UUIDs?
Your post mentioned using “DFB0” and “DFB1”. These are the iOS ones.
For Android, you need to use the longer UUIDs. See my post here:
http://www.cevinius.com/2016/08/17/serial-communication-with-the-bluno-using-bluetooth-le/
All the best.
Kevin
Hola amigos, soy estudiante de 10 grado. El proyecto Mobbob me gusto mucho asi que compre una placa arduino nano, un módulo bluetooth, los servos e imprimí las partes del mobbob. pero al cargar el programa me sale este error (si alguien me puede ayudar se lo agradeceria mucho):
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino: In function ‘void loop_Parser()’:
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1174:102: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
SetServos(tweenTime, currParam2Val, currParam3Val, currParam4Val, currParam5Val, “SV”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1180:30: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
StopAnim(“ST”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1186:39: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
StopAnimImmediate(“SI”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1198:78: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(walkForwardAnim, walkEndAnim, numTimes, “FW”);
^
E:\UsersobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1210:79: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(walkBackwardAnim, walkEndAnim, numTimes, “BW”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1222:68: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(turnLeftAnim, NULL, numTimes, “LT”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1234:69: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(turnRightAnim, NULL, numTimes, “RT”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1246:69: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(shakeHeadAnim, NULL, numTimes, “SX”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1258:66: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(bounceAnim, NULL, numTimes, “BX”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1270:66: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(wobbleAnim, NULL, numTimes, “WX”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1282:70: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(wobbleLeftAnim, NULL, numTimes, “WY”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1294:71: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(wobbleRightAnim, NULL, numTimes, “WZ”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1306:67: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(tapFeetAnim, NULL, numTimes, “TX”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1318:71: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(tapLeftFootAnim, NULL, numTimes, “TY”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1330:72: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(tapRightFootAnim, NULL, numTimes, “TZ”);
^
E:\Users(…)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1342:69: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(shakeLegsAnim, NULL, numTimes, “LX”);
^
E:\Users(….)MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1354:72: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(shakeLeftLegAnim, NULL, numTimes, “LY”);
^
E:\Users(….)\MobBob-Control-Bluetooth\MobBob-Control-Bluetooth.ino:1366:73: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
PlayAnimNumTimes(shakeRightLegAnim, NULL, numTimes, “LZ”);
el bluetooth se sincroniza con mi smartphone pero no envia nada
Hi Cevinius.. I don’t suppose any of your work with the Bluno could guide me into getting a Bluetooth connection with… (wait for it)….. WINDOWS !
DfRobot say not possible but there’s an add to the Windows IoT Git. No mention of Characteristics or Services though. Any help greatly appreciated.
Hi Mat,
I haven’t tried using Windows… so unfortunately, I don’t have any suggestions to help. 🙁
My guess would be that if you have a Windows library that can do BTLE… The UUIDs I found for the Characteristics and Services should be the same?? However that is purely a guess. Maybe have the Windows machines scan for devices/services and print out what it finds… If it can see the Bluno, I think it should be able to connect?
If you get some information, I’d love to find out the answer too!
Kevin