A minimal library for the DHT11.

Dependencies:   mbed

Dependents:   EXP10_DHT11_LCD Sushil_MODSERIAL Core1000_SmartFarm idd_summer17_hw3_evey_jenny_seiyoung ... more

Embed: (wiki syntax)

« Back to documentation index

Dht11 Class Reference

Dht11 Class Reference

Class for the DHT11 sensor. More...

#include <Dht11.h>

Public Member Functions

 Dht11 (PinName const &p)
 Construct the sensor object.
int read ()
 Update the humidity and temp from the sensor.
float getFahrenheit ()
 Get the temp(f) from the saved object.
int getCelsius ()
 Get the temp(c) from the saved object.
int getHumidity ()
 Get the humidity from the saved object.

Detailed Description

Class for the DHT11 sensor.

Example:

 #include "mbed.h"
 #include "Dht11.h"

 Serial pc(USBTX, USBRX);
 Dht11 sensor(PTD7);
 
 int main() {
     sensor.read()
     pc.printf("T: %f, H: %d\r\n", sensor.getFahrenheit(), sensor.getHumidity());
 }

Definition at line 26 of file Dht11.h.


Constructor & Destructor Documentation

Dht11 ( PinName const &  p )

Construct the sensor object.

Parameters:
pinPinName for the sensor pin.

Definition at line 3 of file Dht11.cpp.


Member Function Documentation

int getCelsius (  )

Get the temp(c) from the saved object.

Returns:
Celsius int

Definition at line 83 of file Dht11.cpp.

float getFahrenheit (  )

Get the temp(f) from the saved object.

Returns:
Fahrenheit float

Definition at line 79 of file Dht11.cpp.

int getHumidity (  )

Get the humidity from the saved object.

Returns:
Humidity percent int

Definition at line 87 of file Dht11.cpp.

int read (  )

Update the humidity and temp from the sensor.

Returns:
0 on success, otherwise error.

Definition at line 13 of file Dht11.cpp.