Smart Control of HVAC using Machine Learning, IoT and Data Analytics
1.
Introduction:
The basic purpose of
heating, ventilation and air conditioning (HVAC) systems is to offer thermal
comfort and maintain good indoor air quality through proper ventilation and
filtration. HVAC systems regulate the entire climate of a facility. They also
make the necessary modifications whenever the outside temperature changes.
During the winter, HVAC systems (mostly boilers or heaters) struggle to
maintain a suitable indoor temperature. Because it can increase both energy
efficiency and indoor environmental quality, artificial intelligence has
promising applications in HVAC. AI can optimize variables like airflow,
temperature, and humidity, preserving air quality while consuming the least
amount of energy. IoT is very valuable in the HVAC business for tracking
vibration, airflow, pollutants, the number of occupants, weather conditions,
and other variables. Monitoring key stress indicators and remote analysis
enhances troubleshooting and makes preventative maintenance easier to
implement.
Result: Movement of Actuator based on Predictions
1.1.
Sensor and Actuator Layer:
Sensors and other
data-gathering devices serve as the foundation of any IoT system. They serve as
the link between the physical and digital worlds, converting analogue signals
to digital signals.
Sensors are categorized based
on the following factors:
·
Active/Passive
·
Invasive/Non-Invasive
·
Contact / No-Contact
·
Absolute or Relative
·
Area of Application
·
Measurement
·
What it measures
1.1.1.
Humidity Sensor:
Humidity sensors detect
humidity (amount of water vapour) in the air or a mass. Humidity levels can be
measured in various ways: absolute humidity, relative humidity, mass ratio, and
so on.
1.1.2.
Temperature Sensor:
Temperature sensors
measure the amount of heat or cold that is present in a system. They can be broad
of two types: contact and non-contact. Contact temperature sensors need to be
in physical contact with the object being sensed. Non-contact sensors do not
need physical contact, as they measure temperature through convection and
radiation.
1.1.3.
Chemical Sensor (Carbon dioxide):
Chemical sensors measure
the concentration of chemicals in a system. When subjected to a mix of
chemicals, chemical sensors are typically selected for a target type of
chemical (for example, a CO2 sensor senses only carbon dioxide).
1.1.4.
Actuators:
Actuators receive some
type of control signal (commonly an electric signal or digital command) that
triggers a physical effect, usually some type of motion, force, and so on.
Actuators
are categorized based on the following factors:
·
Type of motion:
Actuators can be classified based on the type of motion they produce (for
example, linear, rotary, one/two/three-axes).
·
Power:
Actuators can be classified based on their power output (for example, high
power, low power, micro power)
·
Binary or continuous:
Actuators can be classified based on the number of stable-state outputs.
·
Area of application:
Actuators can be classified based on the specific industry or vertical where
they are used.
·
Type of energy:
Actuators can be classified based on their energy type.
1.2.
SANET and Smart Object:
This project aims to
develop a SANET. Sensor/actuator network (SANET) is a network of sensors that
sense and measure their environment and/or actuators that act on their
environment. SANET can communicate and cooperating in a productive manner.
1.2.1.
SANET Advantages:
•
Greater deployment flexibility (especially
in extreme environments or hard-to-reach places)
•
Simpler scaling to many nodes
•
Lower implementation costs
•
Easier long-term maintenance
•
Effortless introduction of new
sensor/actuator nodes
•
Better equipped to handle dynamic/rapid
topology changes
1.2.2.
Smart Objects:
A smart object is a
device that they consist of the following four defining characteristics in a
single unit.
- Processing unit
- Sensor(s) and/or actuator(s)
- Communication device
- Power source
We deployed our edge
nodes as smart objects that include a processing unit, controller, and sensor.
1.2.3.
Communication Patterns for Sensor Network:
Periodic:
Transmission of sensory information occurs only at periodic intervals.
1.3.
Low Power Processing Unit:
The goal of Low Power is
to lower the device's power consumption by managing its behaviour to extend its
operational lifetime. Electronic equipment that is powered directly from a
power source normally do not require the use of Low Power or similar strategies
to extend its life. On the other side, it is vital to reduce power
consumption to increase the operating lifetime of devices that use a power
source such as batteries.
1.3.1.
Low-Power Hardware Technique:
Figure 1. is the representation of the Arduino input voltage schematic. The input pin in the controller and the dc jack input passes through the 5 volts regulator that supplies 5 volts to the universal board. Whereas the voltage input through the USB port passes through the 3.3 voltage regulator that rectify the voltage to 3.3 volts only. Therefore, this project deployed the smart object techniques for the edge nodes.
1. Arduino Low Powered Input Modes
1.1.1.
Low Power Microprocessor Libraries:
To enable the Low Power
feature on Arduino boards, we can download the Arduino Low Power library[1]
from the libraries manager in the Arduino IDE. This package lets you
specify how long to sleep, from a few milliseconds to indefinitely. It also
lets you define which elements of the micro to disable, making it a very
powerful and adaptable low-power library.
1.1.2.
Deep Sleep mode:
Deep Sleep mode allows
the device to turn off several internal modules to save maximum power. The
Deep Sleep mode can be programmed to wake up after a predetermined amount of
time.
#include "LowPower.h"
void setup()
{
pinMode(13,OUTPUT);
}
void loop()
{
digitalWrite(13,HIGH);
delay(2000);
digitalWrite(13,LOW);
LowPower.powerDown(SLEEP_2S, ADC_OFF, BOD_OFF);
}
2. Sleep Mode Stats [2]
1.1.1. disable reporting ():
The disable_reporting() is a method used to disable the pin reporting method of pyfirmata. It eventually shuts the power supplied to receive and transmit data. It has same effects as deep sleep mode.
2. Data Analytics:
2.1. Data Source and Acquisition:
Accurate occupancy detection of an office room from light, temperature, humidity and CO2 measurements using statistical learning models. Luis M. Candanedo, Véronique Feldheim. Energy and Buildings. Volume 112, 15 January 2016, Pages 28-39.
2.2. Data Preprocessing:
The bulk of the datasets obtained include missing values due to manual errors, lack of information, and other factors. Although there are several methods for dealing with missing values, there are occasions when dropping such rows from the dataset is the only choice. The pandas 'dropna' function is a popular way to remove rows and columns.
Purpose: To remove the missing values, duplicates and unused columns from a Data Frame.
DataFrame - drop() function
The drop() function removes specific labels from rows or columns.
Remove rows or columns by specifying label names and corresponding axes, or by directly specifying index or column names. Labels on different levels can be removed when using a multi-index by specifying the level.
2.3. Feature Extraction:
2.3.1. Heatmap ():
A correlation heatmap is a graphical representation of a correlation matrix that shows how different variables are related. Correlation can have a value ranging from -1 to 1.
cmap — sets the specific colormap we want to use,
annot — when set to True, the correlation values become visible on the colored cells.
2.3.2. Train Test Split Procedure:
A model validation process that allows you to simulate how a model would perform on new/unseen data is known as train test split. This is how the process works.
1. Ensure that your data is organized in a format suitable for train test split. This is done by splitting the entire dataset into Features and Targets in scikit-learn.
2. Split the dataset into two pieces: a training set and a testing set. This consists of random sampling without replacement about 30% (you can vary this) of the rows and putting them into your training set and putting the remaining 70% to your test set.
3. Note that the colors in “Features” and “Target” indicate where their data will go (“X_train”, “X_test”, “y_train”, “y_test”) for a particular train test split.
4. Train the model on the training set. This is “X_train” and “y_train” in the image.
5. Test the model on the testing set (“X_test” and “y_test” in the image) and evaluate the performance.
3. Test and Train data splitting
1.1.
Decision Tree Classifier:
A decision tree is a
flowchart-like tree structure where an internal node represents a feature(or
attribute), the branch represents a decision rule, and each leaf node
represents the target.
tree_classifier.predict will
take predictions from our testing set (X-test) and we will assign those
predictions to a variable name y-tree-predicts.
Now we compute the confusion
matrix to evaluate the accuracy of classification.
1.2. Results:
The confusion matrix
is a N x N matrix used to evaluate the performance of a classification model,
where N is the number of target classes (0,1). The matrix compares the truth
goal values to the machine learning model's predictions. This provides
us with a comprehensive picture of how well our classification model is working
and the kind of errors it is making.
After finding the
confusion matrix we will plot these predicted and truth values.
4. Confusion Matrix
Translation
Algorithm:
Python-Arduino Interface:
The strength of the python language and the
supportive environment of Arduino is the key feature of the project. The
project is the practical implementation and real-time integration of the python
environment and the Arduino. The framework that connects the other environments
with Arduino is called Firmata. Firmata is a protocol that is used to connect
the Arduino serial interface with other programming languages. Python requires
the installation of Pyfirmata.
|
pip install pyfirmata |
Pyfirmata is the serial connectivity between Python
and Arduino. The Base class for any board for pyfirmata is the
following:
Class
pyfirmata. pyfirmata.Board(port, layout=None, baudrate=57600, name=None,
timeout=None)
Following
are some functions that are to be used in the project.
Table 12.
Pyfirmata Commands
|
SR. No. |
Function |
Functionality |
|
1. |
get_pin(pin_def)
|
Returns
the activated pin given by the pin definition. May raise an
InvalidPinDefError or a PinAlreadyTakenError. Parameter’s pin_def – Pin
definition as described below, but without the Arduino name. So
for example a:1: I. ‘a’
analogue pin PIN ‘i’
for input ‘d’
digital PIN ‘o’
for output ‘p’
for PWM (Pulse-width modulation) All are separated by: |
|
2. |
servo_config
(pin, min_pulse=544, max_pulse=2400, angle=0) |
Configure
a pin as servo with min_pulse, max_pulse and first angle. min_pulse and
max_pulse default to the arduino defaults |
|
3. |
setup_layout(board_layout)
|
Setup
the Pin instances based on the given board layout. |
|
4. |
disable_reporting
()
|
Disable
the reporting of an input pin. Disable
the reporting of the port |
|
5. |
enable_reporting
() |
Set
an input pin to report values. Enable
reporting of values for the whole port. |
|
6. |
Mode
() |
Mode
of operation for the pin. Can be one of the pin modes: INPUT, OUTPUT, ANALOG,
PWM. or SERVO (or UNAVAILABLE) |
|
7. |
write(value) |
Set
the output pins of the port to the correct state. Output
a voltage from the pin Parameters value. Uses
value as a Boolean if the pin is in output mode, or expects a float from 0 to
1 if the pin is in PWM mode. If the pin is in SERVO the value should be in
degrees. |
If you use a pin more often, it can be worth it to use the get_pin() method of the board. It lets you specify what pin you need by a string, composed of ‘a’ or ‘d’ (depending on whether you need an analogue or digital pin), the pin number, and the mode (‘i’ for input, ‘o’ for output, ‘p’ for PWM). All are separated by :
Flow Chart:
Conclusion:
The tests performed have provided important validation
that the rule-based algorithms developed for self-correcting controls for
building air handlers are a viable solution, capable of detecting, diagnosing
and correcting. The primary goal and benefit of HVAC controls are
to provide building occupants with a comfortable environment. The data acquired from the sensors convert into testing
and training data. The data trains to model to predict the accurate output that
will eventually drive the actuator to open and close the HVAC.
References:
1.
https://www.arduino.cc/reference/en/libraries/arduino-low-power/
2.
https://learn.sparkfun.com/tutorials/reducing-arduino-power-consumption/all
0 Comments