Plant monitor for the window sill Part 4 - Temperature and humidity measurement

Hello and welcome to another part of the Plant Keeper series.


Today we will give the plant keeper a 2 in 1 environmental sensor and implement some optimizations of the (LED) hardware as well as the code. The sensor that we connect in this part is the well-known DHT 22 temperature and humidity sensor. This means that in the future, our plant guardian can now record not only the soil moisture, but also the environmental parameters of temperature and humidity that are important for plants in your area. Of course, we will also expand our mobile app accordingly. First of all, we make a change in the wiring of the LEDs.

We use the KY-016 LED RGB module and connect it directly as follows:
Red on pin 0, green on pin 15, and blue on pin.

The advantages of this module are that, on the one hand, we save space when installed in a housing (1/3 of the housing space), but also have the full RGB spectrum of colors via PWM control of the individual channels, so that more than originally 3 states are displayed can be.
(For example, the LED now lights up in white during the initialization phase). Last but not least, we save the series resistors because they are already integrated on the module. The pins to which the RGB LEDs are connected to the ESP32 were selected according to the criterion "suitable for timing non-critical hardware". The background is that the pins to which the LED is connected, firmware may oscillate during a system restart (PWM) before they are initialized, and are therefore not suitable for timing-critical hardware (such as the DHT22).


There has also been a change in the functionality and display of the LED display: Since we only have one and not six RGB LEDs to display the guard's status, we have to summarize the most important information on it.


For this we fall back on the following consideration: For us it is the most important information whether one of the maximum 6 plants should be watered or not. This should be recognizable at a glance. We redefine the color green (sufficient moisture) so that ALL 6 plants have enough moisture so that we get a "green" display. If one of the six sensors detects less than 50% soil moisture, our display jumps to "yellow". At less than 10% on "red". So we know that we should start our Plant Guardian APP to find out which of the six plants should be watered. Since the temperature and humidity sensor DHT 22 is 3.3 V pin and logic compatible, we connect it directly to port 4 of the ESP. Here you can see the complete wiring:

 Part 4 - construction

 

The current parts list with the required hardware parts. (With reference link)

 

number

description

annotation

1

DHT 22

 

 

DHT 11

Alternative to DHT 22

1

KY-016 LED RGB module

 

1

ESP-32 Dev Kit C

 

6

Soil moisture sensor module V1.2

 

1

MB102 power supply adapter

For breadboard construction

12

Resistances as described

 

 

Instead of the DHT 22 sensor listed first, the cheaper DHT 11 sensor can also be used by simply adjusting the line "DHTTYPE DHT22". However, the DHT 11 is not as accurate as the DHT 22.

Here  the differences between the two sensors can also be found again.

If the DHT 11 Senor is to be used, the line must

#define DHTTYPE DHT22

in

#define DHTTYPE DHT11

be changed. No further changes are necessary.

 

The ESP32 pinout is as follows

ESP32 PIN

use

annotation

4

DHT sensor input

 

0

RGB LED PIN

red

15

RGB LED PIN

green

14

RGB LED PIN

blue

 

These were already the necessary hardware changes. To use the DHT22 / DHT 11 Sensor with its proprietary one Wire Protocol in our Sketch, we need to add two more libraries to our IDE next.

This is on the one hand the gerneralized „Adafruit Unified Sensor Libary“ : as well as the actual DHT Sensor Library. Both libraries build on each other and need to be added to our libraries of the IDE as they are needed by our project.

After adding the libraries and adjusting the parameters in the Code, as in the Part 3 in this series, we upload the following code to our ESP:

 

#include <driver/adc.houses>
#include <WiFi.houses>
#include <WiFiClient.houses>
#include <BlynkSimpleEsp32.houses>
#include "EEPROM.houses"
#include <Preferences.houses>
#include "DHT.houses"    // REQUIRES the following Arduino libraries:
// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library
// - Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor

// Port definition RGP LED module
#define LED_Rot     0     // Red LED 
#define Led_blue    14    // Blue LED
#define LED_Gruen   15    // Green LED

