## 3 Hardware Development
### Power Supply
#### 3.4.1 Battery Lifetime Estimation  
The energy consumption of the IoT-GL-Sensor can be divided for analysis into two modes: sleep mode and active mode. Sleep mode is the period in which the device does not perform any tasks. In the same context, the device enters active mode when it acquires, processes, and transmits data. Therefore, the total energy consumed by the IoT-based device is composed of the energy consumed during the sleep period and the energy consumed during the active period [35]. In this application, the light sleep mode is used, as this turns off the CPU and system clock, but keeps the memory powered. This mode also follows the delivery traffic indication  
Figure 6: Schematic connection diagrams: (**a**) the MCU device; (**b**) the Wi-Fi device. message heartbeat in order to appear to be still associated with the gateway. Unlike deep sleep mode, which shuts down everything except the RTC memory, in this mode, the association with the gateway is lost and must be re-established. Table 4 shows the voltage and current consumed when the main devices are in sleep modes. These parameters were obtained from the respective datasheets. From Table 4, it is determined that the device in light sleep mode requires \(i_{Sleep}\) = 0.201 mA. That is, the current consumption per hour in this mode is \(i_{Sleep_{h}}\) = \((0.201)\cdot(3600)\) = 723.6 mAs. Additionally, the current required in active mode can be calculated as follows [35; 36]:  
\[i_{Active}=i_{WuMCU}+i_{Measure}+i_{ProData}+i_{WuWiFi}+i_{DataTrans} \tag{5}\]  
where \(i_{WuMCU}\) is the current required to wake up the MCU, \(i_{Measure}\) is the current used to activate sensors and perform the measurement, \(i_{ProData}\) is the current used for data processing, \(i_{WuWiFi}\) represents the current needed to wake up and connect the Wi-Fi to the network, and \(i_{DataTrans}\) is the current required to transmit the data to the gateway. Table 5 shows the time, voltage, and current parameters in active mode. The current required for each action is provided by the datasheet of each device. The active times of each action were measured with an oscilloscope. Substituting the values from Table 5 into Equation (5) results in \(i_{Active}\) = 0.01 + \((8+0.01+0.01)\) +16 + 120 = 144.03 mA. Since two measurements are made per day, the daily current consumption in active mode is \(i_{Active}\) = 288.06 mA. Two data transfers occur per day, with an average of \(\frac{2}{\pi}\) = 0.08333 data in one hour. Considering that the total time to transfer the two measurements in active mode (from Table 5) is \(t_{Active}\) = 8.4 s, per day, this averages to \(\frac{\pi}{4}\) = 0.35 s per hour. So, in one hour, it consumes on average a current of \(i_{Active_{h}}\) = \((0.08333)\cdot(0.35)\cdot(288.06)\) = 8.4017 mAs [37]. After calculating the average power consumption, the battery capacity (B.C. ) required to power the device can be selected. In this case, it is proposed to use three (1.5 V, 3000 mAh) AA-size batteries (Li-FeS\({}_{2}\)) connected in series, so the capacity is the same but with a voltage level of 4.5 V. Therefore, the lifespan (B.L.) of the battery bank can be evaluated as follows:  
\[B.L=\frac{B.C}{(i_{Sleep_{h}}+i_{Active_{h}})}=\frac{3000\;\text{mAh}\cdot 360 \;\text{s}}{(723.6\;\text{mAs}+8.4017\;\text{mAs})}=14,754.0641\;\text{h}=1.688\;\text{years} \tag{6}\] \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Device** & **Voltage [V]** & **Current in Light** & **Current in Deep** \\  & & **Sleep Mode [\(\mu\)A]** & **Sleep Mode [\(\mu\)A]** \\ \hline Sensor & 4.0 & 0 & 0 \\ MCU & 4.0 & 1 & 0.050 \\ Wi-Fi & 3.3 & 200 & 10 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Power consumption in sleep mode.