Micropython script made for an ESP32 that monitors moisture levels in soil using an analog sensor connected to pin 34, and controls three LEDs based on the moisture readings. Also added a “loop break” button.
Set Up
2x conductive and non corrosive metal nails, one to Ground and the other to pin 34, which is set up as an ADC (Analog-to-Digital Converter) input to read analog values, with a full range of 0-3.3V using atten(ADC.ATTN_11DB).
Three LEDs are connected to pins 25 (green), 26 (yellow), and 27 (red), and are configured as output pins to be turned on or off.
A button is connected to pin 13 with an internal pull-up resistor. When pressed, the button’s value goes to
0
, which will stop the loop.
mPYTHON moisture_sensor.txt