// Led PWM settings
#define PWMfreq 5000  // 5kHz base frequency for LED display
#define PWMledChannelA  0
#define PWMledChannelB  1
#define PWMledChannelC  2
#define PWMresolution  8 // 8 Bit Resolution for LED PWM

//Other Definitions
#define ADCAttenuation ADC_ATTEN_DB_11    // ADC_ATTEN_DB_11 = 0-3. 6 V attenuation ADC (ADC extension
#define MoisureSens_Poll_Interval 300000   // Interval between two soil moisture measurements in milliseconds - & gt; send data packet to mobile phone every 5 minutes
#define DHT_Poll_Interval 400000           // Interval between two temperature and humidity measurements in milliseconds - & gt; send data packet to mobile phone every 6 minutes
#define MaxSensors 6                      // Maximum number of connectable humidity sensors
#define StartInit true
#define runtime false
#define Sens_Calib true
#define Sens_NOTCalib false
#define EEPROM 512                  // Size of the internal EEPROM

// Blynk app definitions
#define BLYNK_GREEN     "#23C48E"
#define BLYNK_BLUE      "#04C0F8"
#define BLYNK_YELLOW    "#ED9D00"
#define BLYNK_RED       "#D3435C"
#define BLYNK_BLACK     "#000000"
#define BLYNK_PRINT Serial
#define BLYNK_NO_BUILTIN
#define BLYNK_NO_FLOAT
//#define BLYNK_DEBUG

// DHT configuration
#define DHTPIN 4     // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22   // DHT 22 (AM2302), AM2321
// # define DHTTYPE DHT21 / / DHT 21 (AM2301)

struct Moisture sensor calibration data
{   int Data[MaxSensors * 2] = {1651, 2840, 1652, 2840, 1653, 2840, 1654, 2840, 1655, 2840, 1656, 2840}; // Calibration Data for humidity sensor. Please note Project Text and adjust values accordingly   // int Data[MaxSensors*2] = {0,0,0,0,0,0,0,0,0,0,0,0,}; // Calibration Data for humidity sensor. Please note Project Text and adjust values accordingly   byte Status Board rpercent values[MaxSensors * 2][2] = { {10, 50},     // Two-dimensinonal array For percent limits (traffic lights) individually per humidity sensor (1 -6)     {10, 50},     {10, 50},     {10, 50},     {10, 50},     {10, 50}   };   String Sensor name[MaxSensors + 2] = {"Plant 1", "Plant 2", "Plant 3", "Plant 4", "Plant 5", "Plant 6", "Air humidity", "Temperature"}; // Sensor name, which is also displayed as a heading in the APP

};

struct Moisture sensor data
{   int Percent[MaxSensors] = {0, 0, 0, 0, 0, 0};  // Moisture sensor data in percent   byte Old_Percent[MaxSensors] = {0, 0, 0, 0, 0, 0}; // Previous _ moisture sensor data in percent (purpose: save data amount.)   bool DataValid [MaxSensors] = {false, false, false, false, false, false};
};

struct DHTSensorData
{   float Humidity = 0 ;      // Humidity sensor data in percent   float Temperature = 0;   float Old_Humidity = 0 ;      // Humidity sensor data in percent   float Old_Temperature = 0;   bool DataValid  = false;   bool SensorEnabled  = false;
};

DHT dht(DHTPIN, DHTTYPE); // Initialize DHP Instalz


// Global Variables


char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // Enter the Blynk app according to the instructions for the Auth Token (email).
// Your WiFi access data.
char ssid[] = "Your_WLAN_SSID";                 // Please adapt to your own WLAN SSID
char passport[] = "Your _WLAN _Passwort!";           // Please adapt to your own WiFi password
MoistureSensorCalibrationData MCalib;
MoistureSensorData MMeasure;
DHTSensorData  DHTMeasure;

