Mold prevention with the AZ-Envy - Part 2

The following blog post was sent to us from the guest car Niklas Heinzel. Have fun reading and postponing:

The second part of this blog series is about using the AZ-Envy environmental development board for early mold prevention in homes. Having looked in part 1 at the structural factors under which mold growth is more likely to occur, we now turn to the technical consideration of the problem, or rather its implementation with the AZ-Envy development board.

We have taken the following basic principles from Part 1, which must now be taken into account in the technical implementation:

"In the technical discussion must be tried to measure the Room air temperature, the Relative humidity (<65%) and the Dew point temperature ( to make. These values ​​must be evaluated as automated, as well as stored. "

In addition to the correct interconnection of all hardware components, a suitable algorithm is necessary for the project, which checks the three values ​​mentioned above the sensors. To write the appropriate algorithm, I used the Open Source Software Arduino IDE, with the adaptation for the ESP12-F microcontroller used from the ESP8266 family.

Advantage of this development environment is the simple integration of libraries that serve the simplification of commands and practicality. These libraries are available for a wide variety of sensors and other components. But they also offer a variety of programming examples to learn the programming language C ++ or C. I have therefore deliberately renounced other development environments that I use otherwise to avoid unnecessary difficulties in upload, or due to the syntax condition.

As usual in almost every programming language, the libraries are first integrated. In my case, there are libraries for easier reading of sensor values ​​of the SHT30 and libraries that allow to build up their own website with the ESP12-F microcontroller.

After initializing all sensors, it is trying to connect via WLAN with the credentials stored in the internal memory with the local network. If no credentials are available, eg. B. When starting the system by the user, a website is built up in which information about the device and a login page are available. There you are wearing his wireless name (SSID) and his wireless password. These data are stored in the internal memory, the EEPROM, and remain obtained even after switching off the power supply of the device. A EEPROM is a so-called Electrically Erasable PRogrammable READ-Only MEmory, ie an electrically erasable, programmable, exclusively reserved for the reading process, which can be programmed or deleted by voltage differences. The capacity of permanent storage and the ability to modify the memory are ideal to safely preserve the credentials.

After entering the data by the user, these are now permanently stored and another login process is not necessary after a short reboot. The microcontroller then connects to Google's Firebase Database via the home network, a free solution for storing small records. For this, only one account must be created and data can be sent to it via the associated API. An API is a programming interface that receives data from users or devices and forward them for the specific application, according to a predetermined syntax. The unique, used for authentication, API key is also stored in the EEPROM and is connected to the account. After establishing the connection to the FireBase database, the SHT30 and MQ-2 sensors are read out. Subsequently, these data are rounded to two decimal places and uploaded to the database. Such a central storage in a database makes it possible to retrieve the data at any time outside the home network, on vacation or via the mobile network.

To retrieve and evaluate the data user-friendly, as well as easy to implement for the user, I have programmed an Android app for this purpose with the development environment Android Studio.

Since the app has no user inferface with which it would be possible to change the API key, etc., this should only give a thought start for the development of its own app.

Android app

This allows the automatic and a few seconds delayed download of the current data of the mold warning system, as well as the complete evaluation of those. User-friendly and clear is humidity (left), room air quality (right), but also the general mold hazard (above). The wreath surrounding the values, depending on the risk potential, turns from green to red and shows again, z. B. in the relative humidity, the value of 0 to 100%.

In order to be able to react quickly and effectively without expertise, a constantly updating and animated button is integrated among the values. This shows, depending on the hazard position, a green hook or a red cross, to clarify the user rapidly the danger.

Click on the button to be proposed to the endangerment parameters, measures such as ventilation, heating or other construction technical measures. Using a navigation bar at the bottom of the field, it is also possible for the user of the application to switch between the presented home page, a contact page, and a page for further information material.

The application is thus an all-in-one solution for IoT-based mold prevention, which represents and evaluates the measured values ​​of the board intelligent and user-friendly.

Here I have illustrated the whole again as a flow chart:

flow chart

Thus, it is also possible for the user without special expertise, by complying with the measures proposed by the app, effectively avoid the majority of the factors that lead to mold formation.

Since several times the temperature interference between the heated gas sensor and the temperature sensor was pointed out:

Unfortunately, in the current version of the AZ-ENVY, this is a known problem which can be curved by creating offset values ​​to correct the temperature artificially downward or through structural changes. This includes a suitable 3D print housing with a wall between the two sensors or alternatively the gas sensor can be released and placed further away by cable.

Since now all the details would be clarified, find here the code for the Arduino IDE, which works with a few adjustments (SSID, password, API-Key) also with you!

Here again the wiring for upload:

FTDI-Adapter AZ-Envy
TX TX
RX RX
GND GND


It follows the sketch for the Arduino IDE:

 // azenvy
 // © Niklas Heinzel
 //2021
 //Ver.3.1
 
 // - Libaries - //
 #include // i2c library
 #include // SHT30 Libary
 #include // ESP8266 Wi-Fi Libary
 #include // DNS server Lary
 #include // server Libary
 #include // WiFi Manager Libary
 #include // Mathe-Libary
 #include "Firebaseesp8266.h"
 
 SHT3x SHT30(0x44);
 
 #define Firebase_host "Insert the link here" // Link to the Firebase real-time database
 #Define Firebase_Auth "Insert Secret Code here" // Secret code for reading and writing to the cloud
 Firebasedata Firebasedata;
 
 contam int analoginpin = A0;  // ADC pin of the ESP-12F
 int sensorvalue = 0;  // integer value for ADC PIN (reading out the gas sensor)
 String SSID = "Azenvy"; // SSID of the Configuration Portal
 contam Char * password = "Azenvy"; // password of the ESP12'S network
 
 String Router_ssid; // string router SSID
 String Router_pass; // string router password
 
 
 // Function to display the connection status
 void heartbeatprint(void)
 {
   static int numb = 1;
 
   IF (Wifi.status() == Wl_connected){
     Serial.print("Connected to WLAN.");  // means connected to WLAN
  }Else{
     Serial.print("Not connected to WLAN!");} // does not mean connected to WLAN
   
   IF (numb == 80)
  {
     Serial.Println();
     numb = 1;
  }
   Else IF (numb++ % 10 == 0)
  {
     Serial.print(" ");
  }
 }
 // Function to check the status in the interval
 void CHECK_STATUS()
 {
   static ulong CheckStatus_Timeout = 0;
   #define heartbeat_interval 30000L
   // Interval of 10 seconds
   IF ((millis() > CheckStatus_Timeout) || (CheckStatus_Timeout == 0))
  {
     heartbeatprint();
     CheckStatus_Timeout = millis() + Heartbeat_Interval;
  }
 }
 
 void set up() {
 
  Serial.Begin(115200); // Start serial connection with a baud rate of 115200
  Serial.Println("------------------------------"); // Issue to serial monitor
  Serial.Println("------------ Azenvy ------------"); // Issue to serial monitor
  Serial.Println("----- by Niklas Heinzel -------"); // Issue to serial monitor
  Serial.Println("------------------------------"); // Issue to serial monitor
 
  // - WiFi Manager - //
  unsigned long starting date = millis();
 
   ESP_Wifimanager ESP_Wifimanager; // Intitryization of the WiFi Manager
 
   Router_ssid = ESP_Wifimanager.Wifi_sid(); // variable for saving in the EEPROM
   Router_pass = ESP_Wifimanager.Wifi_pass(); // variable for saving in the EEPROM
   
   Serial.Println("Open configuration portal of the WLAN's!"); // Issue to serial monitor
   Serial.Println("------------------------------");
   
   IF (Router_ssid != "")
  {
     ESP_Wifimanager.setconfigportalTimeout(10); // Timeout of the Configuration Portal
     Serial.Println("Timeout: 10 seconds"); // Issue to serial monitor
  }
   Else{
     Serial.Println("No timeout!");} // Issue to serial monitor
     Serial.Println("---------------------------");
 
   IF(!ESP_Wifimanager.StartConfigportal((contam Char *) SSID.C_STR(), password)){ // Start the configuration portal and wait for user input
     Serial.Println("Can not connect to network."); // Issue to serial monitor
     Serial.Println("---------------------------");}
   Else{
     Serial.Println("Connected to WLan!"); // Issue to serial monitor
     Serial.Println("---------------------------");}
 
   // constant //
   #define wifi_connect_timeout 10000l
   #define wehene_loop_delay 200L
   #define wehene_loop_steps (WiFi_Connect_Timeout / (3 * While_Loop_Delay))
   
   starting date = millis();
   
   While ( (Wifi.status() != Wl_connected) && (millis() - starting date < Wifi_connect_timeout ) )
  {  
     int I = 0;
     While((!Wifi.status() || Wifi.status() >= Wl_disconnected) && I++ < WHILE_LOOP_STEPS)
    {
       delay(While_Loop_Delay);
    }    
  }
 
   Serial.print((millis()- starting date) / 1000); // Issue to serial monitor
   Serial.print("Connection status is"); // Issue to serial monitor
 
   IF (Wifi.status() == Wl_connected) // if connected then spend something
  {
     Serial.print("Connected, Local IP Address:"); // Issue to serial monitor
     Serial.Println(Wifi.Localip()); // Output to serial monitor of the IP
  }
   Else{
     Serial.Println(ESP_Wifimanager.getting(Wifi.status()));} // Output to serial monitor of status
 
   // - Firebase - //
   Firebase.Begin(Firebase_host, Firebase_auth); // connect with the cloud under the declared login info
 
   pinmode(sensorvalue,Input); // Set ADC PIN to INPUT
   pinmode(2,OUTPUT); // Place integrated LED on output
 
 }
 
 
 void loop() {
 
  CHECK_STATUS(); // Function to the Statuscheck
 
  float Firebasemp = RoundF((SHT30.CTEMP) * 100) / 100;
  float Firebasehum = RoundF((SHT30.humidity) * 100) / 100;
 
  // - SHT30 - //
    IF(SHT30.get()==0){
     Serial.print("Inn temperature =");
     Serial.Println(SHT30.CTEMP);
     Serial.print("Humidity =");
     Serial.Println(SHT30.humidity);
     Serial.Println();
     digitalwrite(2,HIGH); // Switch off the integrated LED
  }
   Else
  {
     Serial.Println("Error reading the SHT30!");
  }
 
 
  // - MQ-2 - //
   Serial.Println("----------------------------------------------"); // Issue to serial monitor
   sensorvalue = analogead(analoginpin); // Reading the ADC PIN (Analog-Digital Converter) from MQ-2
   Serial.print("Gassensor value:"); // Issue in the serial monitor
   Serial.Println(sensorvalue); // Output of the analog value in the serial monitor
   Serial.Println("----------------------------------------------"); // Issue to serial monitor
 
  IF(Firebase.setfloat(Firebasedata, "Mold-Preventer / Temperature", Firebasemp)){
      Serial.Println("Upload the data successfully!");
  }Else{
     Serial.print("Error when uploading:");
     Serial.Println(Firebasedata.ErrorReason());
  }
   
   IF(Firebase.setfloat(Firebasedata, "Mold-Preventer / Humidity", Firebasehum)){
      Serial.Println("Upload the data successfully!");
  }Else{
     Serial.print("Error when uploading:");
     Serial.Println(Firebasedata.ErrorReason());
  }
   
  IF(Firebase.setfloat(Firebasedata, "Mold-Preventer / Gas", sensorvalue)){
      Serial.Println("Upload the data successfully!");
  }Else{
     Serial.print("Error when uploading:");
     Serial.Println(Firebasedata.ErrorReason());
  }
 
 
  delay(5000);
 
 }

