IoT Lab Manual
IoT Lab Manual
LAB MANUAL
Session: 2022-23
Subject: Internet of Things
Sr.
Experiment Name
No.
1 Introduction to ESP 32 and Arduino IDE Software.
To interface Digital sensor (IR) with ESP-WROOM-32 and write a program to turn
2
ON LED at sensor detection
To interface LED with ESP-WROOM-32 and write a program to turn ON LED for 1 sec
3
after every 2 seconds
To interface Water level indicator with ESP-WROOM-32 and write a program to turn
4
ON LED at sensor detection
5 To interface DHT11 sensor with ESP-WROOM-32 and write a program to print
temperature and humidity readings on Serial monitor
Write a program on ESP-WROOM-32 to upload temperature and humidity data to the
6
cloud.
To interface Bluetooth with ESP-WROOM-32 and write a program to turn LED
7
ON/OFF when ‘1’/’0’ is received from smartphone using Bluetooth.
Write a program for making smart air pollution meters using IoT Kit and ThingSpeak
8
IoT cloud as GUI.
Experiment No. 1
Objectives
Theory
The IoT Kit is the ideal solution for university students, providing state-of-the-art, hands-on incorporation of
IoT technology in an educational setting. It supports a lot of features which enables researchers and students to
explore different aspects and develop different applications in IoT field. The most popular protocols used for
the realization of IoT are MQTT, COAP, and HTTP. Sensors used with IoT Kit are the building blocks of the
system which can collect values of different parameters. On-Board Micro-Controller ESP32 transmits
information to cloud server, open-source IoT Platform. Cloud Server will make the values of collected
parameters available over the internet so that they are globally accessible. Download AICTE Model Curriculum
of Courses at UG Level in Emerging Areas: https://www.aicte-india.org/sites/default/files/UG_Emerging.pdf
What is ESP32?
ESP32-DevKitC V4 is a small-sized ESP32-based development board produced by Espressif. Most of
the I/O pins are broken out to the pin headers on both sides for easy interfacing. Developers can either
connect peripherals with jumper wires or mount ESP32-DevKitC V4 on a breadboard. To cover a
wide range of user requirements, the following versions of ESP-32 DevKitC v4 are available:
1. ESP-WROOM-32
2. ESP-WROOM-32D
3. ESP-WROOM-32U
4. ESP-SOLO-1
5. ESP-WROVER
6. ESP-WROVER-B
7. ESP-WROVER-I
8. ESP-WROVER-B(IPEX)
For more details on ESP-WROOM-32 click on the link
below- https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/get-started-devkitc.html
The interface of the module is mainly divided into two parts including both Firmware and Hardware
Key
Description
Component
ESP32-
A module with ESP32 at its core.
WROOM-32
EN Reset button.
Download button. Holding down Boot and then pressing EN initiates
Boot
Firmware Download mode for downloading firmware through the serial port.
USB-to-
Single USB-UART bridge chip provides transfer rates of up to 3 Mbps.
UART Bridge
Micro USB USB interface. Power supply for the board as well as the communication
Port interface between a computer and the ESP32 module.
5V Power On Turns on when the USB or an external 5V power supply is connected to the
LED board. For details see the schematics in Related Documents.
Most of the pins on the ESP module are broken out to the pin headers on the
I/O board. You can program ESP32 to enable multiple functions such as PWM,
ADC, DAC, I2C, I2S, SPI, etc.
where former runs on the ESP8266 Wi-Fi SoC and later is based on the ESP-12 module.
Pin Description:
1) Power Pin: There are four power pins viz. one VIN pin & three 3.3V pins. The
VIN pin can be used to directly supply the ESP8266 and its peripherals, if you
have a regulated 5V voltage source. The 3.3V pins are the output of an on-board
voltage regulator. These pins can be used to supply power to external
components.
2) GND: GND is a ground pin of ESP8266 Node MCU development board.
3) I2C Pins: I2C Pins are used to hook up all sorts of I2C sensors and peripherals
in your project. Both I2C Master and I2C Slave are supported. I2C interface
functionality can be realized programmatically, and the clock frequency is 100
kHz at a maximum. It should be noted that I2C clock frequency should be
higher than the slowest clock frequency of the slave device.
4) GPIO Pins: ESP8266 Node MCU has 17 GPIO pins which can be assigned to
various functions such as I2C, I2S, UART, PWM, IR Remote Control, LED
Light and Button programmatically. Each digital enabled GPIO can be
configured to internal pull-up or pull-down, or set to high impedance. When
configured as an input, it can also be set to edge-trigger or level-trigger to
generate CPU interrupts.
5) ADC Channel: The Node MCU is embedded with a 10-bit precision SAR ADC.
The two functions can be implemented using ADC viz. Testing power supply
voltage of VDD3P3 pin and testing input voltage of TOUT pin. However, they
cannot be implemented at the same time.
6) UART Pins: ESP8266 Node MCU has 2 UART interfaces, i.e. UART0 and
UART1, which provide asynchronous communication (RS232 and RS485), and
can communicate at up to 4.5 Mbps. UART0 (TXD0, RXD0, RST0 & CTS0
pins) can be used for communication. It supports fluid control. However,
UART1 (TXD1 pin) features only data transmit signal so, it is usually used for
printing log.
7) SPI Pins: ESP8266 features two SPIs (SPI and HSPI) in slave and master
modes. These SPIs also support the following general-purpose SPI features:
4 timing modes of the SPI format transfer.
Up to 80 MHz and the divided clocks of 80 MHz.
Up to 64-Byte FIFO.
8) SDIO Pins: ESP8266 features Secure Digital Input/Output Interface (SDIO)
which is used to directly interface SD cards. 4-bit 25 MHz SDIO v1.1 and 4-bit
50 MHz SDIO v2.0 are supported.
9) PWM Pins: The board has 4 channels of Pulse Width Modulation (PWM). The
PWM output can be implemented programmatically and used for driving digital
motors and LEDs. PWM frequency range is adjustable from 1000 μs to 10000
μs, i.e., between 100 Hz and 1 kHz.
10) Control Pins: Control Pins are used to control ESP8266. These pins include
Chip Enable pin (EN), Reset pin (RST) and WAKE pin.EN pin – The ESP8266
chip is enabled when EN pin is pulled HIGH. When pulled LOW the chip works
at minimum power.RST pin – RST pin is used to reset the ESP8266 chip.
WAKE pin – Wake pin is used to wake the chip from deep-sleep.
The above screenshot is of a basic program of led blinking on arduino mega. Since we are using ESP32
so change the board to ESP32 and change the pin number to D26 for interfacing LED on IoT kit.
There are two important functions in arduino IDE:
Void setup()- In this function, a user can declare the I/O pins as input or output. This function will
call the instructions written inside it on the start of ESP32 microcontroller or any other microcontroller
the user is using and will call only once. To declare a pin as an input or output “pinMode()” function
is used.
Void loop()- In this function, the user can write the instructions which he/she wants to execute again
and again that are in loop. To give output to a pin “digitalWrite()” function is used and to take input
from a pin “digitalRead()” function is used.
Result
Thus we have successfully understood the concept of Node MCU 32 and Arduino IDE
Software.
Experiment No. 2
Aim To interface Digital sensor (IR) with ESP-WROOM-32 and write a program to
turn ON LED at sensor detection
Apparatus
IoT, Micro USB cable, LED, IR sensor module, jumper wires.
Theory
IR sensor is a digital sensor consisting of LM358 IC. The LM358 series consists of two independent,
high gain, internally frequency compensated operational amplifiers which were designed specifically
to operate from a single power supply over a wide range of voltages. Operation from split power
supplies is also possible and the low power supply current drain is independent of the magnitude of
the power supply voltage. Application areas include transducer amplifiers, DC gain blocks and all the
0power supply systems.
In the IR sensor module two diodes are there, one is photodiode and other is ir diode. The IR diode
emits IR radiation and these radiations are absorbed by the photodiode, then the circuit is open circuit
and the IR sensor doesn’t give any output. When any obstacle comes in front of the IR diode and
photodiode stops absorbing radiation and the circuit becomes a closed circuit and the IR sensor gives
a digital output in the form of voltage. This output of the IR sensor is taken as digital input in the
ESP32 and when this input comes the led glows.
Circuit Diagram
4. After the programming is complete click on ✓ button to compile the code so that if there is any error the
arduino IDE can detect it.
Experiment No. 3
Aim
To interface LED with ESP-WROOM-32 and write a program to turn ON LED for 1
sec after every 2 seconds
Apparatus
IoT, laptop or computer, Arduino IDE, LED, micro USB cable, female to male jumper wires,
resistor.
Theory
ESP-WROOM-32 has 26 I/O pins. A simple led runs on a DC voltage signal by applying positive
voltage to positive leg (longer leg, which indicates the positive, anode pin) of led and negative voltage
to negative leg (shorter leg, which indicates negative, cathode pin) of led, that is giving high and low
voltages to led. In a digital system, logic ‘1’ means high and logic ‘0’ means low. When high signal
(logic ‘1’) is given to the positive leg of led from IoT with negative leg of led on ground of IoT then
the led glow and when low signal (logic ‘0’) is given then the led switches off.
Circuit Diagram
Procedure
1. Connect ESP-WROOM-32 with your OS using a micro USB cable.
2. Open Arduino IDE
3. Then go to the Tools/board/board manager option.
5. Then select the port on which ESP-32 is connected to your OS. Users can cross check the port in the Device
Manager.
6. Write the program given below.
7. After the programming is completed click on ✓ button to compile the code so that if there is any error the
arduino IDE can detect it.
11. Led positive leg is connected to pin D26 and the negative leg is connected to the GND of ESP32.
12. Press the EN button on ESP32 to reset ESP32.
13. Once the program is uploaded you can see the bulb blinking.
Program
#define led_pin D1
void setup()
{
pinMode(led_pin , OUTPUT);
}
void loop()
{
digitalWrite(led_pin , HIGH);
delay(1000);
digitalWrite(led_pin , LOW);
delay(2000);
}
#define led_pin D1
void setup()
{
pinMode(led_pin , OUTPUT);
}
void loop()
{
digitalWrite(led_pin , HIGH);
delay(1000);
digitalWrite(led_pin , LOW);
delay(2000);
}
Experiment No. 4
Aim
To interface Water level indicator with ESP-WROOM-32 and write a program to turn
ON LED at sensor detection
Apparatus:
NODE MCU
Water level sensor module
LED
Jumper wires
Theory:
In this project we will be building a water level indicator using Arduino & water sensor with the help
of LED to indicate that the tank is full.
The water level indicator circuits are used in factories, chemical plants, and electrical substations and
in other liquid storage systems. There are many possible uses for this simple system, examples include
monitoring a sump pit (to control pump activation), rainfall detection, and leakage detection.
Electronic water level circuits have the capability of alerting if there is a water leak somewhere in the
factory. When the water level is too high or too low or exceeds the higher limit, it can detect the water
level easily by hearing an alarm sound or from different colours of a light bulb. We can also measure
the fuel level in motor vehicles and the liquid level containers which are huge in the companies.
The circuit is designed to indicate levels of water stored in the tank: low level and full level. When
there is no water in the tank, the LEDs is off as an indication that the tank is completely empty. When
water level increases and touches the sensor, the LED will glow indicating that there is water within
the tank.
Procedure:
1. Make the connections as per the circuit diagram.
2. Check the ground connection precisely before switching on the power supply.
3. Connect USB Cable to PC.
4. Write the Code in. Arduino IDE
5. Compile Code in Arduino IDE
6. Upload the code on Node MCU
7. Observe the output.
Department of First Year Engineering Internet of Things Lab
By: Dr. Rahul Pethe
G H RAISONI INSTITUTE OF ENGINEERING & TECHNOLOGY 1
(Approved by AICTE, New Delhi and Recognized by DTE, Maharashtra)
An Autonomous Institute Affiliated to Rashtrasant Tukadoji Maharaj Nagpur University, Nagpur
Accredited by NAAC with A+ Grade
Shraddha Park, B-37-39/1, MIDC, Hingna-Wadi Link Road, Nagpur-440016 (INDIA)
Phone Nos.: 07104-234501 Fax: +91-07104-234501
Email: - [email protected] Web: - www.ghrietn.raisoni.net
DEPARTMENT OF FIRST YEAR ENGINEERING
#define led D1
void setup()
{
Serial.begin(9600);
pinMode(led,OUTPUT);
}
void loop()
{
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
if(sensorValue>=30)
{
digitalWrite(led,HIGH);
}
else
{
digitalWrite(led,LOW);
}
delay(5000);
}
Results: Design and interface water level indicator using NODE MCU successfully implemented.
Experiment No. 5
Aim
To interface DHT11 sensor with ESP-WROOM-32 and write a program to print
temperature and humidity readings on Serial monitor
Apparatus
IoT, Micro USB cable, DHT11 temperature sensor, jumper wires.
Theory
DHT11 Temperature & Humidity Sensor features a temperature & humidity sensor complex with a
calibrated digital signal output. By using the exclusive digital-signal-acquisition technique and
temperature & humidity sensing technology, it ensures high reliability and excellent long-term
stability. This sensor includes a resistive-type humidity measurement component and an NTC
temperature measurement component, and connects to a high performance 8-bit microcontroller,
offering excellent quality, fast response, anti-interference ability and cost-effectiveness. The
calibration coefficients are stored as programmes in the OTP memory, which are used by the sensor’s
internal signal detecting process. The single-wire serial interface makes system integration quick and
easy. Its small size, low power consumption and up-to-20 meter signal transmission make it the best
choice for various applications, including those most demanding ones. When MCU sends a start signal,
DHT11 changes from the low-power-consumption mode to the running-mode, waiting for MCU to
complete the start signal. Once it is completed, DHT11 sends a response signal of 40-bit data that
includes the relative humidity and temperature information to MCU. Users can choose to collect (read)
some data. Without the start signal from MCU, DHT11 will not give the response signal to MCU.
Once data is collected, DHT11 will change to the low power-consumption mode until it receives a
start signal from MCU again.
For more information on DHT11 sensor click on the link
below- https://www.mouser.com/ds/2/758/DHT11-Technical-Data-Sheet-Translated-Version-
1143054.pdf
Circuit Diagram
Procedure
1. Connect ESP-WROOM-32 with your OS using a micro USB cable.
2. Follow the Steps No.2 to Step No.7 of Experiment No.2 for installation and selection of Board. If you have
already done these steps then continue from Step no.3.
3. For interfacing DHT11 sensor, you need to install a library of DHT11. To install the library, go to the
Sketch/Include library/Manage Libraries menu.
4. Search for DHT11 Sensor library in libraries list and install DHT Sensor library by Adafruit. This library
includes all types of DHT Sensors interfacing.
Program
//Reading temperature or humidity may take about 2 seconds because it is a very slow sensor.
float humidity = dht.readHumidity ( ) ; // Declaring humidity a variable and storing the humidity
in it.
float temp = dht.readTemperature ( ) ; // Declaring te a variable and storing the temperature in it.
// Checking if the output is correct. If these are NaN, then there is something in it.
if ( isnan (temp) || isnan (humidity) ) {
Serial.println ( " Sensor not working " ) ;
}
#include "DHT.h"
void setup()
{
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F("°F"));
Department of First Year Engineering Internet of Things Lab
By: Dr. Rahul Pethe
G H RAISONI INSTITUTE OF ENGINEERING & TECHNOLOGY 2
(Approved by AICTE, New Delhi and Recognized by DTE, Maharashtra)
An Autonomous Institute Affiliated to Rashtrasant Tukadoji Maharaj Nagpur University, Nagpur
Accredited by NAAC with A+ Grade
Shraddha Park, B-37-39/1, MIDC, Hingna-Wadi Link Road, Nagpur-440016 (INDIA)
Phone Nos.: 07104-234501 Fax: +91-07104-234501
Email: - [email protected] Web: - www.ghrietn.raisoni.net
DEPARTMENT OF FIRST YEAR ENGINEERING
Experiment No. 6
Aim Write a program on ESP-WROOM-32 to upload temperature and humidity data to
the cloud.
Apparatus
IoT Kit Box, micro usb cable, DHT11 Temperature sensor, jumper wires.
Theory
ESP32-DevKitC V4 is a small-sized ESP32-based development board produced by Espressif. Most
of the I/O pins are broken out to the pin headers on both sides for easy interfacing. Developers can
either connect peripherals with jumper wires or mount ESP32-DevKitC V4 on a breadboard.
To cover a wide range of user requirements, the following versions of ESP-32 DevKitC v4 are
available:
ESP-WROOM-32
ESP-WROOM-32D
ESP-WROOM-32U
ESP-SOLO-1
ESP-WROVER
Key Description
Component
ESP32-
A module with ESP32 at its core.
WROOM-32
EN Reset button.
USB-to-UART
Single USB-UART bridge chip provides transfer rates of up to 3 Mbps.
Bridge
Micro USB USB interface. Power supply for the board as well as the communication
Port interface between a computer and the ESP32 module.
5V Power On Turns on when the USB or an external 5V power supply is connected to the
LED
board. For details see the schematics in Related Documents.
Most of the pins on the ESP module are broken out to the pin headers on the
I/O board. You can program ESP32 to enable multiple functions such as PWM,
ADC, DAC, I2C, I2S, SPI, etc.
ESP-WROVER-B
ESP-WROVER-I
ESP-WROVER-B(IPEX)
Circuit Diagram
Procedure
1. Connect ESP-WROOM-32 with your OS using a micro USB cable.
2. Follow the Steps No.2 to Step No.7 of Experiment No.2 for installation and selection of Board. If you have
already done these steps then continue from Step no.3.
3. Download PubSubClient and arduino json library from the Library Manager.
4. Write the program given below.
5. Replace ssid and password with your wifi id and password.
6. To establish the communication between Hardware and Website go to the website api.thingspeak.com Now
click on Login.
7. Now click on the Sign Up button and create your personal account on the live server. It’s totally free.
8. After creating your account Login to the Website api.thingspeak.com and create the Channel.
Program
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include "DHT.h"
void setup()
{
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F("°F"));
}
Experiment No. 7
Aim
To interface Bluetooth with ESP-WROOM-32 and write a program to turn LED
ON/OFF when ‘1’/’0’ is received from smartphone using Bluetooth.
Apparatus
IoT Kit, Micro USB cable, 5mm LED, HC-05 Bluetooth, Jumper wires.
Theory
HC‐05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent
wireless serial connection setup. The HC-05 Bluetooth Module can be used in a Master or Slave
configuration, making it a great solution for wireless communication. This serial port bluetooth
module is fully qualified Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with
complete 2.4GHz radio transceiver and baseband. It uses CSR Bluecore 04‐External single chip
Bluetooth system with CMOS technology and with AFH (Adaptive Frequency Hopping Feature). The
Bluetooth module HC-05 is a MASTER/SLAVE module. By default, the factory setting is SLAVE.
The Role of the module (Master or Slave) can be configured only by AT COMMANDS. The slave
modules cannot initiate a connection to another Bluetooth device, but can accept connections. Master
module can initiate a connection to other devices. The user can simply use it for a serial port
replacement to establish connection between MCU and GPS, PC to your embedded project, etc.
Hardware Features
Typical ‐80dBm sensitivity.
Up to +4dBm RF transmit power.
3.3 to 5 V I/O.
PIO(Programmable Input/Output) control.
UART interface with programmable baud rate.
With an integrated antenna.
With an edge connector.
Software Features
Slave default Baud rate: 9600, Data bits:8, Stop bit:1,Parity: no parity.
Auto‐connect to the last device on power as default.
Permit pairing device to connect as default.
Auto‐pairing Pin:”1234” as default.
HC-05 Bluetooth
The HC-05 Bluetooth Module has 6 pins. They are as follows:
ENABLE: When enable is pulled LOW, the module is disabled which means the module will not turn on and
it fails to communicate. When enable is left open or connected to 3.3V, the module is enabled i.e the module
remains on and communication also takes place.
Vcc: Supply Voltage 3.3V to 5V
GND: Ground pin
TXD & RXD: These two pins acts as UART interface for communication
STATE: It acts as a status indicator. When the module is not connected to / paired with any other bluetooth
device, the signal goes Low. At this low state, the led flashes continuously which denotes that the module is
not paired with other devices. When this module is connected to/paired with any other bluetooth device, the
signal goes High. At this high state, the led blinks with a constant delay, say for example 2s delay which
indicates that the module is paired.
BUTTON SWITCH: This is used to switch the module into AT command mode. To enable AT command
mode, press the button switch for a second. With the help of AT commands, the user can change the
parameters of this module but only when the module is not paired with any other BT device. If the module is
connected to any other bluetooth device, it starts to communicate with that device and fails to work in AT
command mode.
Circuit Diagram
Department of First Year Engineering Internet of Things Lab
By: Dr. Rahul Pethe
G H RAISONI INSTITUTE OF ENGINEERING & TECHNOLOGY 3
(Approved by AICTE, New Delhi and Recognized by DTE, Maharashtra)
An Autonomous Institute Affiliated to Rashtrasant Tukadoji Maharaj Nagpur University, Nagpur
Accredited by NAAC with A+ Grade
Shraddha Park, B-37-39/1, MIDC, Hingna-Wadi Link Road, Nagpur-440016 (INDIA)
Phone Nos.: 07104-234501 Fax: +91-07104-234501
Email: - [email protected] Web: - www.ghrietn.raisoni.net
DEPARTMENT OF FIRST YEAR ENGINEERING
13. Click on MODES/BLUETOOTH TERMINAL menu and connect module HC-05 Bluetooth.
HC05 App
14. Now Type ‘1’ in BLUETOOTH TERMINAL then the LED will glow and if you type ‘0’ then the LED will
switch off.
Program
#include <HC05.h>
//#define led D1
//#include "BluetoothSerial.h"
void setup() {
pinMode(D1,OUTPUT);
Serial.begin(9600);
void loop() {
if(Serial.available()).
char data;
data=Serial.read();
if(data=='x')
digitalWrite(D1, HIGH);
delay(1000);
else if(data=='y')
digitalWrite(D1, LOW);
Experiment No. 8
Aim
Write a program for making smart air pollution meters using IoT Kit and ThingSpeak
IoT cloud as GUI.
Apparatus
IoT, Micro USB cable, Air Pollution Meter Sensor Box, Arduino IDE.
Theory
ESP32-DevKitC V4 is a small-sized ESP32-based development board produced by Espressif. Most
of the I/O pins are broken out to the pin headers on both sides for easy interfacing. Developers can
either connect peripherals with jumper wires or mount ESP32-DevKitC V4 on a breadboard.
To cover a wide range of user requirements, the following versions of ESP-32 DevKitC v4 are
available:
ESP-WROOM-32
ESP-WROOM-32D
ESP-WROOM-32U
ESP-SOLO-1
ESP-WROVER
ESP-WROVER-B
ESP-WROVER-I
ESP-WROVER-B(IPEX)
Key Component Description
EN Reset button.
Most of the pins on the ESP module are broken out to the pin
I/O headers on the board. You can program ESP32 to enable multiple
functions such as PWM, ADC, DAC, I2C, I2S, SPI, etc.
Dust Sensor
Air quality sensor for detecting a wide range of gases, including NH3, NOx, alcohol, benzene, smoke
and CO2. Ideal for use in the office or factory. Air quality sensor has high sensitivity to Ammonia,
Sulfide and Benze steam, also sensitive to smoke and other harmful gases. It is low cost and
particularly suitable for Air quality monitoring application.
Sensitive material of the Carbon Monoxide sensor is SnO2, which has lower conductivity in clean air.
It makes detection by method of cycle high and low temperature, and detect CO when low temperature
(heated by 1.5V). The sensor’s conductivity is higher along with the gas concentration rising. When
high temperature (heated by 5.0V), it cleans the other gases adsorbed under low temperature. Please
use simple electro circuit, Convert change of conductivity to correspond output signal of gas
concentration. Carbon Monoxide sensor has high sensitivity to Carbon Monoxide. The sensor could
be used to detect different gases containing CO, it is low cost and suitable for different applications.
Circuit Diagram
Smart Air Pollution Meter sensor module with IoT Learning Box
Smart Air Pollution Meter Sensor Module Pins IoT Learning Box Pins
Dust Sensor
GND GND
ILed Rx0
GND GND
A-Out Vp
Vcc 3V3
MQ7 Sensor
+5v 3V3
GND GND
A-Out D32
MQ135 Sensor
+5V 3V3
GND GND
A-Out D35
LM35 Sensor
+5V 3V3
GND GND
A-Out D34
Procedure
1. Connect ESP-WROOM-32 with your OS using a micro USB cable.
2. Follow the Steps No.2 to Step No.7 of Experiment No.2 for installation and selection of Board. If you have
already done these steps then continue from Step no.3.
3. Download the MQ7 sensor library from the Library Manager.
4. Write the program given below.
5. Replace ssid and password with your wifi id and password.
6. Login to the ThingSpeak IoT Portal and create the channel as shown in Experiment No. 9.
7. Open the Channel and copy the API Key and paste it in the program.
8. Now click on ✓ button to compile the program to check whether the code is error free or not.
9. Once the code is compiled and is error free then click on → button to upload the code in ESP32.
10. While uploading the code, long press the boot button on ESP32 otherwise the program will not upload in the
microcontroller (ESP32).
11. Connect the circuit as shown in the circuit diagram above.
12. Press the EN button available on ESP32 to reset ESP32.
13. Then click on the Chart and see data coming from the ESP32.
14. Field1 chart shows the Dust Density, Field2 chart shows the Mq7-CO content in air, Field3 chart shows the
Quality of Air using MQ135 sensor and Field4 chart shows the Temperature in Celsius.
Output
Program
#include <ESP8266WiFi.h>
String apiKey = "CVBKY4XEQNYQ31PF"; // Enter your Write API key from ThingSpeak
const char *ssid = "Ram"; // replace with your wifi ssid and wpa2 key
const char *pass = "Rahulram2";
const char* server = "api.thingspeak.com";
WiFiClient client;
void setup()
{
Serial.begin(115200);
delay(100);
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
Department of First Year Engineering Internet of Things Lab
By: Dr. Rahul Pethe
G H RAISONI INSTITUTE OF ENGINEERING & TECHNOLOGY 4
(Approved by AICTE, New Delhi and Recognized by DTE, Maharashtra)
An Autonomous Institute Affiliated to Rashtrasant Tukadoji Maharaj Nagpur University, Nagpur
Accredited by NAAC with A+ Grade
Shraddha Park, B-37-39/1, MIDC, Hingna-Wadi Link Road, Nagpur-440016 (INDIA)
Phone Nos.: 07104-234501 Fax: +91-07104-234501
Email: - [email protected] Web: - www.ghrietn.raisoni.net
DEPARTMENT OF FIRST YEAR ENGINEERING
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
}
void loop()
{
float h = analogRead(A0);
if (isnan(h))
{
Serial.println("Failed to read from MQ-5 sensor!");
return;
}