Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
70 views

Temperature System

This document describes an IoT system to monitor temperature in a server room using Node MCU and DHT sensor. A Node MCU collects temperature data from the DHT sensor and sends it to the cloud for visualization. This allows remote monitoring of temperature to ensure it stays within the required range of 15 Celsius to prevent server crashes.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views

Temperature System

This document describes an IoT system to monitor temperature in a server room using Node MCU and DHT sensor. A Node MCU collects temperature data from the DHT sensor and sends it to the cloud for visualization. This allows remote monitoring of temperature to ensure it stays within the required range of 15 Celsius to prevent server crashes.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 40

IOT Server Room Temperature

Monitoring System

Abstract
Measuring temperature is one of the most common technique used because it
is important for many operations and tasks to be performed like in any industries
where heaters are used. heat up to. certain temperature is required. When it comes to
sensing temperature. a temperature sensor is use that is installed at a place whose
temperature is to be sensed. The temperature of that place can be monitored through
internet using internet of things. Monitoring is employed in various applications
including temperature,. Pressure, Flow rat,. Capacity, Acceleration and so on.
According to the quantities. distribution and detected frequency of the monitored
objects, there are different monitoring methods to acquire the measurements. Several
problems usually occur during the monitoring of the temperature in a room. For
example. a server room must be kept between 15 Celsius to monitor a temperature in
or else the server might crash and can cause a loss of hundred thousands.
Management has to choose either to place a person to monitor the temperature. Or to
save on human capital by developing a system that can monitor the temperature from
other places at any given time.

Block Diagram

NODE MCU DHT Sensor

Visualization Cloud

Fig 1 Proposed system


problem statement

Important meeting might be ignored due to the fact unavailability of free parking
space or a few different unauthorized character parked his automobile in wrong region. Lot
of time and money were wasted to remedyit however until now didnt get the pleasant
solution. So, the superior parking gadget is an very essential and crucial method to this
problem. This solves many troubles like, it can reduce congest in of automobile on roads
which in return helps fast shifting traffic, reduces time waste on traffic, less burning of fuel
which once more results in god pleasant of air, disabled and antique humans can locate
parking vicinity without difficulty.

Introduction
Due to development of the microelectronics technology and the high-peed digital
signal processing technologies, wireless communication technology is undoubtedly
provides people with a convenient, fast and effective method. It has been used widely in
industrial production and people's life, especially created a new situation of data
acquisition and transmission for some complicated terrain conditions, hostile
environmental conditions and other places that people inconvenient to reach. In this
article, we design a scheme of wireless communication system that it has a small size, low
cost and it can collect environmental factors such as temperature and humidity data real-
timely and remotely. The core of the system control module ATMEGA328
microcontroller is a high-performance single chip microcomputer with a wide voltage,
low power consumption, high integration, strong anti- interference and strong portability.
Sensor DHT11 is a digital- signal-acquisition temperature&humidity sensor. The sensor
has anti-interference ability, high integration, high precision, low power consumption,
small size and low price. Software is based on the Arduino exploitation environment.
Arduino has its own exploitation environment which is based on Eclipse IDE
development environment, similar to the JAVA and C/C ++, it can be done with some
software such as Flash and Processing. Furtherly, reduced the threshold of the research
and use.
IoT

The Internet of Things (IOT) is a system of interconnected computing devices,


mechanical and digital machines, objects, animals or humans, each with a unique identifier
(UID) and the ability to transmit data over a network without human intervention – Manual
connection is required, provided. Human-Computer Interaction or Human- Computer
Interaction. Things on the Internet of Things could be people implanted with heart
monitors, farm animals with biochip transponders, cars with built-in sensors that warn
drivers when tire pressure is too low, or any other natural or Man-made objects can be
assigned Internet Protocol (IP) addresses and can transmit data over a network.

The web of things helps individuals live and work more astute, as well as deal with
their lives. As well as offering savvy gadgets to robotize homes, IOT is fundamental for
business. IOT furnishes organizations with

a continuous investigate how their frameworks truly work, conveying bits of


knowledge into everything from the exhibition of machines to inventory network and
strategies tasks. A few advantages are industry-explicit, and some are relevant across
different enterprises. A portion of the normal advantages of IOT empower organized

 Screen their general business processes


 Further develop the client experience (CX)
 Set aside time and cash
 Improve representative usefulness

