Working Principle
A pH sensor consists of a glass electrode immersed in the test solution. The glass membrane develops a voltage potential proportional to the hydrogen ion (H+) concentration difference between the internal reference solution and the external sample. This voltage follows the Nernst equation: at 25 °C, the electrode produces approximately ±59.16 mV per pH unit change from pH 7 (where voltage is 0 V).
A signal conditioner board (like the DFRobot SEN0161 or Atlas Scientific EZO-pH) amplifies this millivolt signal, offsets it to a positive range, and outputs an analog voltage (0–5 V) or digital reading proportional to pH.
Electrical Characteristics
| Parameter | Typical (DFRobot SEN0161) |
|---|---|
| pH Range | 0–14 |
| Accuracy | ±0.1 pH (after calibration) |
| Response Time | <2 minutes (90% of final value) |
| Electrode Impedance | >250 MΩ (extremely high) |
| Nernst Sensitivity | ~59.16 mV/pH at 25 °C |
| Output (conditioned) | Analog 0–5 V (mid-point at pH 7) |
| Supply Voltage | 5 V |
| Probe Life | ~1 year (glass electrode, store in KCl solution) |
Interfacing with an MCU
Connect the pH probe to the BNC connector on the signal conditioner board, then wire VCC, GND, and the analog output to an MCU ADC pin. The conditioner handles the impedance matching (critical — the electrode’s >250 MΩ impedance cannot drive an ADC directly).
Calibration
- Two-point calibration: Immerse in pH 7.0 buffer (set midpoint), then in pH 4.0 buffer (set slope) — standard for most applications
- Three-point: Add pH 10.0 for full-range accuracy (alkaline calibration)
- Temperature compensation: The Nernst slope changes with temperature; compensate with a thermistor or DS18B20 temperature reading
- Recalibrate: Weekly for critical applications; monthly for hobby use
Code Example
/*
* pH Sensor (DFRobot SEN0161) — Arduino
* Wiring: VCC → 5V, GND → GND, Signal → A0
* Calibrate with pH 7.0 and pH 4.0 buffer solutions
*/
#define PH_PIN A0
/* Calibration values (measure voltage at pH 4.0 and pH 7.0) */
#define PH7_VOLTAGE 2.50 /* Voltage at pH 7.0 (adjust after cal) */
#define PH4_VOLTAGE 3.04 /* Voltage at pH 4.0 (adjust after cal) */
float readPH() {
/* Average 10 samples */
long sum = 0;
for (int i = 0; i < 10; i++) {
sum += analogRead(PH_PIN);
delay(10);
}
float voltage = (sum / 10.0) * 5.0 / 1024.0;
/* Linear interpolation from calibration points */
float slope = (7.0 - 4.0) / (PH7_VOLTAGE - PH4_VOLTAGE);
float ph = 7.0 + (voltage - PH7_VOLTAGE) * slope;
return ph;
}
void setup() {
Serial.begin(9600);
Serial.println("pH Sensor Ready (calibrate with buffer solutions)");
}
void loop() {
float ph = readPH();
float voltage = analogRead(PH_PIN) * 5.0 / 1024.0;
Serial.print("pH: ");
Serial.print(ph, 1);
Serial.print(" Voltage: ");
Serial.print(voltage, 3);
Serial.println(" V");
delay(2000);
}
Real-World Applications
Hydroponics, Aquariums & Water Treatment
pH sensors are essential in hydroponic growing systems (maintaining 5.5–6.5 pH for nutrient uptake), aquarium water management, swimming pool chemistry, wastewater treatment (optimising flocculation), food and beverage production (fermentation monitoring), and environmental water quality testing. Automated dosing systems use pH readings to inject acid or base to maintain target levels.
Limitations
- Probe degradation: Glass electrodes have a finite lifespan (6–12 months); response slows as the glass ages.
- Storage critical: Must be stored in KCl solution; drying destroys the reference junction.
- Temperature dependence: Nernst slope varies with temperature; uncompensated readings drift ±0.03 pH/°C.
- High impedance: The electrode’s 250+ MΩ impedance requires specialised amplifiers; cannot connect directly to ADC.
- Frequent calibration: Accuracy degrades between calibrations; not a “set and forget” sensor.