DHT 11 is a digital temperature humidity sensor. It can be directly interfaced with arduino's digital pins. Dht 11 sensor has four pins out of which one is unused. The other three pins are vcc, ground and dout.
Components required
DHT11
Arduino uno/mega/mini/nano
Connecting wires
Softwares: Arduino IDE, DHT11 library
Step1. Download the DHT11 library from the abouve link
Step2. Connect DHT11 sensor to the Arduino.
Vcc -- 5v
Gnd - gnd of arduino
Dout - any desired digital pin
Step 3. Upload the sketch below.
ARDUIONO CODE
Components required
DHT11
Arduino uno/mega/mini/nano
Connecting wires
Softwares: Arduino IDE, DHT11 library
Step1. Download the DHT11 library from the abouve link
Step2. Connect DHT11 sensor to the Arduino.
Vcc -- 5v
Gnd - gnd of arduino
Dout - any desired digital pin
Step 3. Upload the sketch below.
ARDUIONO CODE
- #include <dht.h>
- dht DHT;
- #define DHT11_PIN 5
- void setup()
- {
- Serial.begin(115200);
- Serial.println("DHT TEST PROGRAM ");
- Serial.print("LIBRARY VERSION: ");
- Serial.println(DHT_LIB_VERSION);
- Serial.println();
- Serial.println("Type,\tstatus,\tHumidity (%),\tTemperature (C)");
- }
- void loop()
- {
- // READ DATA
- Serial.print("DHT11, \t");
- int chk = DHT.read11(DHT11_PIN);
- switch (chk)
- {
- case DHTLIB_OK:
- Serial.print("OK,\t");
- break;
- case DHTLIB_ERROR_CHECKSUM:
- Serial.print("Checksum error,\t");
- break;
- case DHTLIB_ERROR_TIMEOUT:
- Serial.print("Time out error,\t");
- break;
- case DHTLIB_ERROR_CONNECT:
- Serial.print("Connect error,\t");
- break;
- case DHTLIB_ERROR_ACK_L:
- Serial.print("Ack Low error,\t");
- break;
- case DHTLIB_ERROR_ACK_H:
- Serial.print("Ack High error,\t");
- break;
- default:
- Serial.print("Unknown error,\t");
- break;
- }
- // DISPLAY DATA
- Serial.print(DHT.humidity, 1);
- Serial.print(",\t");
- Serial.println(DHT.temperature, 1);
- delay(2000);
- }
The output will be displayed on the serial monitor.
Got any problems? Feel free to contact us.
Got any problems? Feel free to contact us.
No comments:
Post a Comment