# A Low Energy IoT Application Using Beacon for Indoor Localization
## 5 Case of Study  
The architecture of the system described in the previous paragraph (see Figure 2) is essentially based on four fundamental components:  
* Four Bluetooth HC-05 modules comprising three anchors, or reference nodes (set in master mode), and one target (set in slave mode);
* The Arduino Pro Mini to manage and control the HC-05 master Bluetooth modules, which provide the RSSI values of the slave device;
* A coin cell breakout w/on-off switch (with 3 V CR2032 batteries) to power the HC-05 module, which acts as a slave;
* A computer to manage and process the values obtained from the exchange of information between the master and slave modules. The Bluetooth module used is the HC-05. It is a Bluetooth module that is programmable via AT commands and can be used in both master and slave modes. The commands AT + ROLE = 1 and AT + ROLE = 0 allow setting the master mode and the slave mode, respectively. Specifically, as already mentioned, four HC-05 Bluetooth modules are used: three in master mode, to be able to scan and search for other Bluetooth devices, and one in slave mode to be searched by the master modules. An Arduino Pro Mini is used to power and control the HC-05 master modules. The choice to use this card lies in the fact that it is compact and small, and therefore not bulky for applications and installations in small spaces. By connecting the board to the computer via these two components, it is possible to load any type of program using the development environment described in the next paragraph. Through the hardware connections between the HC-05 Bluetooth module and the coins cell for the wearable device, and between the Arduino Pro Mini board and the HC-05 Bluetooth module, it is possible to power the devices to make them wearable. Figure 5: Trilateration with 3 beacons. The series connection between the two CR2032 batteries allows for a total voltage of 6 V, the maximum power voltage allowed for the HC-05 Bluetooth module. In practice, this device acts only as a transmitter: it is the master devices that receive and process the data on the RSS value. Figure 6 shows the algorithm used in the proposed indoor localization system, while Figure 7 shows the complete system, including the three master Bluetooth modules and the slave Bluetooth module, to be located. The programming of the Arduino Pro Mini takes place through the use of a dedicated development environment, called IDE--Integrated Development Environment. The program, written in C and defined in sketch, always contains two functions, setup 0 and loop (), which contain both the settings necessary for the correct functioning of the devices that can be connected to the Arduino Pro Mini board and the instruction blocks to carry out what is required. The setup () function is used not only to initialize variables but also to set up serial communications. After the creation of the setup () function, which initializes and sets the initial values, the loop () function cyclically executes the program defined within it: it represents the main function that will be repeated indefinitely until the board is turned off. After writing all the code, we move on to the compilation phase, which, unlike the C language, is translated and completed essentially in the phase of loading the code on the board itself. In order to view the output, and therefore the result of the compiled code, it is necessary to use the serial monitor, defined in the Arduino development environment, by first clicking on the \"serial monitor\" button and then selecting the same speed, in baud, used in the serial call in order to be able to communicate correctly with the device. In order to obtain the information about the RSSI value from the slave device, it is necessary to define the necessary commands in the setup () function so that the HC-05 module can be enabled to search for other Bluetooth devices. Subsequently, in the loop () function, the AT +  
Figure 6: Algorithm for the calculation of coordinates. Figure 7: Indoor localization system proposed.