61 lines
1.1 KiB
Arduino
Raw Normal View History

2021-01-29 12:31:58 +01:00
//
// FILE: dhtnew_runtime.ino
// AUTHOR: Rob Tillaart
// PURPOSE: DHTNEW library test sketch
// URL: https://github.com/RobTillaart/DHTNew
2021-12-16 17:24:05 +01:00
2021-01-29 12:31:58 +01:00
// DHT PIN layout from left to right
// =================================
// FRONT : DESCRIPTION
// pin 1 : VCC
// pin 2 : DATA
// pin 3 : Not Connected
// pin 4 : GND
#include <dhtnew.h>
2021-11-18 09:48:40 +01:00
DHTNEW mySensor(5); // ESP 16 UNO 5 MKR1010 5
2021-01-29 12:31:58 +01:00
uint32_t lastTime = 0;
2021-11-18 09:48:40 +01:00
2021-01-29 12:31:58 +01:00
void setup()
{
2021-11-18 09:48:40 +01:00
while(!Serial); // MKR1010 needs this
2021-01-29 12:31:58 +01:00
Serial.begin(115200);
Serial.println(__FILE__);
2021-11-18 09:48:40 +01:00
Serial.print("DHTNEW_LIB_VERSION: ");
2021-01-29 12:31:58 +01:00
Serial.println(DHTNEW_LIB_VERSION);
2021-11-18 09:48:40 +01:00
// MKR1010 needs this
// mySensor.setDisableIRQ(false);
2021-01-29 12:31:58 +01:00
}
2021-11-18 09:48:40 +01:00
2021-01-29 12:31:58 +01:00
void loop()
{
if (millis() - lastTime > 2000)
{
lastTime = millis();
for (int pin = 6; pin < 10; pin++)
{
DHTNEW sensor(pin);
sensor.read();
Serial.print(pin);
Serial.print("\t");
Serial.print(sensor.getHumidity(), 1);
Serial.print("\t");
Serial.println(sensor.getTemperature(), 1);
}
}
// Do other things here
}
2021-11-18 09:48:40 +01:00
// -- END OF FILE --