byte AttachedMoistureSensors; // Detected Active Moisture Sensors (Count)
unsigned long Moisure_ServiceCall_Handler = 0;  // Delay Variable for Delay between Moisure Readings
unsigned long DHT_ServiceCall_Handler = 0;  // Delay Variable for Delay between DHT Readings


void set up() {   pinMode(LED_Red, OUTPUT);   pinMode(LED_blue, OUTPUT);   pinMode(LED_Green, OUTPUT);   Serial.begin(115200);   // initialize serial communication at 115200 bits per second:   ledcSetup(PWMledChannelA, PWMfreq, PWM resolution);   ledcSetup(PWMledChannelB, PWMfreq, PWM resolution);   ledcSetup(PWMledChannelC, PWMfreq, PWM resolution);   ledcAttachPin(LED_Red, PWMledChannelA);   // attach the channel to the GPIO to be controlled   ledcAttachPin(LED_blue, PWMledChannelB);   ledcAttachPin(LED_Green, PWMledChannelC);   SetLedConfig(255, 255, 255);   Serial.println(F("System configuration:"));   if (!EEPROM.begin(EEPROM_SIZE))   {     Serial.println(F("failed to initialize EEPROM"));   } else   { Serial.println(EEPROM_SIZE);     Serial.println(F("Bytes EEPROM"));   }   AttachedMoistureSensors = DetectMoistureSensors();   Serial.print(AttachedMoistureSensors);   Serial.println(F("Soil moisture sensor (s)"));   dht.begin();   DHTMeasure.SensorEnabled  = Run_DHTSensor (StartInit);   if (DHTMeasure.SensorEnabled)   {     Serial.println(F("1 DHT 22 sensor"));   }   Serial.print(F("Connection to WLAN"));   delay(500);   Blynk.begin(auth, ssid, passport);  // Initalize WiFi connection over Blync Library   Serial.println(F(" successful."));   SetLedConfig(0, 0, 0);   Init_Blynk_APP();   Run_MoistureSensors(StartInit);   for (int i = AttachedMoistureSensors; i < 6; i++) {     Update_Blynk_APP(i, Sens_Calib);   };
}

byte DetectMoistureSensors ()
{
#define MinSensorValue 100   byte Detected = 0;   for (int i = 0; i < MaxSensors; i++)   {     int MSensorRawValue = ReadMoistureSensor_Raw_Val(i);     if ( MSensorRawValue > MinSensorValue) {       Detected++;     } else {       break;     }   }   if (Detected < 1)   {     Serial.println(F("No soil moisture sensors detected. System stopped."));     esp_deep_sleep_start();     while (1) {}   }   return Detected;
}

bool SetLedConfig(byte Red, byte Green, byte Blue)
{   ledcWrite(PWMledChannelA, Red); // Red LED   ledcWrite(PWMledChannelB, Blue); // Blue LED   ledcWrite(PWMledChannelC, Green); // Green LED   return true;
}

