## 5 Case Study: Experimental Validation in a Representative Smart Building Scenario
### Scenario Description and Operational Flow  
The case study is conducted within a real-world indoor environment that serves as a representative deployment scenario for evaluating the proposed energy management  
\begin{table}
\begin{tabular}{l l l} \hline \hline
**Device Type** & **Model** & **JFML-IoT Class** \\ \hline Temperature Sensor & DHT22 & DHT22 Sensor \\ Humidity Sensor & DHT22 & DHT22 Sensor \\ CO\({}_{2}\) Sensor & MH-Z19 & MHZ19 Sensor \\ Illuminance Sensor & BH1750 & BH1750 Sensor \\ Occupancy Sensor & HC-SR501 (PIR) & PIRSensor \\ Lighting Actuator & PWM-controlled LED driver & LightingActuator \\ Ventilation Actuator & Relay-controlled fan switch & VentilationActuator \\ HVAC Actuator & Relay or IR-based HVAC control & HVACActuator \\ \hline \hline \end{tabular}
\end{table}
Table 1: Examples of sensors and actuators available in JFML-IoT for energy management.  
system. The selected environment is a medium-sized office room of approximately 30 square meters, located within an academic building. This space is regularly used by staff and students, exhibiting variable occupancy patterns and dynamic environmental conditions throughout the day. This room serves as a representative testbed to evaluate the performance and scalability of the energy management framework.  
Figure 2 illustrates both the spatial arrangement and the operational flow of the system components. The room is divided into two sensing zones (Zone 1 and Zone 2), each equipped with an ESP32-based embedded node connected to temperature and humidity sensors (DHT22), illuminance sensors (BH1750), and passive infrared (PIR) detectors (HC-SR501) for occupancy monitoring. A centrally located CO2 sensor (MH-Z19), also managed by an ESP32 node, ensures global air quality tracking. Actuators--including dimmable LED drivers, a ventilation fan, and an HVAC interface--are controlled via a dedicated ESP32 module. Two Raspberry Pi units are used: one to host the MQTT broker and another to execute the fuzzy inference engine (JFML-IoT).  
The system operation unfolds in five sequential stages:  
1. **Sensor Data Acquisition and Publication:** Each ESP32 node continuously collects environmental data and publishes it to a local MQTT broker (step 1).
2. **Message Handling:** The MQTT broker, hosted on a Raspberry Pi (step 2), receives and distributes messages in real time to relevant subscribers.
3. **Fuzzy Inference:** A second Raspberry Pi (step 3) runs the JFML-IoT engine, which subscribes to the sensor data, executes the fuzzy rule-based inference using the FML configuration, and determines the appropriate control actions.  
Figure 2: Schematic layout and operation flow of the experimental room. The setup includes two sensing zones equipped with ESP32-based nodes and environmental sensors (temperature, humidity, illuminance, occupancy), as well as a central CO2 sensor. Step 1: Sensors collect data and publish it via MQTT. Step 2: A Raspberry Pi hosts the MQTT broker to manage data exchange. Step 3: Another Raspberry Pi runs the JFML-IoT engine, subscribes to sensor data, and performs fuzzy inference. Step 4: Control decisions are sent back via MQTT to the actuator node, which manages lighting and HVAC systems.  
4. **Acubation:** Control commands are transmitted via MQTT to the actuator node (step 4), which governs dimmable LED lights, the ventilation fan, and HVAC outputs. This modular and asynchronous architecture enables autonomous, real-time adaptation to environmental changes while preserving system flexibility and interoperability. Table 2 summarizes the input and output variables used in the fuzzy inference process, along with the associated sensor or actuator for each. These variables are directly mapped to physical devices deployed in the room, providing interpretable links between environmental conditions and system decisions. Their configuration also supports human interpretability and traceability of decisions through FML-compliant rule bases.