Good day dear forum members! Please help. I’m a beginner in this business. Made project 4 sensor two -DHT22 and two DHT11. One on the street (of course DHT22, one in the garage DHT22 and two in the cellar and the pit DHT11. The purpose of this - with more than 60 % humidity fans are included. at 55% off. But if the outside humidity is less than in the garage, pit, cellar ( in the sketch while the latter is not). If the fan is turned on. on the phone (blink app) led indicator lights up. All this happened but with one sensor. The relay is triggered, the led on the phone lights up. Now I can not connect the other LEDs. errors are issued. A compile-time error for the Board LOLIN (WEMOS) D1 mini Pro. The latest version of the IDE has another error - expected unqualified-id before ‘)’ token. Could you tell me people good, where I made mistakes?
Here’s the sketch
/**************************************************************
www.EK21 - произвосдство и поставка ЭНЕРГЕТИЧЕСКОГО ОБОРУДОВАНИЯ.
**************************************************************
* This example runs directly on ESP8266 chip.
*
* You need to install this for ESP8266 development:
* https://github.com/esp8266/Arduino
*
* Please be sure to select the right ESP8266 module
* in the Tools -> Board menu!
*
* Change WiFi ssid, pass, and Blynk auth token to run :)
*
**************************************************************/
#include "DHT.h"
#define fan1 D1 //вентилятор D1 Гараж
#define fan2 D5 //вентилятор D5 Подвал
#define fan3 D6 //вентилятор D1 Смотровая яма
#define DHT1PIN D0//датчик на улице
#define DHT2PIN D4//датчик в гараже
#define DHT3PIN D3//датчик в подвале
#define DHT4PIN D2//датчик в смотровой яме
#define DHT1TYPE DHT22)
#define DHT2TYPE DHT22)
#define DHT3TYPE DHT11)
#define DHT4TYPE DHT11)
DHT dht1(DHT1PIN, DHT1TYPE);
DHT dht2(DHT2PIN, DHT2TYPE);
DHT dht3(DHT3PIN, DHT3TYPE);
DHT dht4(DHT4PIN, DHT4TYPE);
#define PIN D1 //контролируемый пин
WidgetLED fan1(V8); // Светодиод на смарте
#define PIN D5 //контролируемый пин
WidgetLED fan2(V9); // Светодиод на смарте
#define PIN D6 //контролируемый пин
WidgetLED fan3(V10); // Светодиод на смарте
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int stat = 0;
int maxHum = 60;
#include <SimpleTimer.h> //таймер
SimpleTimer timer;
char auth[] = "12345678901234567890";
void sendOnOff()
{
int x = digitalRead (fan1);//читаем пин модуля
if (x == 1) {//проверим состояние
led fan1.on(); //вкл вирт.светодиод
}
else { //иначе выключим
led fan1.off();
}
int x = digitalRead (fan2);
if (x == 1) {//проверим состояние
led fan2.on(); //вкл вирт.светодиод
}
else { //иначе выключим
led fan2.off();
}
int x = digitalRead (fan3);
if (x == 1) {//проверим состояние
led fan3.on(); //вкл вирт.светодиод
}
else { //иначе выключим
led fan3.off();
}
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, "ASUS", "ZipandSergey");
dht1.begin();
dht2.begin();
dht3.begin();
dht4.begin();
pinMode(fan1, OUTPUT);
pinMode(fan2, OUTPUT);
pinMode(fan3, OUTPUT);
timer.setInterval(1000, sendOnOff);//устанавливаем перезапуск sendOnOff с интервалом 1с.
}
BLYNK_WRITE(V1) // запрос данных с датчика
{
stat = param.asInt();
}
void loop()
{
Blynk.run();
timer.run();
Send();
}
void Send(){
float h2 = dht2.readHumidity();
// Read temperature as Celsius (the default)
float t2 = dht2.readTemperature();
if (stat == 1)
{
Blynk.virtualWrite(V2, h);
Blynk.virtualWrite(V3, t);
}
float h3= dht3.readHumidity();
// Read temperature as Celsius (the default)
float t3= dht3.readTemperature();
if (stat == 1)
{
Blynk.virtualWrite(V4, h);
Blynk.virtualWrite(V5, t);
}
float h4 = dht4.readHumidity();
// Read temperature as Celsius (the default)
float t4 = dht4.readTemperature();
if (stat == 1)
{
Blynk.virtualWrite(V6, h);
Blynk.virtualWrite(V7, t);
}
if(h2 > maxHum)
{
digitalWrite(fan2, HIGH);
}
else if (h2 < (maxHum - 5) ) // Числа нижнего порога можете поменять по желанию. { digitalWrite(fan, LOW);
{
digitalWrite(fan2, LOW);
}
if(h3> maxHum)
{
digitalWrite(fan3, HIGH);
}
else if (h3< (maxHum - 5) ) // Числа нижнего порога можете поменять по желанию. { digitalWrite(fan, LOW);
{
digitalWrite(fan3, LOW);
}
if(h4 > maxHum)
{
digitalWrite(fan4, HIGH);
}
else if (h4 < (maxHum - 5) ) // Числа нижнего порога можете поменять по желанию. { digitalWrite(fan, LOW);
{
digitalWrite(fan4, LOW);
}
// проверяем, были ли ошибки при считывании и, если были, начинаем заново
if (isnan(h1) || isnan(t1)) {
Serial.println("Failed to read from DHT1 sensor!");
} else {
Serial.print("Humidity1: ");
Serial.print(h1);
Serial.print(" %\t");
Serial.print("Temperature1: ");
Serial.print(t1);
Serial.println(" *C ");
}
if (isnan(h2) || isnan(t2)) {
Serial.println("Failed to read from DHT2 sensor!");
} else {
Serial.print("Humidity2: ");
Serial.print(h2);
Serial.print(" %\t");
Serial.print("Temperature2: ");
Serial.print(t2);
Serial.println(" *C ");
}
if (isnan(h3) || isnan(t3)) {
Serial.println("Failed to read from DHT3 sensor!");
} else {
Serial.print("Humidity3: ");
Serial.print(h3);
Serial.print(" %\t");
Serial.print("Temperature3: ");
Serial.print(t3);
Serial.println(" *C ");
}
if (isnan(h4) || isnan(t4)) {
Serial.println("Failed to read from DHT4 sensor!");
} else {
Serial.print("Humidity4: ");
Serial.print(h4);
Serial.print(" %\t");
Serial.print("Temperature4: ");
Serial.print(t4);
Serial.println(" *C ");
}
Serial.println();
}