Introduction: Bluetooth and IMU With the Tactigon Board - Processing
This series of articles will explain how to use The Tactigon’s integrated sensors and communication interfaces to create a simple gesture controller.
In this article we’re going to learn how to use simple Tactigon’s functions to send accelerometer data and quaternions over Bluetooth Low Energy (BLE from now on).
We’ll look at, in details, to:
- Why Processing?
- Used Libraries
- UUID and Characteristic
- Connection To Device
- Get Data Stream
- Final Considerations
Step 1: Why Processing?
We choose processing because it’s a diffuse software sketchbook, simple and easy to start with. It offers Java and Android compatiblity, and usually it’s possible to port an application from Java to Android with little to no change in coding.
A lot of hobbyists use Processing, so it’s easy to find support, sketches and libraries, as well as in depth tutorials and communities.
Step 2: Used Libraries
This example uses few essential libraries:
We’ll focus on Blepdroid while other libraries are not the aim of this post.
This library is developed specifically for Processing, in Android environment.
Blepdroid is available at: https://github.com/joshuajnoble/blepdroid
Step 3: UUID and Characteristic
As we have seen in previous part, we send data from our Tactigon board with a specific UUID. We have to use the same Identifier in this code, to be able to intercept it and read associated Characteristic value.
This is the static String declaration:
public static String TACTIGON_QUAT_CHAR_STRING = “7ac71000-503d-4920-b000-acc000000001”;
Step 4: Connection to Device
The onDeviceDiscovered() function verify if the BLE device discovered is The Tactigon board or another one.
To listen to the characteristic, we have to call for onServiceDiscovered(). This function scans for available Characteristic and, if available, set the listener to the one with TACTIGON_QUAT_UUID uuid.
Step 5: Get the Data Stream
The onCharacteristicChanged() function will pull data out of the Characteristic byte data, reordering byte values to be able to plot them.
Step 6: Plot
Once obtained the right data to plot, a shift in the plot arrays is executed, freeign a position for the last gathered value. This arrays are now ready to be plotted on the chards by the draw() function.
Step 7: Final Considerations
This Processing sketch is just a simple way to get data and print on an Android screen. By using more advanced algorithms and Processing functions, it’s possible to integrate a gesture controller.
Stay tuned for more Tactigon’s code!