int ReadMoistureSensor_Raw_Val(byte sensor)
{   int ReturnValue, i;   long sum = 0;
#define NUM_READS 6   adc1_config_width(ADC_WIDTH_BIT_12);   // Range 0-4095   switch (sensor)   {     case 0:       {         adc1_config_channel_atten(ADC1_CHANNEL_0, ADCAttenuation);         for (i = 0; i < NUM_READS; i++) { // Averaging algorithm           sum += adc1_get_raw( ADC1_CHANNEL_0 ); // Read analog         }         ReturnValue = sum / NUM_READS;         break;       }     case 1:       {         adc1_config_channel_atten(ADC1_CHANNEL_3, ADCAttenuation);         for (i = 0; i < NUM_READS; i++) { // Averaging algorithm           sum += adc1_get_raw( ADC1_CHANNEL_3 ); // Read analog         }         ReturnValue = sum / NUM_READS;         break;       }     case 2:       {         adc1_config_channel_atten(ADC1_CHANNEL_6, ADCAttenuation);         for (i = 0; i < NUM_READS; i++) { // Averaging algorithm           sum += adc1_get_raw( ADC1_CHANNEL_6 ); // Read analog         }         ReturnValue = sum / NUM_READS;         break;       }     case 3:       {         adc1_config_channel_atten(ADC1_CHANNEL_7, ADCAttenuation);         for (i = 0; i < NUM_READS; i++) { // Averaging algorithm           sum += adc1_get_raw( ADC1_CHANNEL_7 ); //Read analog         }         ReturnValue = sum / NUM_READS;         break;       }     case 4:       {         adc1_config_channel_atten(ADC1_CHANNEL_4, ADCAttenuation);         for (i = 0; i < NUM_READS; i++) { // Averaging algorithm           sum += adc1_get_raw( ADC1_CHANNEL_4 ); //Read analog         }         ReturnValue = sum / NUM_READS;         break;       }     default:       {         adc1_config_channel_atten(ADC1_CHANNEL_5, ADCAttenuation);         for (i = 0; i < NUM_READS; i++) { // Averaging algorithm           sum += adc1_get_raw( ADC1_CHANNEL_5 ); //Read analog         }         ReturnValue = sum / NUM_READS;         break;       }   }   return ReturnValue;
}

void Init_Blynk_APP()
{   Blynk.setProperty(V1, "label", MCalib.SensorName[0]);   Blynk.setProperty(V2, "label", MCalib.SensorName[1]);   Blynk.setProperty(V3, "label", MCalib.SensorName[2]);   Blynk.setProperty(V4, "label", MCalib.SensorName[3]);   Blynk.setProperty(V5, "label", MCalib.SensorName[4]);   Blynk.setProperty(V6, "label", MCalib.SensorName[5]);   Blynk.setProperty(V7, "label", MCalib.SensorName[6]);   Blynk.setProperty(V8, "label", MCalib.SensorName[7]);
}

void Update_Local_Display()
{   byte red1 = 0;   byte yellow1 = 0;   byte green1 = 0;   for (byte i = 0; i < AttachedMoistureSensors; i++)   {     if (MMeasure.DataValid[i])     {       if ( MMeasure.Percent[i] > MCalib.StatusBorderPercentValues[i][1])       {         green1++;       } else if ( MMeasure.Percent[i] > MCalib.StatusBorderPercentValues[i][0])       {         yellow1++;       } else       {         red1++;       }     }   }   if (red1 > 0)   {     SetLedConfig(255, 0, 0);   }   else if (yellow1 > 0)   {     SetLedConfig(255, 255, 0);   }   else if (green1 > 0)   {     SetLedConfig(0, 255, 0);   }   else   {     SetLedConfig(0, 0, 255);   }
}

