Beee 2.4

You might also like

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

1.Aim: To demonstrate the working of a temperature sensor circuit.

2.Apparatus: ARDUINO UNO, temperature sensor (DHT11), connecting wires, breadboard.

3.Circuit Diagram:

Fig.1 Temperature Sensor Circuit

4.Program:

#include "DHT.h"

#define DHTPIN 2    // what digital pin we're connected to

#define DHTTYPE DHT11  // DHT 11

DHT dht(DHTPIN, DHTTYPE);

void setup()

 Serial.begin(9600);

 Serial.println("DHTxx test!");

 dht.begin();
}

void loop()

 delay(2000);

 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!");

   return;

 }

 Serial.print("Humidity: ");

 Serial.print(h);

 Serial.println(" %");

 Serial.print("Temperature: ");

 Serial.print(t);

 Serial.print(" *C  ");

 Serial.print(f);

 Serial.println(" *F");
}

5.Result:

Designing of temperature control circuit using arduino is verified after uploading the
program.

You might also like