Hi, I am using the WeMos D1 Mini and DHT22 Sensor for my project. I have added 2 devices on my Blynk app, each device has it’s own tab which comes with a gauge and super chart to display the data
I have no clue as to why Device 1 is sometimes online, sometimes offline whereas Device 2 is able to display the data. At times, even when Device 1 is online, the widgets will still not be working… as shown below:
I have tried to work Device 1 alone, it does not work too. Device 1 comes online sometimes but the temperature value still does not appear. It either goes to ‘nan’ or no value. I have tried to change the sensors, wires, cables and even WeMos but it still doesn’t work…
//DEVICE -1
/*PINS
V0 =
V1 = Table
V2 =
V3 =
V4 = Stations Selections
V5 = LCD
V6 =
V7 =
V8 = RoS1
V9 = RoS2
V10= RoS3
V11 = T1 (Device 1)
V12 = T2 (Device 2)
Setpoints = V21(Device 1), V22(Device 2)
*/
//All required libraries
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "DHT.h"
#define DHTTYPE DHT22
#define dht_dpin D4
DHT dht(dht_dpin, DHTTYPE);
//All variables with their data types
float setpoint1;
int station, RoS1;
int prevValue, pRoS1;
//Your Auth Token
char auth[] = "zQ5IZJvjq3JHkMJrA5_VAYqyRiOrn_l";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "MyWifi";
char pass[] = "zucheohaen";
//For BLYNK LCD
WidgetLCD lcd(V5);
//Assigning values to some variables coming from BLYNK Virtual Pins
BLYNK_WRITE(V4)
{
station = param.asInt(); // assigning incoming value from pin V4 to a variable
}
BLYNK_WRITE(V8)
{
RoS1 = param.asInt(); // assigning incoming value from pin V8 to a variable
}
BLYNK_WRITE(V21)
{
setpoint1 = param.asFloat();
}
void setup()
{
Blynk.begin(auth, ssid, pass);
dht.begin();
Serial.begin(9600);
}
void loop()
{
Blynk.run();
prevValue = station;
pRoS1 = RoS1;
if (station == 1) {
//lcd.print(col, row, "TEXT"/VARIABLE );
lcd.print(0, 0, "Station = 1");
lcd.print(0, 1, "Rooms =");
lcd.print(8, 1, RoS1);
float t = dht.readTemperature();
Blynk.virtualWrite(V11, t);
Blynk.virtualWrite(V1, "add", 1, "TEMPERATURES", "SETPOINTS" );
Blynk.virtualWrite(V1, "add", 2, t , setpoint1);
}
else if (station == 2) {
lcd.print(0, 0, "Station = 2");
Blynk.virtualWrite(V1, "clr");
Blynk.virtualWrite(V11, 0);
}
}