Raspberry Pi practice problem · Sensors
Two-point calibration
HardBudget $12Python · gpiozero
A capacitive soil moisture sensor (powered from 3.3 V) with AOUT on channel 0 of an MCP3008 on the SPI pins (or the soil sensor + ADC board), and a red LED on GPIO17.
Every probe is different — the datasheet only says "2.4–2.8 V dry, 1.1–1.4 V wet". Calibrate yours:
- From 0 to 2 s the probe is in dry air (0 %): take its reading as dry (sample around 1 s).
- From 2 s to 4.5 s it is in a glass of water (100 %): take its reading as wet (sample around 3.5 s).
- From 5 s on, every second print the moisture, scaled linearly between your two points, as a whole percentage —
Moisture: 30%— and light the LED while it is below 40 % (the plant needs water).
The test plants it in soil at 30 % from 4.5 s, then waters it to 75 % at 8 s.