You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And I also tried in another way. I installed the DHT11-master library. If I work with this library then I have to change some code logic which I write down above. if I run this code including dht11 library then its showing the error in the below line.
float h= dht.readHumidity();
float t = dht.readTemperature();
'class dht11' has no member named 'readHumidity'
Can anyone please help me to re-write the code to work?
The text was updated successfully, but these errors were encountered:
I connected the DHT11 data pin (2) to ESP8266's D2 (GPIO 4) and define in sketch #define DHTPIN 4 for sending the temperature and humidity data to Firebase.
Following is the script.
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <DHT.h>
//#include <ESP8266HTTPClient.h>
//#include <SoftwareSerial.h>
#include <Adafruit_Sensor.h>
#define FIREBASE_HOST "yourproject.firebaseio.com"
#define FIREBASE_AUTH "000000000000000000000"
#define WIFI_SSID "MMMM"
#define WIFI_PASSWORD "XXXXXXXXXi"
#define DHTPIN 4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
delay(1000);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to ");
Serial.print(WIFI_SSID);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("Connected to ");
Serial.println(WIFI_SSID);
Serial.print("IP Address is : ");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.print("Humidity: ");
Serial.print(h);
String fireHumid = String(h) + String("%");
Serial.print("% Temperature: ");
Serial.print(t); Serial.println("°C ");
String fireTemp = String(t) + String("°C");
delay(4000);
Firebase.pushString("xxxx.firebaseio.com/DHT11/Humidity", fireHumid);
Firebase.pushString("xxxx.firebaseio.com/DHT11/Temperature", fireTemp);
}
And I also tried in another way. I installed the DHT11-master library. If I work with this library then I have to change some code logic which I write down above. if I run this code including dht11 library then its showing the error in the below line.
float h= dht.readHumidity();
float t = dht.readTemperature();
'class dht11' has no member named 'readHumidity'
Can anyone please help me to re-write the code to work?
The text was updated successfully, but these errors were encountered: