Senk
A highly configurable device equipped with accelerometer and gyroscope sensors, built using Arduino Nicla Sense ME.
Introduction
Senk is a project designed to create a versatile, energy-efficient device that leverages the capabilities of the Arduino Nicla Sense ME. It integrates accelerometer and gyroscope sensors and offers high configurability via a simple configuration file.
Objectives
The primary objectives of this project include:
- Sensor Integration: Utilize the accelerometer and gyroscope sensors provided by Nicla Sense ME.
- Configurability: Design the device to be highly configurable using a simple configuration file, allowing for versatile applications.
- Energy Efficiency: Implement energy-efficient practices to optimize power consumption.
- Data Handling: Enable the device to store sensor data in its internal memory and facilitate data transmission via Bluetooth Low Energy.
Implementation Analysis
Hardware Configuration
Arduino Nicla Sense ME
The foundation of the entire system relies on the Arduino Nicla Sense ME. This versatile platform integrates various sensors and communication modules crucial for the project.
BHI260AP - 16-Bit 6-Axis IMU
The cornerstone sensor, BHI260AP, serves as a 16-bit 6-axis Inertial Measurement Unit (IMU), encompassing a 3-axis accelerometer and a 3-axis gyroscope. This pivotal component captures essential acceleration and gyroscope data from the surrounding environment.
2MB QSPI Flash Memory
The 2MB QSPI flash memory plays a vital role in storing system data. However, it’s essential to note that the write speed of this memory is relatively slow.
Bluetooth 5.0 Low Energy (BLE)
To optimize energy consumption, the project strategically utilizes Bluetooth Low Energy (BLE) for data communication. This efficient protocol ensures seamless transmission of data acquired by the system, prioritizing energy efficiency in the overall implementation.
Software
System Overview
Configuration
The system is designed to provide high modularity without sacrificing performance and energy efficiency. To achieve this, we utilize #define
directives to configure various settings. When a configuration is turned off, all associated resources that would be utilized if it were activated are excluded and uninitialized, saving energy and memory.
DataSet Management
To enhance modularity and save more energy, the system organizes data into datasets. Specifically, data is collected every DISTANCE_BETWEEN_SET
seconds, with DATA_PER_SET
data points captured at intervals of DATA_DISTANCE
. This dataset approach allows for high-frequency data acquisition without continuous sampling, resulting in significant battery savings.
DataSet Splitting
Given our device’s limited RAM capacity, it’s necessary to segment the dataset into smaller parts, each with a maximum length of MAX_DATASET_DIMENSION more info here. After processing each segment of the complete dataset, the data is dynamically managed: it can either be stored in local memory or transmitted using Bluetooth Low Energy (BLE), depending on the configuration settings.
It’s important to acknowledge that this segmentation process might cause a minor slowdown, particularly when saving data to local storage. Consider this while optimizing for swift data processing.
To optimize this process, we have introduced an option in the application to enable data transmission via BLE between one dataset part and another in a different thread. This ensures that the distance between various data remains unchanged. However, it’s important to note that enabling this may result in a slight increase in energy consumption.
BLE Data Acquisition
Data is shared via BLE, specifically through the creation of a DataSend
service with a UUID specified in the configuration file. Within this service, two characteristics, namely Accelerometer
and Gyroscope
, are established. Both characteristics have UUIDs that can be configured through the settings file (for more information, refer to here).
Both characteristics transmit an array of short values representing XYZ data. It is important to note that the data is transmitted in little-endian format.
For example, if our gyroscope sends something like 0xFFFF0F000200, the corresponding axes values are X: -1, Y: 15, Z: 2.
If needed, a conversion script is available here to translate the transmitted data into axis values.\
Class Overview
Senk [main]
This is the main sketch, managing sensor data acquisition with a focus on modularity and energy efficiency. Key components include sensor handling, conditional initialization of modules like DataSaver
and BLECommunication
, setup routines, data acquisition loop, and data transmission.
Data
The Data
class encapsulates the representation and manipulation of sensor data, providing methods to convert, retrieve, and present information.
DataSaver
The DataSaver
class manages the storage and retrieval of sensor data, offering functionality to save data to local storage, format storage, print file contents, and retrieve specific datasets.
BLECommunication
The BLECommunication
class serves as the central manager for BLE communication, enabling the transmission of sensor data within the system. This class encapsulates crucial functions to handle initialization, data transmission, and BLE characteristic management.
Util
This collection comprises several utility functions designed specifically for this application, such as capturing datasets, sending data via BLE, and saving data to local storage.
Optimization Strategies
Within the scope of this project, prioritizing resource and energy efficiency emerged as a pivotal focus during development. To accomplish this objective, several optimization techniques were implemented:
-
Initialization via Define: Employed
#define
directives for configuration settings, optimizing resource allocation by excluding and initializing unused configurations, thereby conserving energy and memory. -
Simulated High-Frequency Data Acquisition: Alternated high-frequency data collection intervals with periods of inactivity to ensure data availability while conserving battery power, avoiding continuous sampling during idle periods.
-
Utilization of BLE (Bluetooth Low Energy): Leveraged BLE technology for efficient data transmission, minimizing power consumption compared to traditional Bluetooth, and enhancing energy efficiency in data transfer operations.
-
Multi-threaded Data Management: Implemented multiple threads to manage continuous data capture and transmission between parts of the dataset, ensuring minimal delay and consistent data flow.
For a detailed exploration of device power consumption strategies, refer to the dedicated section on Power Consumption, and read some discussions on how to optimize power usage here.
Installation and Configuration
Prerequisites
- Hardware Setup: Ensure you have the Nicla Sense ME properly connected to your device.
- Arduino IDE: Install the Arduino IDE on your development machine.
- Required Libraries: Make sure to have the following libraries installed in your Arduino IDE:
- Nicla_System
- Arduino_BHY2
- LittleFileSystem
- ArduinoBLE
- mbed
- File
- FileSystem
Installation
- Download the Project: Clone or download the Senk project from the repository.
- Open Project in Arduino IDE: Load the Senk project by selecting the Senk.ino file.
- Configure the Arduino IDE: Ensure you have the necessary board and port selected in the Arduino IDE.
- Configure Senk: Customize Senk according to your preferences by following the configuration guide.
- Upload the Code: Upload the Senk code to your Nicla Sense ME.
Useful Links
For more detailed information and guidance, visit the project’s official documentation and GitHub repository.