Arduino and temperature sensor

In this project you can see how to see temperature using dht11 temperature sensor
for this project you need :
Arduino
dht11 temperature sensor

Circuit:
The positive pole temp sensor put into the 5v pin of arduino.
And the negative pole temp sensor put into the gnd pin of arduino.
The out temp sensor put into the A0 pin of arduino.



Code

#include <dht.h>

#define dht_apin A0 // Analog Pin sensor is connected to

dht DHT;


void setup(){

  Serial.begin(9600);

  delay(500);//Delay to let system boot

  Serial.println("DHT11 Humidity & temperature Sensor\n\n");

  delay(1000);//Wait before accessing Sensor

}//end "setup()"



void loop(){

  //Start of Program

  DHT.read11(dht_apin);



    Serial.print("Current humidity = ");

    Serial.print(DHT.humidity);

    Serial.print("%  ");

    Serial.print("temperature = ");

    Serial.print(DHT.temperature);

    Serial.println("C  ");

  delay(1000);//Wait 5 seconds before accessing sensor again.

  //Fastest should be once every two seconds.

}// end loop()

to see how work go to : https://www.youtube.com/watch?v=VjaNc-wpwOM


No comments:

Post a Comment