Make a capacitive soil moisture sensor using ESP32
Source: InternetPublisher:走马观花 Keywords: Humidity sensor ESP32 Updated: 2023/12/25
In order to make it easier to water the plants maintained in the greenhouse in winter, I am going to set up a system in case of emergencies.
After much thought, I came to the conclusion that I was going to make a sensor myself, because for my plant watering project (coming soon), I needed several sensors for several plants.
I chose the ESP32 as the microcontroller because it has multiple 12-bit ADC inputs and is capable of generating PWM signals at higher frequencies than, say, an ArduinoUno. In this project, a 600kHz signal will be generated for each sensor.
The sensor is made from simple, low-cost materials that are widely available and can be used as a capacitive humidity sensor.
Step 1: Make the Humidity Sensor
DIY sensors are made from simple materials:
some audio cables
Two hot pot forks
Terminals
Plastic seat leg covers
Silicone paste
The pins are cut from the fondue fork and chrome plated to help avoid corrosion. Construction with terminal blocks allows easy connection of copper cable wires to chrome-plated pins. The pin (not bent) facilitates insertion into the plant's soil.
As an indicator of moisture content, I'm reusing a water level indicator developed for a previous project of mine:
Step 4: Electronic Setup
In the breadboard setup I used ESP32s (node MCU). The reasons for this choice are stated in the introduction.
My plan is to expand this setup to have the functionality of making a complete plant watering system, with online monitoring and warnings. (ESP32 has onboard WiFi and Bluetooth).
The circuit diagram (made with Fritzing) is as follows:
The sensor circuit diagram is as follows:
The actual setup on the breadboard looks like this:
ESP32 provides 5V power from the USB port and has an onboard 3, 3V voltage regulator. One output GPIO pin is connected to one side of the humidity sensor through a 10KOhm resistor and sends a 600kHz signal to the sensor during 5 measurements (lasting 5 seconds). One input pin of the ESP32 (12-bit ADC) is connected via a diode and R/C network (1MOhm and 1uF). The other leg of the sensor is connected to GND.
The sensor is powered only during measurements to avoid electrolytic effects on the chrome pen.
In my experiments I determined the minimum and maximum values of the sensor by placing it in water (lowest measurement) and in the open air (highest value). Placing the sensor in a flower pot will produce values intermediate between the minimum and maximum values, depending on the soil moisture level. The scale of the intermediate values seems to be fairly linear.
Step 3: Make the Software
The loop function in ArduinoSketch is very simple and only consists of calling 2 functions:
The 1 second delay between measurements is for experimental and demonstration purposes only. In practical applications this frequency would be much less (usually a few times a day, depending on how thirsty the plant is)
ARDUINOIDE's drawing monitor and serial monitor are very useful during experiments. The view of the Drawing Monitor graph looks like this:
The reading on the plotmonitor shows the value measured by the 12-bit ADC. The ESP32's full 3.3V scale is divided by 4096, which is: 0.8mV per step.
Use the following code to measure moisture content:
The brackets for the average values are then determined based on the table above and the humidity levels are indicated with colors on the humidity indicator, thanks to the "Adafruit_NeoPixel.h" library:
To download the sketch to the ESP32 via the USB port, you need to hold down the Boot button.
- Interface circuit composed of 8255A and single chip microcomputer
- Interface circuit between CAN bus controller and single chip microcomputer
- Make a capacitive soil moisture sensor using ESP32
- Sharing the process of making a single-chip integrated digital clock
- 815ept motherboard
- Circuit diagram: AT88RF
- Serial to infrared circuit
- Interface and program design between digital potentiometer X9241 and PIC microcontroller
- Microcontroller test board circuit 2
- One card multiple numbers card reader circuit schematic diagram
- Grain depot humidity detection circuit
- Automatic sprinkler irrigation control circuit
- Schmidt humidity sensor
- Grain moisture detection circuit
- Relative Humidity Sensor Signal Conditioner Circuit Diagram
- Homemade humidity sensor control circuit
- Homemade humidity sensor and alarm circuit
- SM-C-1 type humidity sensor circuit
- Humidity sensor conversion circuit
- Lithium chloride humidity sensor bridge circuit