2020-05-22 03:20:39 -04:00
|
|
|
//
|
|
|
|
// FILE: dhtnew_minimum.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
2020-11-27 05:10:47 -05:00
|
|
|
// PURPOSE: DHTNEW library test sketch
|
2020-05-22 03:20:39 -04:00
|
|
|
// URL: https://github.com/RobTillaart/DHTNew
|
2021-12-16 11:24:05 -05:00
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
// DHT PIN layout from left to right
|
|
|
|
// =================================
|
|
|
|
// FRONT : DESCRIPTION
|
2020-05-22 03:20:39 -04:00
|
|
|
// pin 1 : VCC
|
|
|
|
// pin 2 : DATA
|
2020-11-27 05:10:47 -05:00
|
|
|
// pin 3 : Not Connected
|
|
|
|
// pin 4 : GND
|
2020-05-22 03:20:39 -04:00
|
|
|
|
2021-11-18 03:48:40 -05:00
|
|
|
|
2020-05-22 03:20:39 -04:00
|
|
|
#include <dhtnew.h>
|
|
|
|
|
2021-11-18 03:48:40 -05:00
|
|
|
DHTNEW mySensor(5); // ESP 16 UNO 5 MKR1010 5
|
|
|
|
|
2020-05-22 03:20:39 -04:00
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
2021-11-18 03:48:40 -05:00
|
|
|
while(!Serial); // MKR1010 needs this
|
|
|
|
|
2020-05-22 03:20:39 -04:00
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
|
|
|
Serial.println();
|
|
|
|
|
2021-11-18 03:48:40 -05:00
|
|
|
// MKR1010 needs this
|
|
|
|
// mySensor.setDisableIRQ(false);
|
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
Serial.println("BEFORE OFFSET");
|
2022-10-15 13:50:48 -04:00
|
|
|
delay(2000);
|
2020-11-27 05:10:47 -05:00
|
|
|
mySensor.read();
|
|
|
|
Serial.print(mySensor.getHumidity(), 1);
|
|
|
|
Serial.print("\t");
|
|
|
|
Serial.println(mySensor.getTemperature(), 1);
|
|
|
|
|
2020-05-22 03:20:39 -04:00
|
|
|
mySensor.setHumOffset(10);
|
2020-11-27 05:10:47 -05:00
|
|
|
mySensor.setTempOffset(-3.5);
|
|
|
|
|
|
|
|
Serial.println("AFTER OFFSET");
|
2020-05-22 03:20:39 -04:00
|
|
|
}
|
|
|
|
|
2021-11-18 03:48:40 -05:00
|
|
|
|
2020-05-22 03:20:39 -04:00
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
if (millis() - mySensor.lastRead() > 2000)
|
|
|
|
{
|
|
|
|
mySensor.read();
|
|
|
|
Serial.print(mySensor.getHumidity(), 1);
|
|
|
|
Serial.print("\t");
|
|
|
|
Serial.println(mySensor.getTemperature(), 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-18 03:48:40 -05:00
|
|
|
|
|
|
|
// -- END OF FILE --
|
|
|
|
|