ESP32-S3 thirsty plant alarm
A capacitive soil moisture sensor in the pot: when the soil is dry the red LED lights and a beep sounds every two seconds until you water it. The sensor goes on the analog input, in place of the kit's potentiometer; no soldering, no internet connection.
The program
Chip BASIC: every line is one instruction you can read and change. The compiler checks it at every release of the site.
10 LET a = AREAD()
20 IF a > 2500 THEN LED red, on : SOUND "beep"
30 IF a <= 2500 THEN LED red, off
40 WAIT 2s
50 GOTO 10What you should see: with moist soil everything is off; with dry soil the red LED is on and it beeps every 2 seconds. In the simulator, move the analog input's slider up for dry soil.
▶ Open it in the IDEIn the simulator you see the logic run right away, with no hardware. The simulator does not check the wires: you check those on the board, and the IDE's wiring check walks you through it.
The parts
The compiler finds the parts in the program. Each has its own page with a test program to run before you build the whole thing.
- LED (with resistors: 220 Ω, or 470 Ω on the UNO R4)The part's page: LEDs: red, yellow, green and blue lights
- Passive buzzerThe part's page: Piezo buzzer
- Analog sensor (potentiometer or LDR)The part's page: Analog sensor: potentiometer or light
How to wire it to an ESP32-S3
- Signal → ESP32-S3: GPIO9
- VCC → ESP32-S3: 3V3
- GND → ESP32-S3: GNDCommon ground: this link is mandatory.
- + → ESP32-S3: GPIO5
- − → ESP32-S3: GND
- + red → ESP32-S3: GPIO4Through a 220 Ω resistor
- − → ESP32-S3: GNDCommon ground: this link is mandatory.
If it does not work
- The lights: the program runs but nothing happens
- The LED is the wrong way round, or the series resistor is missing. The long leg goes on the board pin's side, the short one towards GND, with the resistor in between (220 Ω, or 470 Ω on the UNO R4).
- The buzzer: the program runs but nothing happens
- The signal does not reach the buzzer: the wire is on the wrong pin, or the negative pole is not on GND. The signal goes to the pin shown in the diagram, the negative pole to GND.
- The analog sensor: the program runs but nothing happens
- The signal wire is not on the analog pin, or the potentiometer's middle pin is swapped with a side one. The middle pin goes to the analog pin in the diagram, the two side pins to 3.3 V and GND (never 5 V).
What you can change
The threshold is the 2500 on lines 20 and 30: measure your pot (the value just after watering and when it is dry) and put it in between. Remove the SOUND on line 20 if the light is enough, or ask Chip to check once an hour instead of every 2 seconds.
Which boards it works on
- ESP32-S3 Freenove: yes
- Nordic nRF54LM20 DK: yes
- Arduino UNO R4 WiFi: yes