| Dimensions | small 14 x 18 x 5.5 mm | big 22 x 28 x 5 mm |
## Interface
### Constructor
- **DHTNEW(uint8_t pin)** defines the dataPin of the sensor.
- **void reset()** might help to reset a sensor behaving badly. It does reset the library settings to default,
however it does not reset the sensor in a hardware way.
- **uint8_t getType()** 0 = unknown, 11 or 22.
In case of 0, **getType()** will try to determine type.
- **void setType(uint8_t type = 0)** allows to force the type of the sensor.
### Base interface
- **int read()** reads a new temperature and humidity from the sensor
- **uint32_t lastRead()** returns milliseconds since last **read()**
- **float getHumidity()** returns last read value (float) or -999 in case of error.
Note this error value can be suppressed by **setSuppressError(bool)**.
- **float getTemperature()** returns last read value (float) or -999 in case of error. Note this error value can be suppressed by **setSuppressError(bool)**.
### Offset
Adding offsets works well in normal range however they might introduce under- or overflow at the ends of the sensor range.
humidity is constrained to 0..100% in the code. For temperature such constrain would be type dependant, so not done.
Functions to adjust the communication with the sensor.
- **void setDisableIRQ(bool b )** allows or suppresses interrupts during core read function to keep timing as correct as possible. **Note AVR + MKR1010**
- **bool getDisableIRQ()** returns the above setting. Default **true**.
- **void setWaitForReading(bool b )** flag to enforce a blocking wait.
- **bool getWaitForReading()** returns the above setting.
- **void setReadDelay(uint16_t rd = 0)** To tune the time it waits before actual read. This reduces the blocking time.
Default depends on type. 1000 ms (dht11) or 2000 ms (dht22).
set readDelay to 0 will reset to datasheet values AFTER a call to **read()**.
- **uint16_t getReadDelay()** returns the above setting.
- **void powerDown()** pulls dataPin down to reduce power consumption
- **void powerUp()** restarts the sensor, note one must wait up to two seconds.
- **void setSuppressError(bool b)** suppress error values of -999 => you need to check the return value of read() instead.
This is used to keep spikes out of your graphs / logs.
- **bool getSuppressError()** returns the above setting.
## Operation
See examples
#### TIME_OUT
If consistent TIMOUT_C or TIMEOUT_D occur during reading a sensor,
one could try if allowing interrupts solves the issue **DHT.setDisableIRQ(false)**.
This solved this problem at least on
- AVR boards - is build into the constructor
- MKR1010 Wifi - see https://github.com/RobTillaart/DHTNew/issues/67
(added as comment in the examples)
In version 0.4.10 the TIMEOUT_C is extended from 70-90 us to even suppress the TIMEOUT_C
even more. See discussion and tests in https://github.com/RobTillaart/DHTNew/issues/67.
#### Serial
The MKR1010Wifi board need to wait for Serial at startup if you want to monitor it
from the IDE. Adding the line ```while(!Serial):``` fixes this. (added to the examples).
There might be more boards that need this line to work properly.
#### ESP8266 & DHT22
- The DHT22 sensor has some problems in combination with specific pins of the ESP8266. See more details
- https://github.com/RobTillaart/DHTNew/issues/31 (message Jan 3, 2021)