โ Back to Course
pH Sensors and Measurement Methods
๐ pH Sensors and Measurement Methods - Soil Acidity Monitoring
๐ What You'll Learn:
- ๐งช Compare 4 pH measurement methods (strips, pen, sensor, lab)
- ๐ Wire analog pH sensor to ESP32 for continuous monitoring
- ๐ Convert voltage readings to actual pH values (0-14 scale)
- โ๏ธ Calibrate sensor using pH 4 and pH 7 buffer solutions
๐ pH Measurement Methods Comparison
| Method | Price | Accuracy | Pros | Cons |
|---|---|---|---|---|
| ๐งช pH Test Strips | $5-10 | ยฑ0.5 | Cheap, no batteries | Low accuracy, one-time use |
| ๐ฑ Digital pH Pen | $10-20 | ยฑ0.1 | Portable, instant reading | Needs calibration monthly |
| ๐ฅ๏ธ Soil pH Sensor | $15-30 | ยฑ0.2 | Continuous monitoring | Needs ESP32, calibration |
| ๐ฌ Lab Analysis | $10-15/sample | ยฑ0.05 | Most accurate | Slow, per-sample cost |
๐ Soil pH Sensor Wiring
pH Sensor (Analog) ESP32
โโโโโโโโโโโโโโโโโโโ โโโโโโโ
VCC (3.3V/5V) โโโโโโบ 3.3V
GND โโโโโโบ GND
PO (pH Output) โโโโโโบ GPIO34 (ADC)
๐ Complete pH Sensor Code
#define PH_PIN 34
// Calibration values (measure in pH 7 and pH 4 solutions)
float ph7_voltage = 2.50; // Voltage reading in pH 7 buffer
float ph4_voltage = 3.00; // Voltage reading in pH 4 buffer
float readPH() {
int raw = analogRead(PH_PIN);
float volt = raw * (3.3 / 4095.0);
// Linear calibration: slope = (7-4)/(volt7 - volt4)
float slope = 3.0 / (ph7_voltage - ph4_voltage);
return 7.0 - (volt - ph7_voltage) * slope;
}
void setup() {
Serial.begin(115200);
pinMode(PH_PIN, INPUT);
}
void loop() {
float ph = readPH();
Serial.printf("๐ก๏ธ Soil pH: %.1f\n", ph);
if (ph < 5.5) Serial.println(" โ ACIDIC โ Add 2-3kg lime/100mยฒ");
else if (ph < 6.5) Serial.println(" โ
OPTIMAL for most crops");
else if (ph < 7.5) Serial.println(" โ
GOOD (slightly alkaline)");
else Serial.println(" โ ALKALINE โ Add sulfur/compost");
delay(60000);
}
๐ก Calibration Steps (Critical!):
- Buy pH 4.0 and pH 7.0 buffer solutions ($10)
- Rinse probe with distilled water
- Dip in pH 7.0 โ read voltage โ record as ph7_voltage
- Dip in pH 4.0 โ read voltage โ record as ph4_voltage
- Update code with your values
โ ๏ธ pH Sensor Care:
- โ Never let probe dry out โ Store in storage solution or pH 4 buffer
- โ Don't touch glass bulb (oils from skin affect readings)
- โ Calibrate monthly (or before each use for accuracy)
- โ Replace probe every 1-2 years (signal slows down)
๐ฏ Quick Reference:
- ๐งช pH < 5.5: Add lime (2-3kg/100mยฒ)
- โ pH 6.0-7.0: Perfect for vegetables
- ๐งช pH > 7.5: Add sulfur or organic matter
- โ๏ธ Calibrate monthly for accuracy
๐ก Key Takeaways:
- Apply these concepts directly to your farm or project.
- Take notes on important details for the quiz.
- Use the button below to track your progress.
×