Code DHT วัดอุณหภูมิและความชื้น eror DHT// แก้ไขยังไงครับ ขึ้นว่า dht22 was not declared in this scope ผมเขียนให้เชื่อมต่อกับ blynk แต่ไม่ผ่าน โหลดไลบารี่มาหมดแล้วครับ ไม่ผ่านสักที ช่วยดูให้หน่อยครับ
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#define BLYNK_PRINT Serial
char auth[] = "QSGioJ54QqODIL6jKoLZe3fui2_5Dtnv";
char ssid[] = "3bb-wlan 2.4G";
char pass[] = "0931379604";
BlynkTimer timer;
#define LED 14 // LED on chip ESP8266
#define DHTPIN 13 // pin of sensor connected to
#define DHTTYPE DHT11 // DHT22 if useDHT22
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
pinMode(LED, OUTPUT);
Serial.begin(9600);
// Blynk.begin(auth, ssid, pass);
// Blynk.begin(auth, ssid, pass, "prakitblog.com", 8181);
Blynk.begin(auth, ssid, pass, "blynk.iot-cm.com", 8080);
dht.begin();
timer.setInterval(2500, Sensor);
}
void loop()
{
Blynk.run(); // Initiates Blynk
timer.run(); // run BlynkTimer
}
void Sensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
digitalWrite(LED, LOW);
delay(1500);
return;
}
Serial.print("Humidity is: "); Serial.println(h, 1);
Serial.print("Temperature is: "); Serial.println(t, 1);
digitalWrite(LED, HIGH);
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
Arduino: 1.8.6 (Windows 8.1), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"
code_blynk_dht22_led-rgb:12:17: error: 'DHT11' was not declared in this scope
C:\Users\Advice Distributions\Videos\เน?เธฃเธ?เน€เธฃเธตเธขเธ?เธซเธ?เธญเธ?เธ?เธฑเธง\code_blynk_dht22_led-rgb\code_blynk_dht22_led-rgb.ino:13:17: note: in expansion of macro 'DHTTYPE'
C:\Users\Advice Distributions\Videos\เน?เธฃเธ?เน€เธฃเธตเธขเธ?เธซเธ?เธญเธ?เธ?เธฑเธง\code_blynk_dht22_led-rgb\code_blynk_dht22_led-rgb.ino: In function 'void setup()':
code_blynk_dht22_led-rgb:22:7: error: 'class DHT' has no member named 'begin'
C:\Users\Advice Distributions\Videos\เน?เธฃเธ?เน€เธฃเธตเธขเธ?เธซเธ?เธญเธ?เธ?เธฑเธง\code_blynk_dht22_led-rgb\code_blynk_dht22_led-rgb.ino: In function 'void Sensor()':
code_blynk_dht22_led-rgb:32:17: error: 'class DHT' has no member named 'readHumidity'
code_blynk_dht22_led-rgb:33:17: error: 'class DHT' has no member named 'readTemperature'
Multiple libraries were found for "WiFi.h"
Used: C:\Users\Advice Distributions\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
Multiple libraries were found for "BlynkSimpleEsp32.h"
Used: C:\Users\Advice Distributions\Documents\Arduino\libraries\Blynk_For_Chinese
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
Multiple libraries were found for "DHT.h"
Used: C:\Program Files (x86)\Arduino\libraries\DHT
Not used: C:\Users\Advice Distributions\Documents\Arduino\libraries\Grove_Temperature_And_Humidity_Sensor
Not used: C:\Users\Advice Distributions\Documents\Arduino\libraries\DHT_sensor_library
Not used: C:\Program Files (x86)\Arduino\libraries\DHT_sensor_library
exit status 1
'DHT11' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.