4.1.1. CGM Sensor

There are a number of companies that manufacture and distribute commercial CGMs, being Dexcom [59], Medtronic [60] and Abbot [61], the most active in the field. Their most relevant and latest CGMs are compared in Table 1 together with some popular sensor-integrated insulin pump systems that are connected to specific CGM systems (e.g., MiniMed 670G). Additional systems and their main characteristics can be found in [62].


**Table 1.** Comparison of the characteristics of the most popular CGMs.

Among the analyzed CGMs, Abbott's Freestyle Libre was chosen. Although its reading range is limited (up to 10 cm) due to the use of Near Field Communication (NFC), the sensor lasts longer than others provided by Dexcom or Medtronic (14 days versus roughly a week), it is cheaper than other solutions (e.g., a kit with one reader and sensors currently costs e 169.69), finger-pricking is not necessary on a daily basis to calibrate the sensor and it is more accurate than other systems (i.e., it has a lower Mean Absolute Relative Difference (MARD)).

Note that it would be possible to make use of the second generation of Abbot's CGM (Freestyle Libre 2), which provides better MARD, but it was not available for purchase at the beginning of the work related to this article and, in practice, it is essentially the same device.

Abbott's Freestyle Libre sensor is placed on an arm by using a single-use applicator (in Figure 2, on the left). On the right of Figure 2 it is shown the sensor adhered to the optimum location, in the back of the upper arm. After activating the sensor, it takes roughly one hour before the first readings are available. Then, according to Abbot, the sensor will collect data during a maximum of 14 days (in practice, it has been observed that the sensor keeps on collecting data during almost one day more). In addition, note that each Freestyle Libre sensor also has a commercial expiration date that limits its usage time interval.

(**A**) (**B**) **Figure 2.** Abbott's Freestyle Libre sensor and applicator (**A**), and adhered sensor (**B**).

To collect readings from the sensor, the user just has to scan it with Abbot's reader or with an NFC-enabled smartphone that runs Abbot's LibreLink app. The sensor collects readings automatically every 15 min. It is necessary to scan the sensor at least once every 8 h, since the sensor stores up to 8 h of readings. Readings are stored in the internal memory of the sensor, whose structure was previously reverse engineered (at least in part) by open-source initiatives like LibreMonitor [63] or LimiTTer [64]. The most relevant parts of the sensor internal memory are illustrated in Figure 3. As it can be observed, the memory is structured into 344 bytes that are divided into a header, a footer and the main memory fields, which are the following:


**Figure 3.** Structure of the internal memory (in byte) of Abbot's Freestyle Libre sensor.

### 4.1.2. Decentralized Storage

In order to store the collected data, the proposed system makes use of the decentralized database OrbitDB [65], which runs over InterPlanetary File System (IPFS) [66]. Specifically, OrbitDB uses IPFS for storing data and for synchronizing multiple peer databases.

OrbitDB nodes can fetch content if there are connected peers in the swarm that share the database. Obviously, in order to replicate a database, at least one node must be connected to the swarm. Nodes can use the REST API to create/open a database and then add data to them. In the system implemented for this article the database was defined as an eventlog, which creates an append-only log. Fetching and synchronizing data are automatically orchestrated by OrbitDB, so this functionality does not need to be implemented by the REST API.

During the experiments presented in this article OrbitDB nodes were running on a fog gateway and in a virtual machine on a remote cloud on the Internet. In this latter case, the virtual machine make use of two AMD Opteron 3.1 Ghz cores and 8 GB of RAM.
