Documentation

Complete technical documentation for the IoT Mushroom Environment Monitoring System.


⚙️ System Features

  • 🌡 Real-time temperature monitoring
  • 💧 Humidity monitoring
  • 🌱 Soil moisture monitoring
  • 🌫 Gas level monitoring
  • 📟 20×4 LCD display output
  • 📱 Remote monitoring with Blynk IoT
  • 🌀 Remote fan control through mobile application

💻 System Architecture

The system is built using an ESP32 microcontroller which acts as the central controller. Multiple environmental sensors collect data and send it to the ESP32. The microcontroller processes the data, displays it on an LCD screen, and uploads the information to the Blynk IoT cloud platform for remote monitoring.

📚 Libraries Used

  • WiFi.h — Handles WiFi connection for the ESP32
  • BlynkSimpleEsp32.h — Enables communication with the Blynk IoT platform
  • Wire.h — Enables I2C communication
  • LiquidCrystal_I2C.h — Controls the 20×4 LCD display
  • DHT.h — Reads temperature and humidity data from the DHT22 sensor

🔑 Blynk Configuration

The system connects to a Blynk IoT project using the following identifiers:

  • Template ID — Identifies the Blynk project template
  • Template Name — Name of the IoT dashboard
  • Auth Token — Authentication key linking the device to Blynk cloud

These parameters must be defined before including the Blynk library in the code.

🌐 WiFi Configuration

The ESP32 connects to the internet using a WiFi network. The network credentials are defined using:

  • WiFi SSID — Network name
  • WiFi Password — Network password

Once connected, the device communicates with the Blynk cloud server and starts sending environmental data.

🖥 LCD Display

A 20×4 I2C LCD display is used to show real-time environmental data, allowing users to monitor the system locally without opening the mobile application.

RowInformation Displayed
Row 1Humidity value
Row 2Temperature value
Row 3Soil moisture percentage and water status
Row 4Gas sensor reading

🌡 Temperature & Humidity Monitoring

A DHT22 sensor measures environmental temperature and humidity. These values are continuously read by the ESP32 and updated every second.

  • Temperature is measured in degrees Celsius
  • Humidity is measured in percentage

🌱 Soil Moisture Monitoring

The soil moisture sensor provides an analog value between 0 and 4095. The code converts this raw value into a percentage to make the data easier to interpret.

A higher percentage indicates wetter soil while a lower value indicates dry soil.

🌫 Gas Level Monitoring

The MQ-7 gas sensor detects gas levels in the environment. If the sensor reading exceeds the predefined threshold value, the system marks the condition as gas detected.

📱 Blynk Dashboard Integration

The Blynk IoT platform allows users to monitor environmental conditions remotely. The ESP32 sends sensor data to the Blynk cloud using virtual pins.

Virtual PinFunction
V1Fan control switch
V5Humidity value
V6Temperature value
V7Soil moisture percentage
V8Gas sensor raw value
V9Water detection indicator
V10Gas detection indicator

🌀 Fan Control System

The system includes a relay module connected to a fan. The relay allows the fan to be controlled remotely from the Blynk mobile application.

When the user toggles the fan switch in the app, the command is sent to the ESP32, which activates or deactivates the relay accordingly.

⏱ Automated Monitoring Loop

The program uses a timer system to perform sensor readings at regular intervals. Every 1 second, the system performs the following tasks:

  • Read sensor data
  • Update the LCD display
  • Send data to the Blynk dashboard

This ensures continuous monitoring of the mushroom cultivation environment.

⚙ System Initialization

When the device starts, the setup function performs several initialization steps:

  • Start serial communication
  • Initialize the LCD display
  • Initialize sensors
  • Configure input and output pins
  • Connect to WiFi
  • Connect to the Blynk cloud server
  • Start the periodic monitoring timer

🔄 Main Program Loop

The main loop of the program runs continuously and performs two key tasks:

  • Blynk.run() — Maintains connection with the Blynk cloud server
  • timer.run() — Executes scheduled tasks such as sensor reading

This design ensures that the system continuously monitors environmental conditions while remaining connected to the IoT dashboard.

🚀 Future Improvements

  • Machine learning integration for predicting mushroom growth
  • Automated humidity and climate control
  • Smart alert notifications
  • Environmental data logging and analytics
  • Advanced IoT dashboard visualization

🍄 IoT Mushroom Monitoring System — Team Mycelium — GitHub