Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SimpleDHT.h>
- //Matt Vawrinek
- //6/18/17
- //Temp and Humidity Sensor Basic Code
- // for DHT11,
- // VCC: 5V or 3V
- // GND: GND
- // DATA: 2
- int pinDHT11 = 3;
- SimpleDHT11 dht11; //name of library//
- void setup() {
- Serial.begin(9600);
- }
- void loop() {
- // start working...
- Serial.println("=================================");
- Serial.println("Sample DHT11...");
- // read without samples.
- byte temperature = 0;
- byte humidity = 0;
- if (dht11.read(pinDHT11, &temperature, &humidity, NULL)) {
- Serial.print("Read DHT11 failed.");
- return;
- }
- Serial.print("Sample OK: ");
- Serial.print((int)temperature); Serial.print(" *C, ");
- Serial.print((int)humidity); Serial.println(" %");
- // DHT11 sampling rate is 1HZ.
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement