© 2024 EasyEDA Some rights reserved ISO/IEC
1.Easy to use and quick to get started
2.The process supports design scales of 300 devices or 1000 pads
3.Supports simple circuit simulation
4.For students, teachers, creators
1.Brand new interactions and interfaces
2.Smooth support for design sizes of over 5,000 devices or 10,000 pads
3.More rigorous design constraints, more standardized processes
4.For enterprises, more professional users
STD DHT11 Humidity temperature Sensor
Mode: Editors' pick
#include
dht DHT;
#define DHT11_PIN 3
void setup()
{
Serial.begin(9600);
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 from this program to the Serial Monitor will be something like this:**
![DGT11 serial][3]
[1]: /editor/20151225/567cf1669d5e0.JPG
[2]: /editor/20151225/567cf3c71a17a.JPG
[3]: /editor/20151225/567cf44137c9e.jpgID | Name | Designator | Footprint | Quantity |
---|---|---|---|---|
1 | DHT11 | U1 | SNR4-2.54-15.5X12.0X5.5MM | 1 |
2 | Arduino MEGA 2560 | U2 | DIP | 1 |
3 | 1k | R1 | R3 | 1 |
4 | LED | D1 | LED3MM | 1 |
Unfold
Loading...
Do you need to add this project to the album?