Greetings
The board I use is Linknode D1 and connect to Blynk with ESP8266
I’m doing a project : flower planting
and have DHT11 and other sensors
the problem is I can connect to the Blynk cloud
but once I open the Blynk app the device will be online a while
then it will offline and online again and again
I don’t know how to solve this problem
here is my code and screen shots
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "DHT.h"
#define DHTPIN D8
#define DHTTYPE DHT11
char auth[] = "1c5f028a0ec04036be337b26xxxxxxxx";
//wifi
char ssid[] = "xxx";
char pass[] = "xxx";
DHT dht(DHTPIN, DHTTYPE);
int moistureSensor = A0;
void setup()
{
Serial.begin(9600);
pinMode (D11, OUTPUT);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
delay(1000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t) ) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" ");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
//soil humidity
Serial.print("土壤溼度值: ");
int k = analogRead(A0);
Serial.println(k);
delay(1000);
//relay
if (k > 700)
{
digitalWrite(D11, LOW);
}
if (k < 600)
{
digitalWrite(D11, HIGH);
}
Blynk.virtualWrite(V1, h);
Blynk.virtualWrite(V2, t);
Blynk.virtualWrite(V3, k);
}
