Next Article in Journal
A Task Planning Problem in a Home Care Business
Previous Article in Journal
Nonparametric Mean Estimation for Big-but-Biased Data
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Extended Abstract

Automation of the Data Acquisition System for Self-Quantification Devices †

by
Rodrigo Martín-Prieto
RNASA-IMEDIR Research Group, University of A Coruña, A Coruña 15001, Spain
Presented at the XoveTIC Congress, A Coruña, Spain, 27–28 September 2018.
Proceedings 2018, 2(18), 1184; https://doi.org/10.3390/proceedings2181184
Published: 19 September 2018
(This article belongs to the Proceedings of XoveTIC Congress 2018)

Abstract

:
In this paper we describe an environment that enables the interaction and data-fetching through a computer system from the Xiaomi Mi Band 2, a very popular and inexpensive Bluetooth Low Energy Fitness device, thus making it suitable for health-care long-term projects in which continuously gathering sleep and activity data is required. The environment is composed by a communication server running a custom library, exposed through both a shell command prompt and a RESTful API so it can be used by any other system connected to this server. The library is capable of connecting to an arbitrary number of devices at a time, bypassing many restrictions of the manufacturer’s proprietary application and not depending on an outgoing network connection to synchronize data between the system and the devices. In this paper we cover not only the process to enable communication with the target device from computers but also the architectural aspects of the developed system. We also provide brief information about the prototypes developed to test the system on a real ongoing geriatric study.

1. Introduction

Bluetooth Low Energy [1] (BLE henceforth) wearable fitness devices have become more and more ubiquitous and inexpensive in the later years [2]. These devices have become great and inexpensive tools to conduct clinical studies due to their capability to gather daily activity and sleep data without limiting the study subjects’ freedom [3].
Non clinical-oriented devices are intended for a rather individual use, making the user pair a single device to it’s personal smartphone instead of being able to collect the raw data from multiple wearable devices from a computer.
Despite the limitations imposed by commercial lower-end wearable devices, they are already being used in experiments in fields such as pediatrics and gerontology with satisfying results [4]. The main issue is that these limitations impose a cap to how many subjects can take part in an experiment as working with one-to-one pairing and without having methods to automatically extract the required data, this has to be done manually.

2. Objectives

The main objective is to reverse engineer an inexpensive, common and lower-end fitness device, the Mi Band 2 by the Chinese manufacturer XiaoMi and develop a library that is able to seamlessly connect to this kind of device and gather data from many of them at a time to enable these devices for research use. Associated to this library there will be some other tools to expose its core functionality and be able to develop software on top of it. Namely, these tools would be:
  • Shell: A command line to interact with the surrounding devices and command the computer to fetch the raw data from them
  • REST API: A simple API to expose the funcionality of the library to other technologies and be able to integrate it in more complex projects.

3. Materials and Methods

The first stage of the project was getting to know the profile of the Mi Band 2 as a BLE Peripheral and the commands that need to be issued in order to connect, authenticate and fetch the activity data from the device. This was done through the use of Android development tools and a Bluetooth Sniffing device alongside with the official Mi Fit smartphone application to register the most important ones. After this, we were able to obtain a full specification of all the endpoints of the Mi Band 2 and at least the relevant commands and response codes to perform the functionality we were aiming for. These commands were later implemented in Python to create our own independent library with the aid of the Python module “bluePy” to avoid implementing low-level Bluetooth functionality. Mi Band 2 devices were modeled in a Python Class that inherited from bluePy’s generic own BLE Peripheral Class and then the extracted BLE commands and responses were implemented as Class methods of our Mi Band 2 Class.
As for the library-related tools, the SHELL was developed alongside the library to test it’s functionality and conduct early prototype tests, while the API was developed once the main methods for authentication, connection and activity data fetching worked as expected. The REST API was finally used to integrate the library with the GeriaTIC project through a module inside their own platform: ClepITO.
Initially, we proposed a fully distributed architecture to integrate the library with the ClepITO platform. The library would run inside a Data Automatic Acquisition Server in a Linux System and then would connect to the platform’s own database to read and store data, while the ClepITO platform would control the Acquisition Server through HTTP requests making use of the REST API.
Due to some limitations of the project, we ended up using a fully integrated architecture, implementing the server inside a Linux virtual machine running in the same server as the ClepITO platform, and connecting both systems through a host-only network that provided bidirectional access to both systems, allowing for the same functionality as in a distributed environment but encapsulating everything under the same physical system. (See Figure 1)

4. Results and Conclusions