void Update_Blynk_APP(byte Sensor, bool Calibrated)
{   switch (Sensor)   {     case 0:       {         if ((MMeasure.DataValid[0]) & (Calibrated))         {           if ( MMeasure.Percent[0] > MCalib.StatusBorderPercentValues[0][1])           {             Blynk.setProperty(V1, "color", BLYNK_GREEN);           } else if ( MMeasure.Percent[0] > MCalib.StatusBorderPercentValues[0][0])           {             Blynk.setProperty(V1, "color", BLYNK_YELLOW);           } else           {             Blynk.setProperty(V1, "color", BLYNK_RED);           }           delay(100);           Blynk.virtualWrite(V1, MMeasure.Percent[0]);         } else         {           if (Calibrated)           {             Blynk.setProperty(V1, "label", "Deaktiviert");             delay(100);             Blynk.virtualWrite(V1, 0);             delay(100);             Blynk.setProperty(V1, "color", BLYNK_BLACK);           }           else           {             Blynk.virtualWrite(V1, 0);             delay(100);             Blynk.setProperty(V1, "color", BLYNK_BLUE);           }         }         break;       }     case 1:       {         if ((MMeasure.DataValid[1]) & (Calibrated))         {           if ( MMeasure.Percent[1] > MCalib.StatusBorderPercentValues[1][1])           {             Blynk.setProperty(V2, "color", BLYNK_GREEN);           } else if ( MMeasure.Percent[1] > MCalib.StatusBorderPercentValues[1][0])           {             Blynk.setProperty(V2, "color", BLYNK_YELLOW);           } else           {             Blynk.setProperty(V2, "color", BLYNK_RED);           }           delay(100);           Blynk.virtualWrite(V2, MMeasure.Percent[1]);         } else         {           if (Calibrated)           {             Blynk.setProperty(V2, "label", "Deaktiviert");             delay(100);             Blynk.virtualWrite(V2, 0);             delay(100);             Blynk.setProperty(V2, "color", BLYNK_BLACK);           }           else           {             Blynk.virtualWrite(V2, 0);             delay(100);             Blynk.setProperty(V3, "color", BLYNK_BLUE);           }         }         break;       }     case 2:       {         if ((MMeasure.DataValid[2]) & (Calibrated))         {           if ( MMeasure.Percent[2] > MCalib.StatusBorderPercentValues[2][1])           {             Blynk.setProperty(V3, "color", BLYNK_GREEN);           } else if ( MMeasure.Percent[2] > MCalib.StatusBorderPercentValues[2][0])           {             Blynk.setProperty(V3, "color", BLYNK_YELLOW);           } else           {             Blynk.setProperty(V3, "color", BLYNK_RED);           }           delay(100);           Blynk.virtualWrite(V3, MMeasure.Percent[2]);         } else         {           if (Calibrated)           {             Blynk.setProperty(V3, "label", "Deaktiviert");             delay(100);             Blynk.virtualWrite(V3, 0);             delay(100);             Blynk.setProperty(V3, "color", BLYNK_BLACK);           }           else           {             Blynk.virtualWrite(V3, 0);             delay(100);             Blynk.setProperty(V3, "color", BLYNK_BLUE);           }         }         break;       }     case 3:       {         if ((MMeasure.DataValid[3]) & (Calibrated))         {           if ( MMeasure.Percent[3] > MCalib.StatusBorderPercentValues[3][1])           {             Blynk.setProperty(V4, "color", BLYNK_GREEN);           } else if ( MMeasure.Percent[3] > MCalib.StatusBorderPercentValues[3][0])           {             Blynk.setProperty(V4, "color", BLYNK_YELLOW);           } else           {             Blynk.setProperty(V4, "color", BLYNK_RED);           }           delay(100);           Blynk.virtualWrite(V4, MMeasure.Percent[3]);         } else         {           if (Calibrated)           {             Blynk.setProperty(V4, "label", "Deaktiviert");             delay(100);             Blynk.virtualWrite(V4, 0);             delay(100);             Blynk.setProperty(V4, "color", BLYNK_BLACK);           }           else           {             Blynk.virtualWrite(V4, 0);             delay(100);             Blynk.setProperty(V4, "color", BLYNK_BLUE);           }         }         break;       }     case 4:       {         if ((MMeasure.DataValid[4]) & (Calibrated))         {           if ( MMeasure.Percent[4] > MCalib.StatusBorderPercentValues[4][1])           {             Blynk.setProperty(V5, "color", BLYNK_GREEN);           } else if ( MMeasure.Percent[4] > MCalib.StatusBorderPercentValues[4][0])           {             Blynk.setProperty(V5, "color", BLYNK_YELLOW);           } else           {             Blynk.setProperty(V5, "color", BLYNK_RED);           }           delay(100);           Blynk.virtualWrite(V5, MMeasure.Percent[4]);         } else         {           if (Calibrated)           {             Blynk.setProperty(V5, "label", "Deaktiviert");             delay(100);             Blynk.virtualWrite(V5, 0);             delay(100);             Blynk.setProperty(V5, "color", BLYNK_BLACK);           }           else           {             Blynk.virtualWrite(V5, 0);             delay(100);             Blynk.setProperty(V5, "color", BLYNK_BLUE);           }         }         break;       }     case 5:       {         if ((MMeasure.DataValid[5]) & (Calibrated))         {           if ( MMeasure.Percent[5] > MCalib.StatusBorderPercentValues[5][1])           {             Blynk.setProperty(V6, "color", BLYNK_GREEN);           } else if ( MMeasure.Percent[5] > MCalib.StatusBorderPercentValues[5][0])           {             Blynk.setProperty(V6, "color", BLYNK_YELLOW);           } else           {             Blynk.setProperty(V6, "color", BLYNK_RED);           }           delay(100);           Blynk.virtualWrite(V6, MMeasure.Percent[5]);         } else         {           if (Calibrated)           {             Blynk.setProperty(V6, "label", "Deaktiviert");             delay(100);             Blynk.virtualWrite(V6, 0);             delay(100);             Blynk.setProperty(V6, "color", BLYNK_BLACK);           }           else           {             Blynk.virtualWrite(V6, 0);             delay(100);             Blynk.setProperty(V6, "color", BLYNK_BLUE);           }         }         break;       }     case 6:       {         if (DHTMeasure.DataValid)         {           Blynk.virtualWrite(V7, DHTMeasure.Humidity);         } else         {           Blynk.setProperty(V7, "label", "Deaktiviert");           delay(100);           Blynk.virtualWrite(V7, 0);           delay(100);           Blynk.setProperty(V7, "color", BLYNK_BLACK);         }         break;       }     case 7:       {         if (DHTMeasure.DataValid)         {           Blynk.virtualWrite(V8, DHTMeasure.Temperature);         } else         {           Blynk.setProperty(V8, "label", "Deaktiviert");           delay(100);           Blynk.virtualWrite(V8, 0);           delay(100);           Blynk.setProperty(V8, "color", BLYNK_BLACK);         }         break;       }   } // End Switch
}

