Skip to content

CPP: DHT11

Leo Vidarte edited this page Mar 14, 2017 · 4 revisions

The DHT11 is a temperature and humidity sensor.

Schematic

Download the project

Checkout this PlatformIO project code here.

Libs installation

Install the following libraries

$ platformio lib install \
  https://github.com/adafruit/DHT-sensor-library.git
$ platformio lib install \
  https://github.com/adafruit/Adafruit_Sensor.git

Compilation

But... error on compiling

In file included from .piolibdeps/DHT-sensor-library/DHT_U.cpp:22:0:
.piolibdeps/DHT-sensor-library/DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory
#include <Adafruit_Sensor.h>
^
compilation terminated.

There is a known issue with Adafruit libraries. The workaround solution is to add the following line to the platformio.ini

lib_ldf_mode = 2

Then compile and open the serial monitor