0% found this document useful (0 votes)
6 views11 pages

PBL Report

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 11

KIET Group of Institutions, Ghaziabad

Electronics and Communication Engineering

PBL Report
on

Analysing the data of humidity sensor with the help of esp32


on MATLAB

Submitted By:
Atul Kumar 2100290310043
Avinash 2100290310045

Course/Branch(Sem-Sec.): BTech/ECE
Section A

Submitted to: Hunny Pahuja


ACKNOWLEDGEMENT

I’ve got this golden opportunity to express my kind gratitude and sincere thanks to my Head
of Institution, KIET Group of Institutions of Engineering and Technology, and Head of
Department of Electronics and Communication Engineering for their kind support and
necessary counselling in the preparation of this project report. I’m also indebted to each and
every person responsible for the making up of this project directly or indirectly.

I must also acknowledge or deep debt of gratitude each one of my colleague who led this project
come out in the way it is. It’s my hard work and untiring sincere efforts and mutual cooperation
to bring out the project work. Last but not the least, I would like to thank my parents for their
sound counselling and cheerful support. They have always inspired us and kept our spirit up.
Introduction
Graphical representation is always helpful to visualize the data and it becomes
very easy to find trends and patterns by looking at them. There are many
software available to plot graphs based on the input values, but in embedded
system MATLAB is one of the most popular software which can not only
present the results in graphical format but also can be easily integrated with
hardware and microcontroller.

Hardware :

• ESP-32:The ESP32 makes it easy to use the Arduino IDE and the
Arduino Wire Language for IoT applications. This ESp32 IoT Module
combines Wi-Fi, Bluetooth, and Bluetooth BLE for a variety of diverse
applications. This module comes fully-equipped with 2 CPU cores that can
be controlled and powered individually, and with an adjustable clock
frequency of 80 MHz to 240 MHz. This ESP32 IoT WiFi BLE Module with
Integrated USB is designed to fit in all ncd.io IoT products.Monitor sensors
and control relays, FETs, PWM controllers, solenoids, valves, motors and
much more from anywhere in the world using a web page or a dedicated
server.We manufactured our own version of the ESP32 to fit into NCD IoT
devices, offering more expansion options than any other device in the
world! Integrated USB port allows easy programming of the ESP32. The
ESP32 IoT WiFi BLE Module is an incredible platform for IoT application
development. This ESP32 IoT WiFi BLE Module can be programmed using
Arduino IDE.

• IoT Long Range Wireless Temperature And Humidity


Sensor:Industrial Long Range Wireless Temperature Humidity Sensor.
Grade with a Sensor Resolution of ±1.7%RH ±0.5°C .Up to 500,000
Transmissions from 2 AA Batteries.Measures -40°C to 125°C with Batteries
that Survive these Ratings.Superior 2-Mile LOS Range & 28 miles with
High-Gain Antennas.Interface to Raspberry Pi, Microsoft Azure, Arduino
and More
MATLAB Data Logging, Analysis and Visualization:
Plotting DHT11 Sensor readings on MATLAB

Circuit Diagram:

Arduino code for DHT11 interfacing with MATLAB:


First include the library for DHT11 sensor which is ‘DHT.h’.

#include <DHT.h>

Then define the DHT11 data pin connected to the Arduino. In our case, it is pin
number 4.

#define DHTPIN 4

In the ‘void setup’ initialize the serial and the DHT11 sensor.

void setup() {
Serial.begin(9600);
delay(2000);
dht.begin(); // initialise DHT11 sensor
}

In the ‘void loop’ function, set the value of temperature and humidity
as float type. Read the temperature and humidity data from the Arduino using
command float temp = dht.readTemperature() and float humi =
dht.readHumidity(). Then print these values on the serial monitor, so that the
MATLAB will be able to read the values serially.

void loop() {
float temp = dht.readTemperature(); //read temperature data
float humi = dht.readHumidity(); //read temperature data
Serial.print(temp);
Serial.print(humi);
delay(2000);
}

MATLAB code for LOGGING and PLOTTING the DATA:


Open MATLAB in your system, and starting coding in the editor window. The
editor window can be opened by clicking on the ‘new script’ in MATLAB, as
shown in the below image.

Start with defining a variable for the serial communication from MATLAB to
Arduino. COM18 is the port at which my Arduino is connected, you can change
accordingly.

s = serial('COM18');

In the below code, fopen() is used for serial communication between Arduino
and MATLAB. Then we are saving the serial data into variable called ‘out’.
The out variable is a string of nine digits where the first four digits stores the
temperature data and the remaining digits stores humidity data. So, by
using Temp(i)=str2num(out(1:4)) and Humi(i)=str2num(out(5:9)) we are reading
the temperature and humidity data respectively.
fopen(s)
out = fscanf(s)
Temp(i)=str2num(out(1:4));
Humi(i)=str2num(out(5:9));

Now, after pasting the complete code into the editor window. Click on the ‘run’
button to process the code, as shown in the below image.

Wait until the MATLAB shows busy in the bottom left corner of the screen, as
shown in the below image. This indicated that the MATLAB is processing the
code.

If the code executes without any error, the real-time graph window will appear
on the screen, as shown below. Here, the data will update in every two
seconds, as two seconds is the time taken by the DHT11 sensor to send the
data to the serial port.
To check the real-time logged value of temperature and humidity, double click
on the respective variable in the workspace window, as shown in the below
image.
The dialog box will appear which contains all the saved values into the
particular variable.
The complete MATLAB code-
Arduino Code
#include <DHT.h>
#define DHTPIN 4
define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
delay(2000);
dht.begin(); // initialise DHT11 sensor
}
void loop() {
float temp = dht.readTemperature(); //read temperature data
float humi = dht.readHumidity(); //read temperature data
Serial.print(temp);
Serial.print(humi);
delay(2000);
}
MATLAB Code
s = serial('COM18');
time=100;
i=1;
while(i<time)
fopen(s)
fprintf(s, 'Your serial data goes here')
out = fscanf(s)
Temp(i)=str2num(out(1:4));
subplot(211);
plot(Temp,'g');
axis([0,time,20,50]);
title('Parameter: DHT11 Temperature');
xlabel('---> time in x*0.02 sec');
ylabel('---> Temperature');
grid
Humi(i)=str2num(out(5:9));
subplot(212);
plot(Humi,'m');
axis([0,time,25,100]);
title('Parameter: DHT11 Humidity');
xlabel('---> time in x*0.02 sec');
ylabel('---> % of Humidity ');
grid
fclose(s)
i=i+1;
drawnow;
end
delete(s)
clear s
Discussion
Visualization of the entire temperature data can be done by fitting a
trend line in the data. Trend is the rate at which any parameter changes
over a time period. Before fitting a trend line, preprocessing of the data
must be done to remove any missing values and data outliers ensuring
data consistency. This can be done by using logical indexing approach in
MATLAB. It is observed that the week began at a higher temperature of
32 Degree Celsius and found a decline by the end of the week.

This system has the advantages that, first it is competent and reliable for
real time monitoring of humidity. Secondly the system is totally digital,
there is full arrangement of storage of the data so it can be further used
for analysis purpose. And finally the system can continuously monitor the
environment parameters, updating the user at every fixed interval of time
about the change in the parameters. This makes the user keep a better eye
at the premises. However the system is developed only for small area and
though the sensor is nicely calibrated, there are chances of error in the
readings as the sensor may get damaged when exposed to higher
temperature beyond its limit.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy