arduinoprojects

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

dhtnew_suppressError.ino (1318B)


      1 //
      2 //    FILE: dhtnew_suppressError.ino
      3 //  AUTHOR: Rob Tillaart
      4 // VERSION: 0.1.0
      5 // PURPOSE: DHTNEW library test sketch
      6 //     URL: https://github.com/RobTillaart/DHTNew
      7 //
      8 // HISTORY:
      9 // 0.1.0    2020-07-17 initial version
     10 //
     11 // DHT PIN layout from left to right
     12 // =================================
     13 // FRONT : DESCRIPTION
     14 // pin 1 : VCC
     15 // pin 2 : DATA
     16 // pin 3 : Not Connected
     17 // pin 4 : GND
     18 
     19 
     20 // run sketch without connected sensor to see effect
     21 
     22 #include <dhtnew.h>
     23 
     24 DHTNEW mySensor(16);
     25 
     26 uint32_t count = 0;
     27 
     28 void setup()
     29 {
     30   Serial.begin(115200);
     31   Serial.println(__FILE__);
     32   Serial.println();
     33 
     34   // test flag working => prints 010
     35   Serial.print(mySensor.getSuppressError());
     36   mySensor.setSuppressError(true);
     37   Serial.print(mySensor.getSuppressError());
     38   mySensor.setSuppressError(false);
     39   Serial.print(mySensor.getSuppressError());
     40 
     41   // change to false to see difference
     42   mySensor.setSuppressError(true);
     43   Serial.println();
     44 }
     45 
     46 void loop()
     47 {
     48   if (millis() - mySensor.lastRead() > 2000)
     49   {
     50     if ((count % 10) == 0) Serial.println("\nERR\tHUM\tTEMP");
     51     count++;
     52 
     53     int errcode = mySensor.read();
     54     Serial.print(errcode);
     55     Serial.print("\t");
     56     Serial.print(mySensor.getHumidity(), 1);
     57     Serial.print("\t");
     58     Serial.println(mySensor.getTemperature(), 1);
     59   }
     60 }
     61 
     62 // -- END OF FILE --