In a developing united states like India, where the populace and cars are developing
rapidly, the implementation of an advanced parking system is critical. despite the fact that
vehicle utilization is soaring, there are not enough parking spaces to accommodate them,
which means that they have to make do with seldom-determined spaces. which strain the
driving force to park a vehicle on the roads, it's the reason heavy,congestion the roads
sluggish movement of web page traffic. despite the fact that, lot of time is wasted in
searching for parking whilst looking by chance it outcomes environment via emission
dangerous vehicles. This emission adulterates the air with the resource of CO2 and other
gases thru combustion of fuel. additionally, even as looking parking slots, motion of traffic
turns into sluggish. to triumph over all the troubles stated above, we need an green parking
tool which would possibly help to lessen site travelers congestion and enhance air at crucial
places wherein website site visitors rush is more.

According to the definition of IOT, it's miles the manner to interconnection with the
help of the net gadgets that can be embedded to put in force the capability in normal
objects by permitting them to send and acquire data. Connectivity

 Intelligence and identity


 Scalability
 Protection

The Internet of things (IoT) describes physical objects (or groups of such objects)
with sensors, processing ability, software and other technologies that connect and exchange
data with other devices and systems over the Internet or other communications networks.
Internet of things has been considered a misnomer because devices do not need to be
connected to the public internet, they only need to be connected to a network, and be
individually addressable.

The field has evolved due to the convergence of multiple technologies, including
ubiquitous computing, commodity sensors, increasingly powerful embedded systems, as
well as machine learning. Traditional fields of embedded systems, wireless sensor
networks, control systems, automation (including home and building automation),
independently and collectively enable the Internet of things. In the consumer market, IoT
technology is most synonymous with products pertaining to the concept of the "smart
home", including devices and appliances (such as lighting fixtures, thermostats, home
security systems, cameras, and other home appliances) that support one or more common
ecosystems, and can be controlled via devices associated with that ecosystem, such as
smartphones and smart speakers. IoT is also used in healthcare systems.

There are a number of concerns about the risks in the growth of IoT technologies and
products, especially in the areas of privacy and security, and consequently, industry and
governmental moves to address these concerns have begun, including the development of
international and local standards, guidelines, and regulatory frameworks.
Node MCU

The NodeMCU (Node MicroController Unit) is an open-source software and


hardware development environment built around an inexpensive System-on-a-Chip (SoC)
called the ESP8266. The ESP8266, designed and manufactured by Espressif Systems,
contains the crucial elements of a computer: CPU, RAM, networking (WiFi), and even a
modern operating system and SDK. That makes it an excellent choice for Internet of
Things (IoT) projects of all kinds.

However, as a chip, the ESP8266 is also hard to access and use. You must solder
wires, with the appropriate analog voltage, to its pins for the simplest tasks such as
powering it on or sending a keystroke to the “computer” on the chip. You also have to
program it in low-level machine instructions that can be interpreted by the chip hardware.
This level of integration is not a problem using the ESP8266 as an embedded controller
chip in mass-produced electronics. It is a huge burden for hobbyists, hackers, or students
who want to experiment with it in their own IoT projects.

But, what about Arduino? The Arduino project created an open-source hardware
design and software SDK for their versatile IoT controller. Similar to NodeMCU, the
Arduino hardware is a microcontroller board with a USB connector, LED lights, and
standard data pins. It also defines standard interfaces to interact with sensors or other
boards. But unlike NodeMCU, the Arduino board can have different types of CPU chips
(typically an ARM or Intel x86 chip) with memory chips, and a variety of programming
environments. There is an Arduino reference design for the ESP8266 chip as well.
However, the flexibility of Arduino also means significant variations across different
vendors. For example, most Arduino boards do not have WiFi capabilities, and some even
have a serial data port instead of a USB port.

The NodeMCU is available in various package styles. Common to all the designs is
the base ESP8266 core. Designs based on the architecture have maintained the standard 30-
pin layout. Some designs use the more common narrow (0.9″) footprint, while others use a
wide (1.1″) footprint – an important consideration to be aware of.
The most common models of the NodeMCU are the Amica (based on the standard
narrow pin-spacing) and the LoLin which has the wider pin spacing and larger board. The
open-source design of the base ESP8266 enables the market to design new variants of the
NodeMCU continually.

NodeMCU ESP8266 Specifications & Features

 Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106


 Operating Voltage: 3.3V
 Input Voltage: 7-12V
 Digital I/O Pins (DIO): 16
 Analog Input Pins (ADC): 1
 UARTs: 1
 SPIs: 1
 I2Cs: 1
 Flash Memory: 4 MB
 SRAM: 64 KB
 Clock Speed: 80 MHz
 USB-TTL based on CP2102 is included onboard, Enabling Plug n Play
 PCB Antenna
 Small Sized module to fit smartly inside your IoT projects