You can use the sketch download here.

After the first upload of the sketch, use a mobile phone e.g. Connect to the Wi-Fi network of the AZ-ENVY and enter a login website. There, select your desired network with which the board should always connect after the setup and after a restart the data is sent!

To make a corresponding database it is only necessary https://firebase.google.com to create a real-time database. In the settings you will also find the SECRET code with which the board can access the database. A possible layout is the following here (accordingly, the Arduino code must be changed for other designation):

Login website

From this point you can use the data for many applications, e.g. Android apps reading, display a display, etc.

So I wish a lot of fun with the AZ-Envy development board and I'm very curious which new projects will be built on it!

Niklas Heinzel

Esp-8266Projects for beginnersSmart home

9 comments

veit burmester

veit burmester

@Andreas Wolter
Vielen Dank für die Antwort. Ich kann auf der NAS ein FTP Server laufen lassen. Somit ist dann “nur” das Übertragen der Daten als File zu lösen. Wenn hier jemand eine Lösung hat bitte mir eine E-Mail senden.
Oder lässt sich das auch mit einem Print Befehl lösen. ?
Vielen Dank

Andreas Wolter

Andreas Wolter

@Veit Burmester: es gibt mehrere Lösungen für das Speichern von Daten via HTML oder UPD auf einem NAS im Netz. Dafür sollte auf dem NAS ein Server laufen, der die Daten entgegennehmen kann.

