ESP8266-Based Battery-Powered Soil Moisture Monitoring System
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to measure soil moisture levels using a soil moisture sensor and an ESP8266 microcontroller. The circuit is powered by a 9V battery and includes a rocker switch to control the power supply. The ESP8266 reads the analog value from the soil moisture sensor and prints the value to the Serial Monitor.
Component List
9V Battery
- Description: Provides power to the circuit.
- Pins:
+,-
Rocker Switch
- Description: Controls the power supply to the circuit.
- Pins:
input,output
ESP8266
- Description: Microcontroller used to read the soil moisture sensor and communicate the data.
- Pins:
3V,G,D8,D7,D6,D5,D4,D3,D2,D1,D0,A0,S3,S2,S1,SC,S0,SK,EN,VIN,RST,VU
Soil Moisture Sensor
- Description: Measures the moisture level in the soil.
- Pins:
gnd,vcc,aout
Wiring Details
9V Battery
Pin
-is connected to:- ESP8266: Pin
G
- ESP8266: Pin
Pin
+is connected to:- Rocker Switch: Pin
input
- Rocker Switch: Pin
Rocker Switch
Pin
inputis connected to:- 9V Battery: Pin
+
- 9V Battery: Pin
Pin
outputis connected to:- ESP8266: Pin
VIN
- ESP8266: Pin
ESP8266
Pin
Gis connected to:- 9V Battery: Pin
- - Soil Moisture Sensor: Pin
gnd
- 9V Battery: Pin
Pin
VINis connected to:- Rocker Switch: Pin
output
- Rocker Switch: Pin
Pin
A0is connected to:- Soil Moisture Sensor: Pin
aout
- Soil Moisture Sensor: Pin
Pin
3Vis connected to:- Soil Moisture Sensor: Pin
vcc
- Soil Moisture Sensor: Pin
Soil Moisture Sensor
Pin
gndis connected to:- ESP8266: Pin
G
- ESP8266: Pin
Pin
vccis connected to:- ESP8266: Pin
3V
- ESP8266: Pin
Pin
aoutis connected to:- ESP8266: Pin
A0
- ESP8266: Pin
Code Documentation
Code for ESP8266
// Define the pin for the soil moisture sensor
const int soilMoisturePin = A0;
void setup() {
// Initialize serial communication at 9600 baud rate
Serial.begin(9600);
}
void loop() {
// Read the analog value from the soil moisture sensor
int soilMoistureValue = analogRead(soilMoisturePin);
// Print the soil moisture value to the Serial Monitor
Serial.print("Soil Moisture Value: ");
Serial.println(soilMoistureValue);
// Wait for 1 second before taking another reading
delay(1000);
}
File Name: sketch.ino
This code initializes the ESP8266 to read the analog value from the soil moisture sensor connected to pin A0. The value is then printed to the Serial Monitor every second.