You are on page 1of 13

INTERFACING TEMPERATURE SENSOR USING

NODE MCU

• AIM : To study about interfacing temperature sensor using node mcu.


• Components Required : DHT11/DHT22 sensor
Node mcu Board
Jumper wires
USB cable

• Software Used : Arduino IDE


THEORY
• DHT11 is a low cost digital sensor for sensing temperature and humidity .
• DHT11 sensor consists of a capacitive humidity sensing element and a
thermistor for the purpose of sensing temperature.
• It 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.
HARDWARE PROCEDURE
• Connect VCC pin of DHT11 sensor to 3.3v input pin of node mcu board.
• Connect Data out pin to any GPIO pin in the board.
• Connect Ground pin to the ground in the board.
• Connect USB connector to node mcu to monitor.
SOFTWARE PROCEDURE
• Open Arduino IDE software.
• Click on file , go to New.
• Write a program as per circuit pin connections.
• Go to sketch select include library and go to manage library.
• Install some libraries which are used in the program .
• Go to tools and select type of board.
• Now go to port and select other board and port.
• Now click on save and verify the program.
• Click on upload and dump the code into node mcu using USB cable.
• Observe the output in the serial monitor.

PROGRAM :
#include "DHT.h"
#define DPIN 4 //Pin to connect DHT sensor (GPIO number) D2
#define DTYPE DHT11 // Define DHT 11 or DHT22 sensor type
DHT dht(DPIN,DTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
delay(2000);
float tc = dht.readTemperature(false); //Read temperature in C
float tf = dht.readTemperature(true); //Read Temperature in F
float hu = dht.readHumidity(); //Read Humidity
Serial.print("Temp: ");
Serial.print(tc);
Serial.print(" C, ");
Serial.print(tf);
Serial.print(" F, Hum: ");
Serial.print(hu);
Serial.println("%");
}
OUTPUT :

RESULT : Thus , study about interfacing temperature sensor using


node mcu board is completed and verified successfully.

You might also like