SunFounder ESP32 Starter Kit
(continued from previous page)
# Scale the value to the range of 0-1023 for ESP32 PWM duty cycle
pwm_value = int(value * 1023 / 4095)
# Update the LED brightness based on the potentiometer value
led.duty(pwm_value)
# Read the voltage in microvolts and convert it to volts
voltage = pot.read_uv() / 1000000
# Print the raw value and the voltage
print(f"value: {value}, Voltage: { voltage}V")
# Wait for 0.5 seconds before taking the next reading
time.sleep(0.5)
With this script run, the LED brightness changes as the potentiometer is rotated, while the analog value and voltage at
this point are displayed in the Shell.
• machine.ADC - MicroPython Docs
3.27 5.9 Measure Soil Moisture
This capacitive soil moisture sensor is different from most of the resistive sensors on the market, using the principle of
capacitive induction to detect soil moisture.
By visually reading the values from the soil moisture sensor, we can gather information about the moisture level in the
soil. This information is useful for various applications, such as automatic irrigation systems, plant health monitoring,
or environmental sensing projects.
Required Components
In this project, we need the following components.
It’s definitely convenient to buy a whole kit, here’s the link:
Name ITEMS IN THIS KIT LINK
ESP32 Starter Kit 320+
You can also buy them separately from the links below.
COMPONENT INTRODUCTION PURCHASE LINK
ESP32 WROOM 32E
ESP32 Camera Extension -
Jumper Wires
Soil Moisture Module
Available Pins
• Available Pins
3.27. 5.9 Measure Soil Moisture 385