## 3 Materials and Methods
### LoRa System Signal Coverage-Characterization
#### 3.1.2 Methods  
The data packets are sent to a LoRa gateway using a simple custom-built LoRa packet format. The information that reaches the gateway is processed by a server service app that publishes the information in an MQTT server (running on a Raspberry Pi). The data is  
Figure 1: Implemented Long-Range (LoRa) Gateway system. (**a**) Schematic of the LoRa communication test device equipped with various sensors on an electronic breadboard. (**b**) Diagram of the communication process. retrieved from the server, displayed on a Graphical User Interface (GUI), and stored in a file or database using Node-RED-see the schematic of the communication process in Figure 1b. The Node-RED's GUI is made available in an online domain, making the measurements remotely accessible in real-time, e.g., via a smartphone (Galaxy S6, Samsung). The microcontroller is programmed to send one data packet per second to the server for the signal-coverage measurements. Node-RED is used to display the received data and monitor the time elapsed between consecutive received packets. Since the signal time-of-flight is much shorter (picoseconds) than 1 s, one can assume that if the time interval between successive received packets is larger than 1 s, then one or more packets were lost. Hence, the time gap between received packets can be used to determine the coverage area by defining a maximum delay threshold and asserting that if the delay is below or above the threshold, then the communication is either established or broken, respectively. The transceiver location is tracked using the smartphone GPS and recorded using the Android app, Geo Tracker [50]. The mobile system (LoRa transceiver and smartphone) is then moved around the University campus in Ourense, while position-correlated time-between-packets measurements are collected and stored for analysis. The analysis consists of overlaying the reception rate with the GPS coordinates. The GPS coordinates are converted from angular to Cartesian using the Mercator projection:  
\[x(t)=(R_{0}+h(t))(\theta(t)-\theta_{0}), \tag{1}\]  
\[y(t)=\ (R_{0}+h(t))\log\left[\tan\left(\frac{\pi}{4}+\frac{\phi(t)}{2}\right) \right], \tag{2}\]  
where \(x(t)\) and \(y(t)\) are the time-dependent Cartesian coordinates. \(\theta(t)\), \(\phi(t)\) are the time-dependent longitude, latitude, and altitude, respectively, in radians, and \(h(t)\) is the time-dependent altitude in meters. Table 1 shows the values used for the Greenwich meridian reference \(\theta_{0}\) and Earth's radius \(R_{0}\). After obtaining time gaps between packet arrivals over the emitter trajectory, we use a simple interpolation method to create 2D maps of the time gap between packet arrivals. The developed process works similarly to a flood-fill algorithm, and in the following, we describe its use and function. First, a zero-filled 2D matrix of appropriate dimensions to represent the city map, e.g., 1 pixel per meter, is created, such that, e.g., a 700 \(\times\) 700 m\({}^{2}\) city map is represented by a 700 \(\times\) 700 pixel matrix. The matrix cells (pixels) are then assigned to the measured time gap between packet arrivals following the relative GPS location data. Simultaneously, for those areas in which there are no measurements, the pixel entries remain zero. Optionally, it assigns the points beyond a certain (arbitrary) maximum radius with the maximum measured time gap between packet arrivals to prevent undesired outwards signal spreading. The resulting matrix is fed as starting point to the algorithm. The iterative algorithm assigns each zero-cell with the average of its non-zero closest neighbors. After each iteration, the map of the time gap between packet arrivals spreads 1 pixel in every direction, stemming from the original locations with the measured time gap between packet arrivals. The number of iterations required to fill the map depends on both the chosen matrix size and the number of points, and the spatial trajectory and shape.