## 3 Subsystems
### Intelligent HVAC Control  
The control of heating, ventilation and air conditioning (HVAC) devices in buildings can have a big impact on energy consumption. In our solution, it was integrated a system that enables the autonomous control of an air conditioning unit by forecasting the room's usage in the next time period. To provide HVAC control, an infrared universal emitter device was built using open-source hardware and software. The infrared control device uses an Arduino Mega with an infrared emitter that accepts HTTP GET requests in a similar way as a RESTful API. When receiving an HTTP request, the Arduino will query a RESTful API, created in Node.js, that retrieves the infrared code that the Arduino needs to emit. Arduino has memory limitations that do not allow the store of all possible infrared signals. The use of external server overpasses this limitation and can store a huge number of signals. Moreover, this solution provides easy system scalability--when a new signal is stored at the server, it will immediately be accessible by all the Arduinos--and provides a single location for all systems that use infrared signals to control resources, such as air conditioners, television sets, and projectors. Figure 12 shows the infrared device and the sequence diagram for each control request. With the control solved, the idea was to forecast the room's usage in the next hour to control the HVAC accordingly. Figure 13 shows the control actions used in the intelligent HVAC control system. Figure 12: Infrared signal emission diagram. Figure 13: Intelligent HVAC control flowchart. Fifteen minutes before the hour starts, the system estimates the occupancy of the room during the next hour using two processes: forecasting the energy consumption of the room during the target hour, and forecasting the occupancy of the room based on the forecasted energy consumption value. The consumption forecasting starts at fifteen minutes before each hour, using a hybrid neural fuzzy inference system (HyFIS) algorithm. This forecasting method implements a combination of neuronal networks and fuzzy rule-based systems [34]. The HyFIS, seen in Figure 13, receives a combination of four effective variables on the energy consumption value from past seven days as train data to create the forecasting model and based on the same variables from the current hour estimates the consumption value for the next hour. In the following of this process, a support vector machine (SVM) [35] classification algorithm has been used to identify the occupancy of the room. This classification method receives the estimated consumption value from HyFIS. The SVM also receives the same data set from the past six days to create the classification model and finally based on this model and the input data, the method returns a 0 or 1 result. Which in this case, 1 means that during the next hour at least one person will be in the room and 0 mean that the room during the next hour will be empty. At ten minutes before each hour, the system will act according to the SVM classification result and the real-time temperature value. At this moment the system will take one of four actions:  
* Turn off the air conditioner unit--this action will be taken if there will be no expected occupancy in the next hour period;
* Turn on the air conditioner unit at 22 \({}^{\circ}\)C in cold mode--this action will be taken if occupancy is expected and the room's temperature is higher than 25.5 \({}^{\circ}\)C;
* Turn on the air conditioner unit at 24 \({}^{\circ}\)C in heat mode--this action will be taken if occupancy is expected and the room's temperature is below than 21 \({}^{\circ}\)C;
* Turn on the 5 min monitoring (the yellow dots of Figure 13)--this action will be taken if occupancy is expected and the room's temperature is between 21 \({}^{\circ}\)C and 25.5 \({}^{\circ}\)C.  
After the first control action, the intelligent HVAC control system runs an error check at twenty minutes after the beginning of the hour.