veit burmester

veit burmester

Hallo
Tolles Projekt.
Da ich schon ein Envy in betrieb habe kann ich der Problematik mit der Temperatur nur zustimmen.
Das Beste war bei mir das Auslöten des Sensors und damit einen Abstand herzustellen.
Ich würde lieber die Daten auf meiner NAS (Eigene IP) speichern uns sie dann danach zu bearbeiten. Hier fehlt mir nur der Ansatz wie ich das Programmieren kann,

Andreas Wolter

Andreas Wolter

@Jürgen: aktuell gibt es eine 3D-Druckvorlage, die jedoch nicht speziell für die Lösung des Temperaturproblems gedacht ist. Eventuell ist es möglich, diese selbst anzupassen. Die Druckvorlage ist über die Produktseite im AZ-Shop zu finden: https://www.az-delivery.de/products/az-envy?pos=2&_sid=9a38157bc&ss=r unter “Wichtige Downloads & Links”.

@Patrick: die Angaben für RX/TX sind korrekt. Hier werden die Verbindungen nicht gekreuzt (wie man es sonst gewohnt ist). Darauf verweist auch Bernd Albrecht in seinem Beitrag zum AZ-Envy: https://www.az-delivery.de/blogs/azdelivery-blog-fur-arduino-und-raspberry-pi/az-envy-das-etwas-andere-micro-controller-board?pos=1&_sid=80eb9056b&ss=r

@Michael: Der Teil für die App soll eine Anregung darstellen. Daher gibt es aktuell keine Android oder iOS App.

@Moofer: für Sie ist da wahrscheinlich der frsi-Wert zur Bewertung der Schimmelwahrscheinlichkeit interessant. Ich habe dazu das hier gefunden: https://www.tbas.de/Der-fRSi-Wert-zur-Bewertung-einer-Schimmelwahrscheinlic.html

Moofer

Moofer

Hallo,
das ist ein sehr nützliches Projekt.
Ich habe bereits ein ähnliches Projekt in Angriff genommen, nur die Berechnung der Taupunkttemperatur hat mich vor Probleme gestellt. Ihre Lösung kann ich in mein Projekt einbinden.
Ein weiteres Feature meines Projektes sollte einen Vergleich von Innen- und Außentemperatur / Luftfeuchte durchführen, um das Öffnen der Fenster zu erlauben oder nicht. Vielleicht haben Sie da auch noch eine Anregung, welche Werte verglichen werden müssten.
Vielen Dank

Michael

Michael

Danke für den Blog.
Aber wie kommt man an die App bzw. die Logik darin? (Bin iPhone-Nutzer)

Patrick

Patrick

Hallo,
Ich vermute mal, die Verkabelung zwischen FTDI Adapter und dem AZ envy ist nicht richtig.
RX und TX sollten hier an einer Stelle getauscht werden
RX <→ TX
TX <→ RX

Hayes

Hayes

Great project, unfortunately not everyone can use the cloud, so I am going to try and modify it to build a stand alone unit with an alarm which doesn’t need WiFi access. I use mobile broadband with limits, so I do not have it on unless I want to go online.

Juergen

Juergen

Es wäre schön, wenn AZ Auch ein entsprechendes Gehäuse oder einen Weg für eine Temperaturkompensation aufzeigen könnte. Über die offenbar bekannten Probleme wird vor dem Einkauf nichts erwähnt. Ich habe den Eindruck bei AZ sitzen gestandene Software-Guru´s, da sollte es doch ein Leichtes sein dem Käufer eine Abhilfe aufzuzeigen. Wie hat Fredel Fesel einst gesungen “Ein Auto das nicht richtig fährt ist nicht viel wert”, leicht abgewandelt aber es geht ja um die Temperatur.

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN