arduinoprojects

git clone https://git.tarina.org/arduinoprojects
Log | Files | Refs

dhtnew_minimum.ino (1139B)


      1 //
      2 //    FILE: dhtnew_minimum.ino
      3 //  AUTHOR: Rob Tillaart
      4 // VERSION: 0.1.2
      5 // PURPOSE: DHTNEW library test sketch
      6 //     URL: https://github.com/RobTillaart/DHTNew
      7 //
      8 // HISTORY:
      9 // 0.1.0    2018-01-08 initial version
     10 // 0.1.1    2020-04-30 replaced humidity and temperature with functions
     11 // 0.1.2    2020-06-15 match 0.3.0 error handling
     12 //
     13 // DHT PIN layout from left to right
     14 // =================================
     15 // FRONT : DESCRIPTION  
     16 // pin 1 : VCC
     17 // pin 2 : DATA
     18 // pin 3 : Not Connected
     19 // pin 4 : GND
     20 
     21 #include <dhtnew.h>
     22 
     23 DHTNEW mySensor(16);
     24 
     25 void setup()
     26 {
     27   Serial.begin(115200);
     28   Serial.println(__FILE__);
     29   Serial.println();
     30 
     31   Serial.println("BEFORE OFFSET");
     32   mySensor.read();
     33   Serial.print(mySensor.getHumidity(), 1);
     34   Serial.print("\t");
     35   Serial.println(mySensor.getTemperature(), 1);
     36 
     37   mySensor.setHumOffset(10);
     38   mySensor.setTempOffset(-3.5);
     39 
     40   Serial.println("AFTER OFFSET");
     41 }
     42 
     43 void loop()
     44 {
     45   if (millis() - mySensor.lastRead() > 2000)
     46   {
     47     mySensor.read();
     48     Serial.print(mySensor.getHumidity(), 1);
     49     Serial.print("\t");
     50     Serial.println(mySensor.getTemperature(), 1);
     51   }
     52 }
     53 
     54 // END OF FILE