Programming NodeMCU ESP8266 with Arduino IDE

The NodeMCU Development Board can be easily programmed with Arduino IDE since it
is easy to use.

Programming NodeMCU with the Arduino IDE will hardly take 5-10 minutes. All you
need is the Arduino IDE, a USB cable and the NodeMCU board itself. You can check
this Getting Started Tutorial for NodeMCU to prepare your Arduino IDE for NodeMCU.

Arduino IDE
The Arduino IDE is an open-source software, which is used to write and upload code to the
Arduino boards. The IDE application is suitable for different operating systems such as
Windows, Mac OS X, and Linux. It supports the programming languages C and C++.
Here, IDE stands for Integrated Development Environment.

The program or code written in the Arduino IDE is often called as sketching. We need to
connect the Genuino and Arduino board with the IDE to upload the sketch written in the
Arduino IDE software. The sketch is saved with the extension '.ino.'

The Arduino IDE will appear as:


Toolbar Button

The icons displayed on the toolbar are New, Open, Save, Upload, and Verify.

It is shown below:
Upload

The Upload button compiles and runs our code written on the screen. It further uploads the
code to the connected board. Before uploading the sketch, we need to make sure that the
correct board and ports are selected.

We also need a USB connection to connect the board and the computer. Once all the above
measures are done, click on the Upload button present on the toolbar.

The latest Arduino boards can be reset automatically before beginning with Upload. In the
older boards, we need to press the Reset button present on it. As soon as the uploading is
done successfully, we can notice the blink of the Tx and Rx LED.

If the uploading is failed, it will display the message in the error window.

We do not require any additional hardware to upload our sketch using the Arduino
Bootloader. A Bootloader is defined as a small program, which is loaded in the
microcontroller present on the board. The LED will blink on PIN 13.

Open

The Open button is used to open the already created file. The selected file will be opened in
the current window.

Save

The save button is used to save the current sketch or code.

New

It is used to create a new sketch or opens a new window.

Verify

The Verify button is used to check the compilation error of the sketch or the written code.

Serial Monitor
The serial monitor button is present on the right corner of the toolbar. It opens the serial
monitor.

It is shown below:

When we connect the serial monitor, the board will reset on the operating system
Windows, Linux, and Mac OS X. If we want to process the control characters in our
sketch, we need to use an external terminal program. The terminal program should be
connected to the COM port, which will be assigned when we connect the board to the
computer.

Menu Bar

 File

When we click on the File button on the Menu bar, a drop-down list will appear. It is
shown below:

Let's discuss each option in detail.


New

The New button opens the new window. It does not remove the sketch which is already
present.

Open

It allows opening the sketch, which can be browsed from the folders and computer drivers.

Open Recent

The Open Recent button contains the list of the recent sketches.

Sketchbook

It stores the current sketches created in the Arduino IDE software. It opens the selected
sketch or code in a new editor at an instance.

Examples

It shows the different examples of small projects for a better understanding of the IDE and
the board. The IDE provides examples of self-practice.

Close

The Close button closes the window from which the button is clicked.

Save

The save button is used to save the current sketch. It also saves the changes made to the
current sketch. If we have not specified the name of the file, it will open the 'Save As...'
window.

Save As...

We can save the sketch with a different name using the 'Save As...' button. We can also
change the name accordingly.
Page Setup

It allows setting the page margins, orientation, and size for printing. The 'Page Setup'
window will appear as:

Print

According to the settings specified in the 'Page Setup', it prepares the current sketch for
printing.

Preferences

It allows the customization settings of the Arduino IDE.

Quit

The Quit button is used to close all the IDE windows. The same closed sketch will be
reopened when we will open the Arduino IDE.
 Edit

When we click on the Edit button on the Menu bar, a drop-down list appears. It is shown
below:

Let's discuss each option in detail.

Undo

The Undo button is used to reverse the last modification done to the sketch while editing.

Redo

The Redo button is used to repeat the last modification done to the sketch while editing.

Cut
It allows us to remove the selected text from the written code. The text is further placed to
the clipboard. We can also paste that text anywhere in our sketch.

Copy

It creates a duplicate copy of the selected text. The text is further placed on the clipboard.

Copy for Forum

