# A Low Energy IoT Application Using Beacon for Indoor Localization
## 6 Experimental Results  
This chapter shows the results obtained from the experimental tests carried out in a closed place without interference, considering a well-defined area. For each distance, the reference nodes, in automatic and continuous mode, scan the mobile node obtaining the RSSI parameter converted into distance. The data obtained are saved in a text file via serial connection and subsequently managed in order to obtain the coordinates (x, y). In order to better evaluate the indoor localization methodologies, it is necessary to take into account a set of metric parameters, such as precision, recall, accuracy and F1-score. The source code loaded on the cards allows to take advantage of the AT mode of the HC-05 module and to initialize the device so that it can perform a Bluetooth scan. Once you have loaded the sketch on the Arduino Pro Mini you have to:  
* Choose the area of interest and divide it into N-zones;
* Make the connection as shown in Figure 7;
* Connect the Arduino Pro Mini boards to the pc via the FTDI adapter and USB cable;
* Open the serial monitors using a computer in order to store the RSSI values obtained from each single reading in a file, in tkt format;
* Perform the tests by placing the slave in the selected area, starting the three reference devices simultaneously. Once the slave module is turned on, the three reference modules, positioned at known distances from each other, provide an indication of the RSS value of the Bluetooth module to be located. The power value of each single master is very important as it allows you to determine the distance between the reference Bluetooth module and the target Bluetooth. The conversion from RSSI value to distance is done through the following steps:  
* LISTA Read RSSI value: The master devices get the RSS value from the scan of the target Bluetooth module;
* LISTA Distance calculation: Once the RSS value in dBm is obtained, the distance can be calculated, using the formula \(RSSI=-\left(10n\log_{10}d-P_{d0}\right)\). In order to convert the RSSI value into distance, it is necessary to perform a calibration test in order to define both the RSSI value at a distance of 1 m from the source and the value of the signal propagation constant. The knowledge of these two parameters allows the conversion from dBm to meters. To achieve the final goal, several tests were carried out to test the behavior of the RSSI values of the master devices as a function of the coordinates (x, y). The experimental testscarried out were carried out by holding the wearable device still in a specific area. A static test was carried out by placing the master devices at 8 m each and dividing the area into 16 zones of area 2 \(\times\) 2 m, as shown in Table 4.  
The choice to use this initial arrangement is linked to the fact that the HC-05 devices transmit at a maximum distance of 10 m: at the extreme points, in fact, the slave is just over 10 m away from the masters. A total of 60 measurements were made for each single zone. Taking into consideration the zone (3; 3) it can be seen from Figure 8 the presence of a high number of coordinates outside the reference zone. The values that fall within the marked area are defined as true positives (true positive--TP), while those outsides are called false negatives (false negative--FN). To determine all the parameters for the calculation of precision, recall, accuracy and F1-score, all the areas adjacent to the area under examination are then considered. False positives are all those measures associated with the adjacent areas which, erroneously, are positioned within the area considered (false positive--FP); the external ones, however, are defined as true negatives (true negative--TN), intended as errors of classification. The dispersion of the data is caused by measurement errors: a small error on each single beacon, even of 1 dBm, corresponds to a large error of the coordinates (x, y). The knowledge of the values defined as true negatives, on the other hand, allows the calculation of the accuracy.