void Get_Moisture_DatainPercent()
{   byte CalibDataOffset = 0;   for (byte i = 0; i < AttachedMoistureSensors; i++)   {     CalibDataOffset =  i * 2;     int RawMoistureValue = ReadMoistureSensor_Raw_Val(i);     if ((MCalib.Data[CalibDataOffset] == 0) || (MCalib.Data[CalibDataOffset + 1] == 0)) // MinADC Value maxADC ADC Value     {       MMeasure.Percent[i] = RawMoistureValue;       MMeasure.DataValid[i] = false;     } else     {       RawMoistureValue = MCalib.Data[CalibDataOffset + 1] - RawMoistureValue;       RawMoistureValue = MCalib.Data[CalibDataOffset] + RawMoistureValue;       MMeasure.Percent[i] = map(RawMoistureValue, MCalib.Data[CalibDataOffset], MCalib.Data[CalibDataOffset + 1], 0, 100);       if ((MMeasure.Percent[i] > 100 ) | (MMeasure.Percent[i] < 0 ))       {         MMeasure.Percent[i] = RawMoistureValue;         MMeasure.DataValid[i] = false;       } else  {         MMeasure.DataValid[i] = true;       }     }   }   return ;
}



void Run_MoistureSensors (bool Init)   // HauptFunktion zum Betrieb der Bodenfeuchtesensoren
{   byte MinSensValue = 100;   if ((millis() - Moisure_ServiceCall_Handler >= MoisureSens_Poll_Interval) | (Init))   {     Moisure_ServiceCall_Handler = millis();     Get_Moisture_DatainPercent();     for (int i = 0; i < AttachedMoistureSensors; i++)     {       if (MMeasure.DataValid[i])       {         if (MMeasure.Percent[i] != MMeasure.Old_Percent[i])         {           MMeasure.Old_Percent[i] = MMeasure.Percent[i];           if (MMeasure.Percent[i] < MinSensValue ) {             MinSensValue = MMeasure.Percent[i];           };           Serial.print(F("Feuchtigkeitswert Sensor "));           Serial.print(i);           Serial.print(F(" in Prozent :"));           Serial.print(MMeasure.Percent[i]);           Serial.println(F(" %"));           Update_Blynk_APP(i, Sens_Calib);    // Aktualisiere Handywerte         }       } else       {         Update_Blynk_APP(i, Sens_NOTCalib);    // Aktualisiere Handywerte         Serial.print(F("Sensor "));         Serial.print(i);         Serial.print(F(" nicht kalibiert. Bitte kalibrieren. Rohdatenwert:"));         Serial.println(MMeasure.Percent[i]);       }     }     Update_Local_Display();           // Aktualisiere lokales Pflanzenwächter Display (Led)   }
}

bool Run_DHTSensor (bool Init)   //
{   if ((millis() - DHT_ServiceCall_Handler >= DHT_Poll_Interval) | (Init))   {     DHT_ServiceCall_Handler = millis();     DHTMeasure.Humidity = dht.readHumidity();     DHTMeasure.Temperature = dht.readTemperature(false);   // Read temperature as Celsius (isFahrenheit = true)     if (isnan(DHTMeasure.Humidity) || isnan(DHTMeasure.Temperature) )     {       Serial.println(F("Failed to read from DHT sensor!"));       DHTMeasure.DataValid  = false;       return false;     }     DHTMeasure.DataValid  = true;     if (DHTMeasure.Humidity != DHTMeasure.Old_Humidity)     {       DHTMeasure.Old_Humidity = DHTMeasure.Humidity;       Update_Blynk_APP(6, true); //  Luftfeuchteanzeige     }     if (DHTMeasure.Temperature !=  DHTMeasure.Old_Temperature)     {       DHTMeasure.Old_Temperature = DHTMeasure.Temperature;       Update_Blynk_APP(7, true); //  Temperaturanzeige     }   }   return true;
}


// Main Loop
void loop()
{   Run_MoistureSensors(RunTime);   if (DHTMeasure.SensorEnabled) {     Run_DHTSensor(RunTime);   }   Blynk.run();   // Execute Blync Basic- Functions
}

 

Weitere unbedingt anzupassende Parameter sind nicht hinzugekommen, da der DHT 22 und auch der DHT 11 Sensor eine interne Werte Kalibrierung hat, die keiner weiteren Anpassung mehr Bedarf.

Nachdem wir den Code nun angepasst und auf unseren ESP hochgeladen haben und sich unser ESP erfolgreich in das WLAN eingeloggt hat (Weiße LED geht aus) müssen wir auch in diesem Teil wieder unsere APP erweitern.

Dazu fügen wir in unsere APP zwei weitere „LEVEL H“ Elemente hinzu und konfigurieren das erste Element für die Luftfeuchte wie folgt:

Part 4 app configuration


• Farbe: Weiß
• Input Pin: V7 (virtuell)
• Minimum Wert:0
• Maximum Wert: 100
• Reading Rate: PUSH

 

Das zweite „Level H“ Element für die Temperatur konfigurieren wie folgt:

Part 4 App Settings 2


• Farbe: Weiß
• Input Pin: V8 (virtuell)
• Minimum Wert: -20
• Maximum Wert: 60
• Reading Rate: PUSH

 

Anschließend sollte unsere Pflanzen App wie folgt aussehen:

Part 4 - App view

Nach drücken des „Start“ Buttons bekommen wir nun in der APP neben den aktuellen Bodenfeuchtesensorwerten auch die aktuelle Temperatur und Luftfeuchtigkeit dank unserem DHT Sensor angezeigt.

Ich wünsche viel Spaß beim Nachbauen, und bis zum nächsten Mal.

 

Esp-32Projects for advancedSensorsSmart home

2 comments

Knut Dorendorff

Knut Dorendorff

Hallo Michael.
Das würde mich interessieren
Gruss Knut

Michael

Michael

Der Beitrag ist ja mal wieder hervorragend geschrieben! Weiter so. Ich werde versuchen meinen Bosch BME zu implementieren.

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