Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

EXPERIMENT NUMBER-4

DATE OF EXPERIMENT–27/09/2023
AIM: Interfacing DHT-11 with Arduino.
Materials required:Arduinoboard;DHT-11sensor;Jumper wire; Breadboard;
Arduino IDE installed on a computer.

CODE:
#include "DHT.h"
#define DHT_PIN 2
#define DHT_TYP DHT11
DHT dht(DHT_PIN,DHT_TYP);

void setup(){
Serial.begin(9600);
dht.begin();
}

void loop() {
delay(2000);
float humidity = dht.readHumidity();
float temperature=dht.readTemperature();
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print(" %\t");
Serial.print("Temperature:");
Serial.print(temperature);
Serial.println(" *C");
}

OUTPUT:The output of this Arduino experiment would be the periodic


readings of humidity and temperature from the DHT11 sensor, displayed on the
Arduino Serial Monitor. The readings will be updated every 2 seconds due to the
delay in the loop function.

You might also like