Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 1.09 KB

README.md

File metadata and controls

38 lines (28 loc) · 1.09 KB

DHTxx - Digital-Output Relative Humidity & Temperature Sensor Module

The DHT temperature and humidity sensors are very popular. This projects support DHT11, DHT12, DHT21(AM2301), DHT22(AM2302).

Usage

1-Wire Protocol

// GPIO Pin, DHT Type
using (DhtSensor dht = new DhtSensor(26, DhtType.DHT22))
{
    Temperature temperature = dht.Temperature;
    double humidity = dht.Humidity;
}

I2C Protocol

Only DHT12 can use I2C protocol.

I2cConnectionSettings settings = new I2cConnectionSettings(1, DhtSensor.DefaultI2cAddressDht12);
UnixI2cDevice device = new UnixI2cDevice(settings);

using (DhtSensor dht = new DhtSensor(device))
{
    Temperature temperature = dht.Temperature;
    double humidity = dht.Humidity;
}

References