Open lfrancois opened 7 years ago
Installing the library doesn't sound to help.
ludo@idefix:~/repos/esp8266-dht22-sensor % platformio lib install "DHT22"
Library Storage: /Users/ludo/repos/esp8266-dht22-sensor/.piolibdeps
Looking for DHT22 library in registry
Conflict: More than one library has been found by request {"name": "DHT22"}:
[ ID ] Name Compatibility "Authors": Description
--------------------------------------------------------------------------------------------------------------------------------------
[ 115 ] DHT22 arduino, atmelavr "Ben Adams, Craig Ringer": Digital-output relative humidity & temperature sensor/module DHT22
[ 58 ] DHT22 energia, timsp430 "Eugene Mamin": Digital-output relative humidity & temperature sensor/module DHT22
Automatically chose the first available library (use `--interactive` option to make a choice)
Found: http://platformio.org/lib/show/115/DHT22
LibraryManager: Installing id=115
Downloading [####################################] 100%
Unpacking [####################################] 100%
DHT22 @ 837124f0ce has been successfully installed!
ludo@idefix:~/repos/esp8266-dht22-sensor %
Trying to make progress with these changes
ludo@idefix:~/repos/esp8266-dht22-sensor % git diff 20:26 #4344
diff --git a/src/main.cpp b/src/main.cpp
index e39cffa..e751794 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -14,10 +14,10 @@ OneWire ds(ONE_WIRE_BUS);
#endif
#ifdef SENSOR_DHT22
-#include <DHT.h>
+#include <DHT22.h>
#include "../config.h"
#define DHTPIN 2
-DHT dht(DHTPIN, DHTTYPE, 11); // 11 works fine for ESP8266
+DHT22 dht(DHTPIN); // 11 works fine for ESP8266
#endif
MDNSResponder mdns;
@@ -174,8 +174,8 @@ int ICACHE_FLASH_ATTR read_sensors(byte bus_idx, float& temp, float& humidity) {
#ifdef SENSOR_DHT22 // Read temp&hum from DHT22
// Reading temperature for humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor)
- humidity = dht.readHumidity(); // Read humidity (percent)
- temp = dht.readTemperature(false); // Read temperature as Celsius
+ humidity = dht.getHumidity(); // Read humidity (percent)
+ temp = dht.getTemperatureC(); // Read temperature as Celsius
#endif
//Serial.print("Free heap:");
ludo@idefix:~/repos/esp8266-dht22-sensor %
ludo@idefix:.../esp8266/esp8266-dht22-sensor % git diff
diff --git a/platformio.ini b/platformio.ini
index 123995e..29f0fe5 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -18,9 +18,10 @@
# targets = upload
[env:esp01]
-platform = espressif
+platform = espressif8266
framework = arduino
board = esp01
targets = upload
# Optimize for binary size
#build_flags=-Os
+lib_deps = 19
ludo@idefix:.../esp8266/esp8266-dht22-sensor %
The project works as is, but you need to manually install the right DHT library. I installed this one in the .platformio/lib folder and then it build just fine: https://github.com/adafruit/DHT-sensor-library
It's my first experience with platformio and with the esp8266 so I am very new to it. When I try to run a platformio run, I got this issue.