In this page you will find the description of how I built a box called Multidimensional Box. It is a box with different sensor and accessories able to display and distribute via BLE the output from its sensors
If you need additional specific information about this topic or if you want to look it personally please write an email
Arduino is one of the most interesting controller to use with all the different sensor modules available on the market. Sooner or later you will need to integrate a specific sensor in order to build something needed for your life or for your job, so it
could be very cool to anticipate some work testing some of the main sensors and technologies you can encounter in the future. In this specific project I used a GPS module, a Sonar and a BlueTooth module to build an indipendent box. This box is powered by two lipo batteries
and results will be displayed on a smal led panel.
The name multidimensional comes from different aspects of this project. First of all it uses different sensors so it impacts different 'Dimension' of the word.
Last but not least it uses two interesting components available on the basic Arduino 101. The GPS and the accellerometer.
Thanks to these two components we can evaluate the space surrounding it in all the dimension (X-Y-Z and speed)
#include
Then you need to create instances and characteristics. In the following code I created the instance of the peripheral and declared a service
to distribute the accellerometer data coming from the 101 accellerometer. For the accellerometer service I will create 3 carachteristics (Yaw, Pitch and Roll)
BLEPeripheral blePeripheral; // create peripheral instance
BLEService AccellerometerService("F000AA1-0451-4000-B000-000000000000"); // create service
//Yaw, Pitch and Roll Charactheristics (Only read and Notify)
BLEFloatCharacteristic YawCharacteristic("F000AA11-0451-4000-B000-000000000000", BLERead | BLENotify);
BLEFloatCharacteristic PitchCharacteristic("F000AA12-0451-4000-B000-000000000000", BLERead | BLENotify);
BLEFloatCharacteristic RollCharacteristic("F000AA13-0451-4000-B000-000000000000", BLERead | BLENotify);
Following you will see the inizialization code and the start of the ble service
blePeripheral.setLocalName("Accellerometer");
blePeripheral.setDeviceName("VicSensorCentral");
// set the UUID for the service this peripheral advertises:
blePeripheral.setAdvertisedServiceUuid(AccellerometerService.uuid());
// add service and characteristics
blePeripheral.addAttribute(AccellerometerService);
blePeripheral.addAttribute(YawCharacteristic);
blePeripheral.addAttribute(PitchCharacteristic);
blePeripheral.addAttribute(RollCharacteristic);
YawCharacteristic.setValue(0);
PitchCharacteristic.setValue(0);
RollCharacteristic.setValue(0);
// advertise the service
blePeripheral.begin();
From now on the service is live and you can read it using a debugger or using a read service built in another application
If you want to check if a device is connected (just to save time not writing information on carachteristics) you can use the following sentences
BLECentral central = blePeripheral.central();
// if a central is connected to peripheral:
if (central) { ...
Once you want to write a carachteristics you will simply need to invoke the SetValue function
YawCharacteristic.setValue(filter.getYaw());
PitchCharacteristic.setValue(filter.getPitch());
RollCharacteristic.setValue(filter.getRoll());
in this case the filter structure is the Magdwik structure used to read the CurieIMU accellerometer values. But it returns a long value so you can use it for anything you want to distribute over the BLE protocol.