The 'Copy for Forum' button is used to copy the selected text to the clipboard, which is also
suitable for posting to the forum.

Copy as HTML

The 'Copy for Forum' button is used to copy the selected text as HTML to the clipboard. It
is desirable for embedding in web pages.

Paste

The Paste button is used to paste the selected text of the clipboard to the specified position
of the cursor.

Select All

It selects all the text of the sketch.

Go to line...

It moves the cursor to the specified line number.

The window will appear as:


Comment/Decomment

The Comment/ Decomment button is used to put or remove the comment mark (//) at the
beginning of the specified line.

Increase Indent

It is used to add the space at the starting of the specified line. The spacing moves the text
towards the right.

Decrease Indent

It is used to subtract or remove the space at the starting of the specified line. The spacing
moves the text towards the left.

Increase Font Size

It increases the font size of the written text.

Decrease Font Size

It decreases the font size of the written text.

Find...

It is used to find the specified text. We can also replace the text. It highlights the text in the
sketch.

The window will appear as:


Find Next

It highlights the next word, which has specified in the 'Find...' window. If there is no such
word, it will not show any highlighted text.

Find Previous

It highlights the previous word, which has specified in the 'Find...' window. If there is no
such word, it will not show any highlighted text.

 Sketch

When we click on the Sketch button on the Menu bar, a drop-down list appears. It is shown
below:

Let's discuss each option in detail.

Verify/Compile
It will check for the errors in the code while compiling. The memory in the console area is
also reported by the IDE.

Upload

The Upload button is used to configure the code to the specified board through the port.

Upload Using Programmer

It is used to override the Bootloader that is present on the board. We can utilize the full
capacity of the Flash memory using the 'Upload Using Programmer' option. To
implement this, we need to restore the Bootloader using the Tools-> Burn Bootloader
option to upload it to the USB serial port.

Export compiled Binary

It allows saving a .hex file and can be kept archived. Using other tools, .hex file can also be
sent to the board.

Show Sketch Folder

It opens the folder of the current code written or sketch.

Include Library

Include Library includes various Arduino libraries. The libraries are inserted into our code
at the beginning of the code starting with the #. We can also import the libraries from .zip
file.

Add File...

The Add File... button is used to add the created file in a new tab on the existing file.

For example, let's add 'Blink' file to the 'Javatpoint' file. The tab will now appear as:
We can also delete the corresponding file from the tab by clicking on the small triangle ->
Delete option.

Tools

When we click on the Tools button on the Menu bar, a drop-down list appears. It is shown
below:

Let's discuss each option in detail.

Auto Format
The Auto Format button is used to format the written code. For example, lining the open
and closed curly brackets in the code.

Archive Sketch

The copy of the current sketch or code is archived in the .zip format. The directory of the
archived is same as the sketch.

Fix Encoding and Reload

This button is used to fix the inconsistency between the operating system char maps and
editor char map encoding.

Manage Libraries...

It shows the updated list of all the installed libraries. We can also use this option to install a
new library into the Arduino IDE.

Serial Monitor

It allows the exchange of data with the connected board on the port.

Serial Plotter

The Serial Plotter button is used to display the serial data in a plot. It comes preinstalled in
the Arduino IDE.

WiFi101/WiFiNINA Firmware Updater

It is used to check and update the Wi-Fi Firmware of the connected board.

Board

We are required to select the board from the list of boards. The selected board must be
similar to the board connected to the computer.

Processor
It displays the processor according to the selected board. It refreshes every time during the
selection of the board.

Port

It consists of the virtual and real serial devices present on our machine.

Get Board Info

It gives the information about the selected board. We need to select the appropriate port
before getting information about the board.

Programmer

We need to select the hardware programmer while programming the board. It is required
when we are not using the onboard USB serial connection. It is also required during the
burning of the Bootloader.

Burn Bootloader

The Bootloader is present on the board onto the microcontroller. The option is useful when
we have purchased the microcontroller without the bootloader. Before burning the
bootloader, we need to make sure about the correct selected board and port.

Help

When we click on the Help button on the Menu bar, a drop-down list will appear. It is
shown below:
The Help section includes several documents that are easy to access, which comes along
with the Arduino IDE. It consists of the number of options such as Getting Started,
Environment, Troubleshooting, Reference, etc. We can also consider the image shown
above, which includes all the options under the Help section.

Some documents like Getting started, Reference, etc., can be accessed without the internet
connection as well. It will directly link us to the official website of Arduino.

Temperature&humidity sensor DHT11

Humidity is the measure of water vapour present in the air. The level of humidity in
air affects various physical, chemical and biological processes.  In industrial applications,
humidity can affect the business cost of the products, health and safety of the employees.
So, in semiconductor industries and control system industries measurement of humidity is
very important.  Humidity measurement determines the amount of moisture present in the
gas that can be a mixture of water vapour, nitrogen, argon or pure gas etc…  Humidity
sensors are of two types based on their measurement units.  They are a relative humidity
sensor and Absolute humidity sensor. DHT11 is a digital temperature and humidity sensor.

DHT11 is a low-cost digital sensor for sensing temperature and humidity.  This
sensor can be easily interfaced with any micro-controller such as Arduino, Raspberry Pi
etc… to measure humidity and temperature instantaneously.
DHT11 humidity and temperature sensor is available as a sensor and as a module.
The difference between this sensor and module is the pull-up resistor and a power-on LED.
DHT11 is a relative humidity sensor.  To measure the surrounding air this sensor uses a
thermistor and a capacitive humidity sensor.

DHT11 sensor consists of a capacitive humidity sensing element and a thermistor


for sensing temperature.  The humidity sensing capacitor has two electrodes with a
moisture holding substrate as a dielectric between them. Change in the capacitance value
occurs with the change in humidity levels. The IC measure, process this changed resistance
values and change them into digital form.

For measuring temperature this sensor uses a Negative Temperature coefficient


thermistor, which causes a decrease in its resistance value with increase in temperature. To
get larger resistance value even for the smallest change in temperature, this sensor is
usually made up of semiconductor ceramics or polymers.

The temperature range of DHT11 is from 0 to 50 degree Celsius with a 2-degree


accuracy. Humidity range of this sensor is from 20 to 80% with 5% accuracy. The
sampling rate of this sensor is 1Hz .i.e. it gives one reading for every second.  DHT11 is
small in size with operating voltage from 3 to 5 volts. The maximum current used while
measuring is 2.5mA.

DHT11 Sensor
DHT11 sensor has four pins- VCC, GND, Data Pin and a not connected pin. A pull-
up resistor of 5k to 10k ohms is provided for communication between sensor and micro-
controller.

This sensor is used in various applications such as measuring humidity and


temperature values in heating, ventilation and air conditioning systems. Weather stations
also use these sensors to predict weather conditions.  The humidity sensor is used as a
preventive measure in homes where people are affected by humidity.  Offices, cars,
museums, greenhouses and industries use this sensor for measuring humidity values and as
a safety measure. It’s compact size and sampling rate made this sensor popular among
hobbyists.
DHT11 is a kind of digital compound temperature&humidity sensor that has had
the calibration output digital signal. In order to ensure the product has a very high
reliability and long-term stability, it uses a specific digital module of acquisition
technology and the temperature&humidity sensor technology. The encapsulated form of
DHT11is a single row of 4 stitch. Single wire and serial interface makes the system
integration simply and easily. The connection of DHT11 and MCU.When connecting line
of MCU and DHT11 within 20m, it should use 5k pull-up resistors. Otherwise, there
should be combined with the actual situation to choose suitable pull-up resistors.
Temperature&humidity sensor DHT11 has a 3-5.5V power supply voltage. In order to
achieve the purpose of decoupling filtering, the pin of VDD and GND can be added a
100nf capacitance. When DHT11 is powered on, we can rule out the factors of instability
by 1s waiting time. In this period of time, system does not need to send any instruction
information. MCU and DHT11 selection of single bus data format for communication and
synchronization, each communication time is about 4ms. After MCU sending start
instruction to sensor, temperature&humidity sensor DHT11 that comprises a low power
state transform to high speed condition. When the command finished, sensor will launch
instruction of its response signal and 40 bits information of data. At the same time, trigger
a instruction of signal collection. Then we can be able to read the part of data information.
If in this state, the sensor receives the start signals of MCU, then begin a temperature and
humidity data acquisition trigger. Otherwise, DHT11 can’t be able to collect the
temperature and humidity data initiatively. The system will conversion to low speed mode
after acquisition of data. DHT11 has characteristics of super fast response, strong anti-
interference, high cost performance, etc.

BACKGROUND
The monitoring of environmental variables such as temperature, pressure and
humidity has a long history of development and the variables have shown significant
impact in the productivity of plant growth, the quality of food industry and the efficiency
of many temperature and humidity-sensitive equipment (Vleeschouver, et al., 2017). The
monitoring of temperature and humidity of laboratories, storages, halls, school and
hospitals is important with respect to health and hygiene. The reliable measurement and
monitoring is crucial in this competitive era of technology. Arduino, the open source
hardware has shown ability to meet the need of accurate and real-time monitoring and
controlling of environmental variables. The Arduino user community is a forum where
many people can share their ideas, use each other’s work and modify them to innovate and
advance many different interacting objects. Arduino is use in a wide range of projects to
develop objects that can interact with people or environment and internet. The materials
required are easily available, cheap in price and easy to use with the help of available open
source information. Arduino has been used to build robots, drones, remote controllers,
monitoring devices and many interesting objects which is a one big step towards making
the world more automated and sustainable. Arduino can be told to do such things in
appropriate language that Arduino understand: C, C++.
The projects related to monitoring environmental variables are simple and common but
always with great importance; many projects on greenhouse building monitoring and
household plant monitoring are available (Akami, et al., 2015). This thesis was expected to
be helpful in learning electronics and programming as well as documentation process.
OBJECTIVE
The benefits of having temperature and Humidity monitor is to keep the server
room in best conditions. It is better to keep the server room monitored, The ideal
temperature range in a server room should be between 68°F (20°C) and 71°F (21.66°C).
This can be accomplished by running an air conditioning system, and also by keeping a
cooling duct system in place.

Flow Chart.

Start

Wait Wifi to connect


Motivation

Enokela and Othoigbe, 2015 designed an automated greenhouse control system using
Arduino prototype platform. The system designed by them achieved monitoring and
control of a greenhouse environment by using sensors and actuators which were under the
control of a microcontroller running a computer program. They concluded that the
greenhouse control system was successfully designed and was meant to protect seedlings in
nurseries from intruders. Kale and Kulkarni, 2016 developed real-time remote temperature
and humidity monitoring using Arduino. This system had more variation of humidity
parameter in night time as compared to the day time. Kunjumon et al., 2016 developed
temperature and humidity monitoring and alert management system. In the system
developed by them, a solution was provided to monitor and get an alert of an increase in
temperature or humidity. They concluded that this system can be cheaply made from low-
cost locally available components and can be used to monitor and control the temperature
and humidity at the data center

Installing the DHT Library for ESP8266


To read from the DHT sensor, we’ll use the DHT library from Adafruit. To use this library
you also need to install the Adafruit Unified Sensor library. Follow the next steps to install
those libraries.

1. Open your Arduino IDE and go to Sketch > Include Library > Manage Libraries. The


Library Manager should open.

2. Search for “DHT” on the Search box and install the DHT library from Adafruit.
3. After installing the DHT library from Adafruit, type “Adafruit Unified Sensor” in the
search box. Scroll all the way down to find the library and install it.

Code

// Including the ESP8266 WiFi library


#include
#include "DHT.h"

// Uncomment one of the lines below for whatever DHT sensor type you're
using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
//#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321

// Replace with your network details


const char* ssid = "YOUR_NETWORK_NAME";
const char* password = "YOUR_NETWORK_PASSWORD";
// Web Server on port 80
WiFiServer server(80);

// DHT Sensor
const int DHTPin = 5;
// Initialize DHT sensor.
DHT dht(DHTPin, DHTTYPE);

// Temporary variables
static char celsiusTemp[7];
static char fahrenheitTemp[7];
static char humidityTemp[7];

// only runs once on boot


void setup() {
// Initializing serial port for debugging purposes
Serial.begin(115200);
delay(10);

dht.begin();

// Connecting to WiFi network


Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {


delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Starting the web server


server.begin();
Serial.println("Web server running. Waiting for the ESP IP...");
delay(10000);

// Printing the ESP IP address


Serial.println(WiFi.localIP());
}

// runs over and over again


void loop() {
// Listenning for new clients
WiFiClient client = server.available();

if (client) {
Serial.println("New client");
// bolean to locate when the http request ends
boolean blank_line = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();

if (c == '\n' && blank_line) {


// Sensor readings may also be up to 2 seconds 'old' (its a very slow
sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
strcpy(celsiusTemp,"Failed");
strcpy(fahrenheitTemp, "Failed");
strcpy(humidityTemp, "Failed");
}
else{
// Computes temperature values in Celsius + Fahrenheit and Humidity
float hic = dht.computeHeatIndex(t, h, false);
dtostrf(hic, 6, 2, celsiusTemp);
float hif = dht.computeHeatIndex(f, h);
dtostrf(hif, 6, 2, fahrenheitTemp);
dtostrf(h, 6, 2, humidityTemp);
// You can delete the following Serial.print's, it's just for debugging
purposes
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t Heat index: ");
Serial.print(hic);
Serial.print(" *C ");
Serial.print(hif);
Serial.print(" *F");
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t Heat index: ");
Serial.print(hic);
Serial.print(" *C ");
Serial.print(hif);
Serial.println(" *F");
}
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();
// your actual web page that displays temperature and humidity
client

Sample Output
Circuit Diagram
Troubleshooting
If you get an error message in your serial Monitor while reading the temperature and
humidity from the DHT11, DHT22, AM2302 or AM2301 sensor, follow the next steps to
see if you can make it work.

If your DHT11/DHT22 sensor returns the error message “Failed to read from DHT
sensor!” or the DHT readings return “Nan”:

Try one of the next troubleshooting tips.

1. Wiring

When you’re building an electronics project, you need to double-check the wiring or pin
assignment. After checking and testing that your circuit is properly connected, if it still
doesn’t work, continue reading the next troubleshooting tips.

2. Power
The DHT sensor has an operating range of 3V to 5.5V (DHT11) or 3V to 6V (DHT22). If
you’re powering the sensor from a 3.3V pin, in some cases powering the DHT with 5V
solves the problem.

3. Bad USB port or USB cable

Sometimes powering the ESP32, ESP8266, Arduino or similar boards directly from a PC
USB port is not enough. Try to plug it to a USB hub powered by an external power source.
It might also help replacing the USB cable with a better or shorter one. Having a USB port
that supplies enough power or using a good USB cable often fixes this problem.

4. Power source

As mentioned in the previous tip, your board (ESP32, ESP8266, Arduino, etc) might not be
supplying enough power to properly read from the DHT sensor. In some cases, you might
need to power your board with a power source that provides more current.

5. Sensor type

Double-check that you’ve uncommented/commented in your code the right sensor for your
project. In this case, we are selecting the DHT22:

//#define DHTTYPE DHT11 // DHT 11#define DHTTYPE DHT22 // DHT 22


(AM2302), AM2321//#define DHTTYPE DHT21 // DHT 21 (AM2301)

6. Sampling rate

The DHT sensor is very slow getting the readings (the sensor readings may take up to 2
seconds). In some cases, increasing the time between readings solves the problem.

7. DHT sensor is fried or broken

Unfortunately, these cheap sensors sometimes look totally fine, but they are fried/broken.
So, even though you assembled the right circuit and code, it will still fail to get the
readings. Try to use a different sensor to see if it fixes your problem.
8. Wrong baud rate or failed to upload code

If you don’t see anything in your Arduino IDE Serial Monitor, double-check that you’ve
selected the right baud rate, COM port or that you’ve uploaded the code successfully.

While building our projects, we’ve experienced similar issues with the DHT and it was
always solved by following one of the methods described earlier.

Fatal error: Adafruit_Sensor.h: No such file or directory

There’s also a common error that happens when you try to compile the code. If you receive
the following error:

fatal error: Adafruit_Sensor.h: No such file or directory


#include <Adafruit_Sensor.h>

You need to install the Adafruit Unified Sensor driver library. In your Arduino IDE, type
in the search box “Adafruit Unified Sensor“, scroll all the way down to find the library
and install it.
After installing the library, restart your Arduino IDE and the code should compile without
the error message.

CONCLUSION
The work was successful in building a monitoring device which works as a
thermometer for measuring temperature and humidity inside a building; it is capable of
measuring humidity and temperature outdoors. Compared to expensive sensor, the
Arduino-based monitoring system successfully reduces the power consumption, cost and
complexity of the process. The performance of the system was accurate and reliable with
some error in measurement and limitations of the used sensor. Arduin- based monitoring
devices are the new possibilities for developing smart devices freely with small budget and
simple work. The accelerating race of advanced technology outdates the technology used
in Arduino Uno in no time; advanced software working similarly are available. The
Arduino is programmed to use a USB cable to connect to computer while there are many
other boards available with different features. The project was interesting and was
practically helpful to learn to use micro controllers (Arduino), programming language C
and basic electronics. This was a very helpful project in learning and understanding the
world of micro controllers, and using micro controllers in real life. The thesis project was a
platform to advance the technique of research, test and documentation that was learnt
throughout the studies in the degree programme.

REFERENCES

[1] R. Rahim, " Humidity and Temperature Prototype for Education with Internet of
Things”,
International Journal of Pure and Applied Mathematics, vol. 119, no. 16, pp. 2487-2491,
2018.
[2] S. Pallavi, "Internet of Things: Architectures, Protocols, and Applications," Journal of
Electrical
and Computer Engineering, pp. 1-26, 2017.
[3] P. Narkhede, "Physical Conditions Monitoring in Server Rooms Internet of Things,"
International
Journal of Electrical and Electronics Research, pp. 237-239, 2015.
[4] H. Nainggolan, "Rancang Bangun Sistem Kendali Temperatur Dan Kelembaban Relatif
Pada
Ruangan Dengan Menggunakan Motor Dc Berbasis Mikrokontroler Atmega8535," Jurnal
Fisika Unand , Vol. 2, No. 3, P. 140, 2013.
[5] S. Vatsal, Using Raspberry Pi To Sense Temprature And Relative Humidity,
International
Research Journal Of Engineering And Technology, 2017.
[6] ASHRAE, "Applying 2011 ASHRAE Data Center Guidelines To HP Proliant-Based
Facilities,"
2008.
[7] J. P. SIPAN, "Temperature & Humidity Monitoring & Control System Based On
Arduino And
Sim900a Gsm Shield," International Journal Of Electrical, Electronics And Data
Communication, Vol. 5, No. 11, P. 62, 2017.
[8] S. A. Nugroho, " Detektor Suhu Ruangan Dengan Tombol Pengatur Manual Berbasis
Mikrokontroler AT89S51," Seminar Riset Unggulan Nasional Informatika Dan Komputer
FTI UNSA, Vol. II, No. 2, Pp. 15-21, 2013.
[9] T. Liu, "Digital-Output Relative Humidity & Temperature Sensor/Module DHT22
(DHT22 Also
Named As AM2302)," Aosong Electronics Co.,Ltd.
[10] A. H. Saptadi, "Perbandingan Akurasi Pengukuran Suhu Dan Kelembaban Antara
Sensor DHT11
Dan DHT22," Jurnal Infotel , Vol. VI, No. 2, Pp. 49-55, 2014.
[11] M. Ichwan, "Pembangunan Prototipe Sistem Pengendalian Peralatan Listrik Pada
Platform
Android," Jurnal Informatik, Vol. IV, No. 1, Pp. 13-25, 2013.
[12] G. P. Nugroho, "Sistem Pendeteksi Dini Banjir Menggunakan Sensor Kecepatan Air
Dan Sensor
Ketinggian Air Pada Mikrokontroler Arduino," Jurnal Teknik Pomits , Vol. II, No. 1, Pp.
1-
5, 2013.
[13] Monicris, "Air Conditioning Web Controlled By Arduino," Instructables, [Online].
Available:
Https://Www.Instructables.Com/Id/Air-Conditioning-Web-Controlled-By-Arduino/.
[Accessed 10 8 2018].
[14] Laabissi M, Achhab M E, Wilkin J And Dochain D 2001 Trajectory Analysis Of
Nonisothermal
Tubular Reactor Nonlinear Models Syst. Contr. Lett. 42 169 – 184
[15] Miller M 2005 Controllability Cost Of Conservative Systems: Resolvent Condition
And
Transmutation Journal Of Functional Analysis 218 425 – 444
[16] Pazy A 1983 Semigroups Of Linear Operators And Applications To Partial
Differential Equations
(New York: Springer)
[17] Rabah R And Skylar G 2014 Observability And Controllability For Linear Neutral
Type Systems
21st International Symposium On Mathematical Theory Of Networks And Systems
(Groningen, The Netherlands, 7-11 July 2014) Pp 223–229
[18] Renardy M And Rogers R C 2004 An Introduction To Partial Differential Equations
(New York:
Springer)
[19] Tucsnak M And Weiss G 2009 Observation And Control For Operator Semigroups
(Berlin:
Birkhauser)
[20] Winkin J, Dochain D And Ligarus Ph 2000 Dynamical Analysis Of Distributed
Parameter Tubular
Reactors Automatica 36 349 – 361
[21] Zhao X And Weiss G 2011 Controllability And observability of a well-posed system
coupled with
a finite-dimensional system IEEE Transaction on Automatic Control 56 1 12p
[22] Zuazua E 2005 Controllability and Observability of Partial Differential Equations:
Some results
and open problems Preprint nd.edu/~mtns/papers/12197

You might also like