## 4 Experiments
### Experimental Testbed  
The WSN built for research purposes consists of four smart sensor nodes. Three of the sensor nodes can act as cluster head or cluster member. The fourth node is used as sink. Each node of the WSN contains a microcontroller, a communication module and an analogue light sensor ALS-PT19. The measurement of energy consumption is performed by using LTC4150 Coulomb counter [34], which is an external module of the microcontroller. The Coulomb counter is useful in measuring the depletion of battery energy in wireless devices. It enables continuous current measurement in situation where long-term observation is required. The measuring process is based on differential measurement over a shunt, i.e., a resistor that has a small amount of resistance and is connected in series. The Coulomb counter detects potential difference (voltage drop) across the resistor and determines current flowing through the circuit using [PERSON]'s law. Due to parameters of the internal resistor and the maximum energy consumption of the sensor node, the smallest amount of energy to be measured is 26 uAh. The LTC4150 module generate impulse on an output pin each time 0.1707 mAh is absorbed by the sensor node. These impulses are counted by  
Figure 2: Initialization process for 3 nodes in WSN cluster. an additional microcontroller to evaluate the energy consumption over a long period of time. It was assumed that all sensor nodes have the same battery capacity of 700 mAh. When designing smart sensor nodes, two families of microcontrollers were taken into account: ARM and AVR. Both can switch off unused functional blocks, but differ in the approach to energy saving. The microcontrollers of AVR family (AT Tiny, ATMega) by default have all modules such as \(ADC\), \(I^{2}C\), \(SPI\) enabled. Different approach is used in ARM systems. Here, initially all modules are switched off. It is also possible to turn off the power supply to individual input/output ports, which in the case of the aforementioned AVR family of microcontrollers is not possible. In this research the ARM microcontroller was used (STM32F103), which is clocked at 72 MHz frequency and offers greater accuracy of timers, enabling better synchronization of sensor nodes, while maintaining compact dimensions of the device. The wireless communication module installed in sensor nodes is based on ZigBee technology (xBee S2C), which provides wireless end-point connectivity to devices. These modules use DigiMesh firmware developed by Digi. DigiMesh simplifies network configuration and increases reliability in conditions where devices required for network operation may fail. Moreover, this technology is easy to use. The xBee modules support multiple network topologies such as point to point, point to multi-point, mesh, and cluster tree. The system includes an implemented data retransmission mechanism. The electrical diagram of the test environment for single sensor node was shown in Figure 3.  
As shown in Figure 3. an additional node (microcontroller without wireless communication module) is included in the experimental testbed to measure the energy consumption for all sensor nodes. The measurements collected by the additional nodes are not available for the sensor nodes and are used only for evaluation of the WSN lifetime. Thus, the sensor nodes cannot use these measurements for making decisions about CH rotation. Initial research was conducted to verify the possibility of evaluating both the energy consumption and the WSN lifetime with use of sensor nodes powered from batteries. However, when repeating the measurement with the same settings, significantly different results were obtained. This problem occurs due to the fact that the batteries are never charged exactly in the same level. To solve this problem a power supply unit, Mean Well APV-12-5 [35], was used during experiments. The lifetime of WSN was determined for each analyzed scenario by the additional node, which performs measurements of energy consumption.