ccarman602

Lesson-8-Temperature

Nov 25th, 2021 (edited)
534
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Temperature and Humidity Sensor
  2. #include "DHT.h"
  3. #include <Arduino.h>
  4.  
  5. #define DHTPIN 3     // what pin we're connected to
  6. #define DHTTYPE DHT11   // DHT 11
  7. DHT dht(DHTPIN, DHTTYPE);
  8.  
  9. void setup(void) {
  10.   Serial.begin(9600);
  11.   Serial.println("DHTxx test!");
  12.   dht.begin();
  13. }
  14.  
  15. void loop(void) {
  16.  
  17.   float temp, humi;
  18.   temp = dht.readTemperature();
  19.   humi = dht.readHumidity();
  20.  
  21.   Serial.print("Temp:");
  22.   Serial.print(temp);
  23.   Serial.println("C");
  24.  
  25.   Serial.print("Humidity:");
  26.   Serial.print(humi);
  27.   Serial.println("%");
  28.  
  29.   delay(200);
  30. }
  31.  
RAW Paste Data