Build a Low‑Cost Arduino pH Sensor for Your Home Lab

Ever tried to measure the acidity of a DIY soda or a garden soil sample and found the cheap test strips either too vague or too pricey? That’s the moment I realized I needed a reliable, reusable pH meter that wouldn’t break the bank. With a little Arduino magic and a cheap glass probe, you can get lab‑grade readings right from your kitchen bench. Below is the step‑by‑step guide I use in my own experiments at Tech Brew Lab.

What you need

  • Arduino Uno or compatible board – the brain of the project. If you already have one for other tinkering, great.
  • Analog pH probe – you can buy a generic glass electrode for $10‑$15 on e‑bay or AliExpress. Look for “pH sensor probe for Arduino”.
  • Signal‑conditioning circuit – a simple op‑amp based amplifier (LM358 works fine) and a few resistors.
  • Breadboard and jumper wires – for prototyping.
  • 5 V power supply – the Arduino’s USB power is enough.
  • Calibration solutions – standard pH 4.0 and pH 7.0 buffers (you can buy a small bottle set or make a vinegar‑water mix for pH 4.0 and a mild soap solution for pH 7.0).
  • A small plastic or glass container – to hold the liquid you’re testing.
  • Optional: 3D‑printed or laser‑cut housing – if you want a tidy final look.

All of these items total under $30, which is a fraction of the price of a commercial meter.

How it works

The Arduino side

The Arduino reads an analog voltage from the probe circuit on one of its analog input pins (A0 is a common choice). The raw voltage is tiny—usually a few millivolts per pH unit—so we need to amplify it before the Arduino can see a useful range (0‑5 V).

The pH probe side

A glass pH probe works like a tiny battery. Its glass membrane develops a voltage that changes with the hydrogen ion concentration in the solution. The voltage is negative for acidic solutions and positive for basic ones. Because the signal is weak and can drift, we add a high‑impedance buffer (the op‑amp) to keep the reading stable.

Step‑by‑step build

1. Assemble the circuit

  1. Place the LM358 on the breadboard.
  2. Connect the probe’s BNC connector (or the two wires if it’s a bare probe) to the non‑inverting input (+) of the op‑amp.
  3. Wire the inverting input (–) to a voltage divider that sets the reference at 2.5 V (half of Arduino’s 5 V). This centers the output around the mid‑range.
  4. Add a feedback resistor of 100 kΩ between the output and the inverting input. This gives a gain of about 10, enough to stretch the probe’s millivolt signal into the Arduino’s 0‑5 V window.
  5. Connect the op‑amp’s output to Arduino’s A0 pin.
  6. Power the circuit from the Arduino’s 5 V and GND pins.

2. Write the Arduino sketch

const int phPin = A0;
float voltage, phValue;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int raw = analogRead(phPin);
  voltage = raw * (5.0 / 1023.0);      // convert to volts
  phValue = 3.5 * voltage + 0.0;      // placeholder; will be calibrated
  Serial.print("Voltage: ");
  Serial.print(voltage, 3);
  Serial.print(" V  |  pH: ");
  Serial.println(phValue, 2);
  delay(1000);
}

The line phValue = 3.5 * voltage + 0.0; is just a rough estimate. We’ll replace the slope and offset after calibration.

3. Upload and test

Plug the Arduino into your laptop, upload the sketch, and open the Serial Monitor. You should see a voltage reading that changes as you dip the probe into water. If the numbers look flat, double‑check your wiring and make sure the probe is wet.

4. Calibrate the sensor

Calibration is the heart of any pH meter.

  1. Zero point (pH 7.0) – Place the probe in the pH 7.0 buffer. Note the voltage reading (V7). In the sketch, replace the placeholder formula with phValue = (V7 - voltage) * slope + 7.0.
  2. Span point (pH 4.0) – Move the probe to the pH 4.0 buffer. Note the voltage (V4). Compute the slope: slope = (7.0 - 4.0) / (V7 - V4).
  3. Update the sketch with the new slope and offset values, then re‑upload.

Now the sensor should output a realistic pH number for any solution you test.

Testing and calibration

After calibration, try a few household liquids: lemon juice, black coffee, and a mild soap solution. Record the readings and compare them to known values (lemon juice is around pH 2‑3, coffee about pH 5, soap near pH 9). Small deviations are normal; the probe’s glass membrane ages, and temperature also shifts the voltage. If you need higher accuracy, add a temperature sensor (like the DS18B20) and apply a temperature compensation factor—something I’ll cover in a future Tech Brew Lab post.

Tips and troubleshooting

  • Keep the probe clean. Rinse with distilled water after each use and store it wet in a small bottle of buffer solution. A dry probe can give erratic readings.
  • Mind the reference voltage. If you power the Arduino from a laptop USB, the 5 V line can be a bit noisy. A small capacitor (0.1 µF) across the reference divider helps smooth things out.
  • Watch for drift. Glass probes can drift by 0.1 pH per week. Re‑calibrate weekly if you need consistent data.
  • Avoid strong bases. Very high pH (>10) can damage cheap probes. Stick to the range 0‑10 for best longevity.
  • Enclose the circuit. A simple 3D‑printed case keeps the op‑amp away from splashes and makes the whole thing look tidy on your bench.

With this setup, you have a reusable, low‑cost pH sensor that plugs straight into your Arduino and talks to your laptop over serial. It’s perfect for home chemistry experiments, garden testing, or just satisfying that curiosity about how acidic your favorite craft soda really is. Next time you’re at the market, grab a bag of fresh berries, crush them, and watch the pH drop in real time—science in the kitchen, the Tech Brew Lab way.

Reactions