PlatformIO Community

Problem with DHT.h


#1

Very new to using platformio, trying to use the DHT 22 sensor with a standard ESP 32 development board.
I have tried to include all the library files but I’m getting one error as below:
#include <Arduino.h>
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <Wire.h>
#include <Adafruit_BMP280.h>
#include <DTH.h>
when you try and hover over the statement it reads DHT.h no such file or directory
I tried adding the file into the platformio.ini

[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git#feature/stage
board = esp32dev
framework = arduino
upload_port=192.168.1.77
lib_deps=
https://github.com/blynkkk/blynk-library
https://github.com/adafruit/Adafruit_Sensor


https://github.com/adafruit/Adafruit DHT Unified

I must be doing something very obviously wrong but I just do not know what
can anyone help please?
PS the same library and the same board and code works fine on the Arduino IDE but I really would like to continue using your new platformio.


#2

Try to make the library reference list in platformio.ini to look as:

lib_deps=
Blynk
Adafruit Unified Sensor
DHT sensor library

or:

lib_deps=
https://github.com/blynkkk/blynk-library.git
https://github.com/adafruit/Adafruit_Sensor
https://github.com/adafruit/DHT-sensor-library


DHT Library reports 'nan'
#3

Thank you for taking the time to reply and yes that does now work.
But if you have the time please can you explain simply how you got that answer.
As I’m sure it will come up again and I would like to learn.
Thanking you all again for any advice or suggestions you can offer


#4

Based on my experience with a project where I’m using Adafruit’s generic DHT sensor library approach to support the DHT22 sensor I learned I have to use the two libraries:

The platformio.ini manual page shows how library dependencies can be configured for your project: http://docs.platformio.org/en/latest/projectconf/section_env_library.html

Using the platformio.org library search results show you how to integrate the libraries into the platformio.ini file (see the installation tab):