# Design and Application of a Smart Lighting System Based on Distributed Wireless Sensor Networks
## 3 Materials and Methods
### Lighting Control Based on Rules
#### 3.3.1. Lighting Control Rules for Office Environment  
An indoor environment can be divided into multiple zones, each of which requires different lighting conditions. For instance, in Figure 6, an office space with three zone types are presented, Zones A, B, and C. Zone A is for leisure time, while zones B and C are for working. Zone B is near the windows, having great potential for harvesting daylight. On the contrary, zones A and C lack natural light, and daylight harvesting cannot be conducted in these zones. Moreover, body motion in Zone A is usually large, making it easy to sense occupancy. However, in Zones B and C, small movements often occur. The layout of the sensors is given in Table 2. The lighting control rules are obtained based on Equation (2) and considering environmental conditions and user preferences are listed in Table 3. When occupants are detected, and the associated LED is dimmed according to the rules, the neighbor LEDs will also be triggered, as presented in Figure 5.  
For Zones A and C, since the daylight harvesting cannot be implemented, when occupancy is detected, the dimming levels of the associated LED and its neighbors are set to 100%. When the occupancy state is unoccupied, and its neighbors' states are unoccupied, the dimming level is related to the stage type in Table 3. On stage 1, 2, or 6, the dimming level of the unoccupied state is set to 0%; this is nonworking time, and aggressive energy management can be utilized. On stage 3 or 5, the dimming level is set to 10% with no occupancy in order to decrease the impact of illuminance change when people enter the sensing area and improve the comfort level. Stage 4 is the lunch-break time, during which staff can take a nap in the office with dimming level of 10%. For Zone B, the control rules are the same as for Zones A and C on stages 1 and 6 when the daylight illuminance is weak and in stage 4 when the dimming level of lights are set to 10% for lunch break. In stages 2, 3, and 5, daylight harvesting is implemented in Zone B. According to the distance to the window, Zone B is subdivided into two parts: primary zone (PZ) and secondary zone (SZ), shown in Figure 7. The PZ represents the area adjacent to the window, the SZ represents the area adjacent to the PZ. The dimming level of a LED in PZ or SZ is denoted as \(\sigma_{n}^{z}(t)\), where \(z\in\{\text{PZ},\text{SZ}\}\). When an occupant is detected, \(\sigma_{n}^{z}(t)\) increases by 40% with \(z\) taking the values corresponding to PZ and SZ, and the maximum value of \(\sigma_{n}^{z}(t)\) is 100%; the value of \(\sigma_{n}^{\text{PZ}}(t)\) depends on the illuminance value of daylight, and it can be expressed as follows:  
\[\sigma_{n}^{\text{PZ}}(t)=\left\{ \begin{array}{l}30\%,l^{D}\geq 180\;lx,\\ 70\%,125\;lx\leq l^{D}\text{<}180\;lx,\\ 100\%,l^{D}<125\;lx,\\ \end{array} \right. \tag{3}\]  
where \(l^{D}\) represents the illuminance value of daylight detected by the light sensors in the area closest to the window. \(l^{D}\) is broadcast to all the sensing modules in Zone B through the wireless sensing network. When the occupancy state is determined as unoccupied, \(\sigma_{n}^{z}(t)\) of Zone B is set to 10% if it does not receive request frames from its neighbors. The most important objective of the rules is to ensure that the illuminance value on the working plane meets the specification requirements, such as 500 lx for desks in high-end offices. The values in all rules are calculated based on the specification requirements, and simulation results of illuminance distribution on desks using lighting software DIALux ([[https://www.dialux.com/zh-CN/](https://www.dialux.com/zh-CN/)]([https://www.dialux.com/zh-CN/](https://www.dialux.com/zh-CN/))) and on-site measurement results. On-site measurement contains two steps. The first step is to measure \(l^{D}\) and illuminance distribution at different times