To test the library’s capabilities, two field tests were conducted during two visits to one of the centers associated with the GeriaTIC project located at Carballo, A Corunna. The first one was done early in the development of the library, making use of the Shell developed to test the library, while the second one made use of the REST API. Both tests resulted successful, and we were able to seamlessly gather data from all of the study participants. The first test took a few minutes to connect and fetch all of the data from the devices, but this time was greatly improved to less than a minute per device for the second test.
The data extracted by hand from the Mi Fit application is previously aggregated by the application’s own algorithms, while being able to autonomously fetch the data from these devices provide us with a minute-by-minute data feed that we can manipulate and interpret at will, resulting in an improvement of the data quality. To conclude, we were able to develop a complete novel system capable of communicating a computer with a closed-source wearable device, the Mi Band 2, and improved the data gathering process in effort and time. By doing so, we have not only improved the methods and results of the GeriaTIC project but also have enabled other similar projects to perform better than before and it’s our hope that we have encouraged them to use inexpensive wearable devices such as the Mi Band 2 to improve these studies.
This work is, in the end, a proof of concept about BLE devices and how we can communicate with them in ways that they were not initially meant to, and how these same devices can help in health-care areas. This research also manifests the need of more accessible and open wearable devices so researchers can conduct more and better studies without having to crack open closed devices for that mean. As both the Mi Band 2 and the Mi Fit application are closed-source, we lack the ability to know for sure if our implementation of the commands to communicate with the device is complete, or if our way of interpreting and aggregating the data is completely correct, so there is still work and tests that need to be done in order to assure that these are as good or better than the originals.

Acknowledgments

Thanks to Eloy Naveira [5] for his little, but meaningful speech about his undergraduate thesis on opening the Mi Band 1 during the master course I attended to. This speech was the last push I needed to start working on opening the Mi Band 2. Also thanks to the FreeYourGadget community for providing with their constant knowledge and the source of the GadgetBridge Android application, that helped me understand the inner workings of the Mi Band 2. Last but not least, thanks to Javier Pereira and the RNASA-IMEDIR laboratory, as well as the CITIC, for supporting my research both materially and economically. Without this support it would have been extremely difficult to conduct all of these tasks and take this research to a good end.

Conflicts of Interest

The author declares no conflict of interest. The founding sponsors had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, and in the decision to publish the results.

References

  1. Gómez:, C.; Oller, J.; Paradells, J. Overview and Evaluation of Bluetooth Low Energy: An Emerging Low-Power Wireless Technology. Sensors 2012, 12, 11734–11753. [Google Scholar] [CrossRef]
  2. Wearable Device Shipments Worldwide from 2016 to 2022. Available online: https://www.statista.com/statistics/610478/wearable-device-shipments-worldwide (accessed on 20 June 2018).
  3. Technologies for Participatory Medicine and Health Promotion in the Elderly Population (GERIATIC). Available online: https://clinicaltrials.gov/ct2/show/study/NCT03504813?cntry=ES (accessed on 20 June 2018).
  4. Saner, H. Wearable Sensors for Assisted Living in Elderly People. Front. ICT 2018, 5, 1. [Google Scholar] [CrossRef]
  5. Naveira, E. Medical Sensors to Prevent Sedentarism. Undergraduate Thesis, University of A Coruña, A Coruña, Spain, September 2016. (In Spanish). [Google Scholar]
Figure 1. (a) Initial design for the full system’s architecture. Each element is encapsulated on it’s own subsystem and interconnected by local or external networks for maximum flexibility. (b) Final design for the full system’s architecture. All of the elements are packed under the same super-system due to project’s requirements and for ease of replication purposes.
Figure 1. (a) Initial design for the full system’s architecture. Each element is encapsulated on it’s own subsystem and interconnected by local or external networks for maximum flexibility. (b) Final design for the full system’s architecture. All of the elements are packed under the same super-system due to project’s requirements and for ease of replication purposes.
Proceedings 02 01184 g001
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Martín-Prieto, R. Automation of the Data Acquisition System for Self-Quantification Devices. Proceedings 2018, 2, 1184. https://doi.org/10.3390/proceedings2181184

AMA Style

Martín-Prieto R. Automation of the Data Acquisition System for Self-Quantification Devices. Proceedings. 2018; 2(18):1184. https://doi.org/10.3390/proceedings2181184

Chicago/Turabian Style

Martín-Prieto, Rodrigo. 2018. "Automation of the Data Acquisition System for Self-Quantification Devices" Proceedings 2, no. 18: 1184. https://doi.org/10.3390/proceedings2181184

APA Style

Martín-Prieto, R. (2018). Automation of the Data Acquisition System for Self-Quantification Devices. Proceedings, 2(18), 1184. https://doi.org/10.3390/proceedings2181184

Article Metrics

Back to TopTop