arduinoprojects

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

dhtnew_runtime.ino (964B)


      1 //
      2 //    FILE: dhtnew_runtime.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    2021-01-04  intial 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 #include <dhtnew.h>
     21 
     22 DHTNEW mySensor(16);
     23 
     24 uint32_t lastTime = 0;
     25 
     26 void setup()
     27 {
     28   Serial.begin(115200);
     29   Serial.println(__FILE__);
     30   Serial.println(DHTNEW_LIB_VERSION);
     31 }
     32 
     33 void loop()
     34 {
     35   if (millis() - lastTime > 2000)
     36   {
     37     lastTime = millis();
     38     for (int pin = 6; pin < 10; pin++)
     39     {
     40       DHTNEW sensor(pin);
     41       sensor.read();
     42       Serial.print(pin);
     43       Serial.print("\t");
     44       Serial.print(sensor.getHumidity(), 1);
     45       Serial.print("\t");
     46       Serial.println(sensor.getTemperature(), 1);
     47     }
     48   }
     49 
     50   // Do other things here
     51 }
     52 
     53 // END OF FILE