Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP8266 NodeMCU Based Soil Moisture and Temperature Monitoring System

View and Edit Project In Cirkit DesignerImage of ESP8266 NodeMCU Based Soil Moisture and Temperature Monitoring System

Circuit Documentation

Summary

The circuit in question is designed to monitor soil moisture levels and ambient temperature and humidity. It utilizes an ESP8266 NodeMCU microcontroller as the central processing unit, interfaced with a DHT11 temperature and humidity sensor and a soil moisture sensor module. The ESP8266 NodeMCU reads analog data from the soil moisture sensor and digital data from the DHT11 sensor. The collected data is then processed and output through the serial interface.

Component List

ESP8266 NodeMCU

Soil Moisture Module

Soil Moisture Sensor

DHT11

Wiring Details

ESP8266 NodeMCU

Soil Moisture Module

Soil Moisture Sensor

DHT11

Documented Code

#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_ESP8266.h>

#define DHTPIN 4 // Connect Out pin to D2 in NODE MCU
#define DHTTYPE DHT11  
DHT dht(DHTPIN, DHTTYPE);

void setup()
{   
    Serial.begin(115200);
    dht.begin();
}

void loop()
{
    delay(1000);
    int value = analogRead(A0);
    value = map(value, 400, 1023, 100, 0); // Map the value from the sensor to a 0-100% scale
    float h = dht.readHumidity(); // Read humidity
    float t = dht.readTemperature(); // Read temperature
    
    // Print the soil moisture, temperature, and humidity to the serial monitor
    Serial.print("Soil Moisture : ");
    Serial.print(value);
    Serial.print("   Temperature : ");
    Serial.print(t);
    Serial.print("    Humidity : ");
    Serial.println(h);
}

This code is designed to be uploaded to the ESP8266 NodeMCU. It initializes the DHT11 sensor and reads the soil moisture level from the analog pin A0. The soil moisture value is mapped to a percentage scale for easier interpretation. The temperature and humidity are read from the DHT11 sensor and all the data is printed to the serial monitor at a one-second interval.