2020-05-22 03:20:39 -04:00
|
|
|
//
|
|
|
|
// FILE: dhtnew_minimum.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
2020-11-27 05:10:47 -05:00
|
|
|
// VERSION: 0.1.2
|
|
|
|
// PURPOSE: DHTNEW library test sketch
|
2020-05-22 03:20:39 -04:00
|
|
|
// URL: https://github.com/RobTillaart/DHTNew
|
2020-11-27 05:10:47 -05:00
|
|
|
//
|
2020-05-22 03:20:39 -04:00
|
|
|
// HISTORY:
|
|
|
|
// 0.1.0 2018-01-08 initial version
|
|
|
|
// 0.1.1 2020-04-30 replaced humidity and temperature with functions
|
2020-11-27 05:10:47 -05:00
|
|
|
// 0.1.2 2020-06-15 match 0.3.0 error handling
|
2020-05-22 03:20:39 -04: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
|
|
|
|
|
|
|
#include <dhtnew.h>
|
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
DHTNEW mySensor(16);
|
2020-05-22 03:20:39 -04:00
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
|
|
|
Serial.println();
|
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
Serial.println("BEFORE OFFSET");
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
if (millis() - mySensor.lastRead() > 2000)
|
|
|
|
{
|
|
|
|
mySensor.read();
|
|
|
|
Serial.print(mySensor.getHumidity(), 1);
|
|
|
|
Serial.print("\t");
|
|
|
|
Serial.println(mySensor.getTemperature(), 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-27 05:10:47 -05:00
|
|
|
// END OF FILE
|