Humidity control in the garage and cellar. WEMOS MINI PRO

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();
}
1 Like

Hello and welcome. However… you didn’t properly format your posted code as required in both the Welcome Topic and when you open a new topic :frowning:

Please repost your code, properly formatted. Thank you.

how do I format the code correctly?

How is already shown… twice :wink: … above in the link to the Welcome Topic and the directions from the original post.

And now here as well…

Blynk%20-%20FTFC

Put three backticks at the beginning and end of your code.
Three backticks look like this’d:
```
If you can’t find the backtick symbol on your keyboard then just copy the three backticks above and paste them at the beginning and end of your code.

Pete.

Yes thank you I already guessed and made this. On photo awkward to transfer

1 Like

Try reading this:

Pete.

Pete thanks, I fixed it. I already had a timer, but the error did not disappear…

Are you saying that the problem is 100% solved, or that you e made some changes and you still have a problem?

If you still have a problem then you should post your updated code, and details of the problem.

Pete.

I changed the code(and here too,see above), but the error remained the same. expected ‘,’ or ‘;’ before ‘)’ token

Which part of the code does the compiler point to with this error?
Copy and paste your error message.

Pete.

line 35
 Description very large, error at the end
exit status 1
expected ',' or ';' before ')' token

Please paste adjusted/new code in new post as we don’t get automatic notice of changes in prior posts.

When you have a 'very large error message". the thing to do is to scroll backwards to find the first error (in orange text) and investigate that part of the code.
As you didn’t bother to post the actual message, I’ve compiled your code myself and realised that the error is caused by the tray closing brackets in these 4 lines of code:

#define DHT1TYPE DHT22)
#define DHT2TYPE DHT22)
#define DHT3TYPE DHT11)
#define DHT4TYPE DHT11)

Once these are corrected then you get more error messages like this:

sketch_apr26a:36:1: error: 'WidgetLED' does not name a type

 WidgetLED fan1(V8); // Светодиод на смарте

 ^

That seems to be because you’ve previously defined fan1 as D1, but I may be wrong:

#define fan1 D1 //вентилятор D1 Гараж

I have no idea what you’re trying to achieve here, so I’ll let you sort that one out.

Edited to add…
Or, the error may be because you’re not including the Blynk libraries until after you’re trying to reference Blynk objects. Putting your libraries at the beginning of the code is always good practice.

Pete.

Don’t waste your time Pete! He obviously ignored your previous post about keeping the main loop() clean. :stuck_out_tongue:

If the sketch above is up to date, the 3 x DHT-sensors is called from within the loop() and we all know what the next question will be :rofl:

1 Like

Sorry, couldn’t wait for Your answer, we had already late the second hour of the nig

I didn’t know that and edited here

Yes indeed it is. Now deleted.

Made as You wrote
Compiled again, got another error: ‘DHT’ does not name a type
Link to error in line 33: DHT dht4(DHT4PIN, DHT4TYPE);
There’s a new 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 <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#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); // Светодиод на смарте



int stat = 0;
int maxHum = 60;

#include <SimpleTimer.h> //таймер
SimpleTimer timer;

char auth[] = "abcc955ef726453a89b97232338d0a57";

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();
}

You seem to be missing this needed library in your new code.

By the way, BlynkTimer (Blynk’s improved version of SimpleTimer) is now included in the Blynk library, so all you need is…

BlynkTimer timer;

And as already referenced a few times… use a clean void loop() … get Send(); OUT of the void loop()!! Use a timer to call it instead of it trying to run thousands of times a second.

removed Send()

Thanks, I will search I thought it was SimpleTimer.h same library

Strangely, it worked for one dht22 or DHT11 sensor.
Thank You for your patience and understanding. If I have any questions (and they probably will be, I’m quite new) can I contact You?

1 Like

Removed SimpleTimer.h, Set BlynkTimer timer; :
#include <ESP8266WiFi.h>
BlynkTimer timer;
writes an error: ‘BlynkTimer’ does not name a type

1 Like