[text] So

Viewer

  1. #include <dht.h>
  2.  
  3. dht DHT;
  4.  
  5. #define DHTPIN 3 // Pin where the DHT11 is connected
  6.  
  7. void setup() {
  8.   Serial.begin(9600);
  9. }
  10.  
  11. void loop() {
  12.   int chk = DHT.read11(DHTPIN);
  13.   Serial.print("Temperature = ");
  14.   Serial.print(DHT.temperature);
  15.   Serial.println(" *C");
  16.   Serial.print("Humidity = ");
  17.   Serial.print(DHT.humidity);
  18.   Serial.println(" %");
  19.  
  20.   delay(2000); // Wait for 2 seconds before reading again
  21. }
  22.  

Editor

You can edit this paste and save as new:


File Description
  • So
  • Paste Code
  • 05 May-2024
  • 427 Bytes
You can Share it: