Introduction: Bluetooth and IMU With the Tactigon Board - Arduino

This series of articles will explain how to use The Tactigon’s integrated sensors and communication interfaces to create a simple gesture controller.

Source code available here on GitHub

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:

  • Used Libraries
  • UUID and Characteristic
  • Buffer
  • Final Considerations

Step 1: Used Libraries

This example uses few essential libraries:

  • tactigon_led.h
  • tactigon_imu.h
  • IMU_main.h
  • tactigon_BLE.h

First three libraries, have been analyzed on first part of this series, we now discover tactigon_BLE.h library.

tactigon_BLE.h
This library is dedicated to integrated BLE module. It provides few types needed to create a communication between two devices.

T_BLE is BLE Manager (bleManager instance in this example), it handles UUID, Characteristics and their buffer. In next examples we’ll see other methods of this class, handling connection and its status.

UUID is the universally unique identification, which, associated with a characteristic, allows to identify it by external devices.

T_BLE_Characteristic is the characteristic class. It needs an UUID and length in bytes of the payload it will transmit.

Step 2: UUID and Characteristic

In the setup function we created an uuid with the uuid.set() method.

The UUID needs to be unique at application level.

The String “7ac71000-503d-4920-b000-acc000000001″ used is unique since we use only this in our sketch.

We set the Characteristic (bleChar instance) with the bleManager.addNewChar() method, which instantiate a new Characteristic object by providing an UUID and the data length in byte (14 in this example).

Step 3: Sampling and Transmission Frequency

With the condition:

if(GetCurrentMilli() >= (ticks +(1000 / 50))){

ticks = GetCurrentMilli();

//acquisition

//buffering

//transmission

}

we let sensors acquisition, buffering and transmission happen at 50Hz.

Step 4: Buffer

An unsigned char array (also 14 bytes size) is used as buffer for the characteristic.

With memcpy we prepare this buffer, filling with sensors data.

memcpy(&buffData[0], &qData.q0, 2);

This execution of memcpy copies the memory area pointed by qData.q0, 2 bytes long, in the memory area pointed by buffData[0]. It’a a binary operation, so data type is not relevant.

Same applies for other Quaternions and Accelerometer data in this example.

Step 5: Data Transmission

Once the buffer has been prepared with all needed informations, bleChar.update(buffData) function is called.

This function notify bleChar that a buffer is ready for transmission.

The library will transmit it as soon as possible.

Step 6: Final Considerations

This sketch is another step towards the creation of a gesture monitor with The Tactigon. In next article we’ll look at how to receive and use data sent by this sketch in a processing environment.

Stay tuned for more Tactigon’s code!

Comments

About This Instructable

26views

0favorites

License:

Bio: Open board for 3D gesture control, motion capture, tracking and vibration measurement. The Tactigon is the perfect link between a HUMAN or an OBJECT and ... More »
More by The Tactigon:Bluetooth and IMU With the Tactigon Board - ProcessingBluetooth and IMU With the Tactigon Board - ArduinoThe Tactigon Accelerometer and LEDs Interaction
Add instructable to: