## 3 Wireless Sensor Networks
### System Design
#### 3.1.3 Sensors Used in Transmitter Type SPWS  
The Silicon Labs (Silicon Labs, Austin, TX, USA) Si7021; and Sensirion (Sensirion, Stafa, Switzerland) SHT2 sensors were considered for the measurement of air temperature and relative humidity: In both, the two variables are measured by the same device, allowing a decrease in the PCB (printed circuit board) size. Other factors taken into account in the selection were the accuracy and energy consumption. Among the two sensors the Si7021 was chosen, since it presented smaller energy consumption, and its design had already HVAC applications in mind. It uses an I\({}^{2}\)C bus for communication with the microcontroller, requiring only two pins besides VDD and GND: SCL (a serial clock line) and DATA (a serial data line). The digitized temperature and relative humidity values provided by the sensor must be converted to the corresponding units using Equations (7) and (8):  
\[TA_{i}(^{\circ}\mathrm{C})=\frac{175.72\times T_{s}}{65,536}-46.85 \tag{7}\]  
\[RH_{i}=\frac{125\times RH_{s}}{65,536}-6, \tag{8}\]  
where \(TA_{i}(^{\circ}\mathrm{C})\) and \(RH_{i}\)(%) are the air temperature and relative humidity given in degrees Celsius and percentage, respectively, and \(T_{s}\) and \(RH_{s}\) are the 16-bit words given by the device. The accuracy values for temperature and for relative humidity are \(\pm 0.4\)\({}^{\circ}\mathrm{C}\) and \(\pm 3\)%, respectively. With the goal of preserving the battery charge, the required computations are offloaded to the collector or storage nodes, which means the WSN transmits the 16-bit words given by the device. To shorten the acquisition time and therefore decrease consumption energy, the VDD, DATA and SCL pins were implemented by means of general I/O pins programed in the microcontroller firmware. This enables using shorter I\({}^{2}\)C clock periods, therefore allowing faster operation that consequently requires less energy. Room Activity Sensor  
A Passive Infra-Red (PIR) motion sensor was used to detect movement in rooms. The Panasonic EKMC1601111 sensor was selected, as it presents a good compromise between size, current consumption (170 \(\upmu\)A) and 30 s of warm-up time. This component is easily attached to the microcontroller, requiring a single pin to read the sensor output (high for movement, ground otherwise). The room activity is then obtained as the fraction of samples for which the output pin is in a high state, in each minute. Door/Window State Sensor  
Magnetic need switch sensors were employed to detect the state (open or closed) of windows and doors. Two devices were tested: Comus S1372 and Hamlin 59150-030. The latter was chosen due to its price and easiness of mounting on a surface. As mentioned before, the MRT is estimated employing measurements of wall temperatures. A common PT1000 surface contact temperature sensor is used, which shows very good resistance linearity with temperature. A Wheatstone bridge and amplifier circuit (Texas Instruments INA126 UA [28] instrumentation amplifier) was employed to scale its terminals differential voltage to the microcontroller's ADC input range. The wall temperature is then obtained as:  
\[T_{W}(^{\circ}\mathrm{C})=\frac{[R_{PT1000}-R0_{PT1000}]}{3.85}, \tag{9}\]  
where \(R_{PT1000}\) is the sensor resistance sampled by the microcontroller's ADC, and \(R0_{PT100}\) is a baseline resistance of 1000 Ohms, obtained by the PT1000 at 0 \({}^{\circ}\mathrm{C}\). To provide accuracy within 0.5 \({}^{\circ}\mathrm{C}\), all sensors were calibrated. Calibration was performed by means of the SHT25 sensor (accuracy within 0.4 \({}^{\circ}\mathrm{C}\)), dipped in glycerin with PT1000 sensors. After recording a number of temperatures, linear regression was used to find the calibration factor to apply. As for the Si7021 sensor, the WSN transmits the 10-bit word corresponding to the ADC quantization, leaving all the required computations to be done at the collector or storage nodes, therefore preserving the battery charge.