Skip to content
AkerminMeasure. Monitor. Improve. Compare Products
Learning Center

How to Make a pH Meter With Arduino

You want to read pH from an Arduino for a hydroponic tank, aquarium or school project. The build is simple, but the electrode needs the right interface and a proper calibration before the numbers mean anything.

As an Amazon Associate, Akermin earns from qualifying purchases. Product links on this page are affiliate links.

You need three things: a glass combination pH electrode with a BNC connector, a pH interface board that buffers the electrode’s tiny high-impedance voltage and shifts it into the Arduino’s 0 to 5 volt range, and calibration buffers at pH 7 and pH 4 or 10. Connect the board’s output to an analog pin, average many readings, record the voltage in each buffer, and convert with a straight line between those two points. Never connect the electrode directly to the Arduino, and expect hobby-grade accuracy of about a tenth of a pH unit when it is set up well, which is good for hydroponics and aquariums but not for food safety records or lab work.

Why the electrode cannot plug straight into an analog pin

A pH electrode is a small battery whose voltage depends on hydrogen ion activity. A thin glass membrane develops a potential that changes by about 59 millivolts per pH unit at 25 C, and it is close to zero millivolts at pH 7. Acidic solutions give a positive voltage and alkaline solutions a negative one, so the full range from pH 0 to 14 is only about plus or minus 414 millivolts.

The difficulty is the source resistance. The glass membrane has an internal resistance in the range of tens to hundreds of megohms. An Arduino analog input, and even a normal multimeter, draws enough current to collapse that voltage, so you would read nonsense. The input also cannot see negative voltages.

A pH interface board solves both problems. It contains an operational amplifier with an extremely high input impedance that copies the electrode voltage without loading it, adds gain, and shifts the result so that pH 7 lands somewhere in the middle of the 0 to 5 volt range, often near 2.5 volts. Most boards have a trimmer to set that offset. Some boards also isolate the probe electrically, which matters in tanks with pumps and heaters.

Parts list and wiring

Part What to look for Why it matters
Combination pH electrode Gel-filled, BNC plug, rated for your sample (water, soil slurry, food) The electrode sets the accuracy and lifespan more than anything else
pH interface board High-impedance input, BNC socket, analog output, offset trimmer; isolation is a plus Converts millivolts to a voltage the Arduino can read
Arduino or compatible Any board with an analog input; 5 V or 3.3 V boards both work if the output range matches Reads and converts the signal
Temperature sensor A waterproof digital probe such as a DS18B20 Lets you correct slope for temperature
Buffers Fresh pH 7.00 and pH 4.00 or 10.00 Calibration reference
Storage solution KCl electrode storage solution Keeps the glass hydrated; never store in distilled water
  1. Connect the board’s VCC and GND to the Arduino 5 V (or 3.3 V if the board supports it) and GND.
  2. Connect the board’s analog output, often labelled Po or A, to an analog pin such as A0.
  3. Screw the electrode onto the BNC socket.
  4. Wire the temperature probe to a digital pin with its pull-up resistor, as its datasheet shows.
  5. Keep the analog wire short and away from motor, pump and relay wiring.

Turning the voltage into pH: the calibration maths

The relationship between voltage and pH is very close to a straight line, so two buffer points define it. In your sketch, take a few dozen analog readings, discard the highest and lowest, average the rest, and convert to volts: on a 10-bit, 5 volt board, volts = reading times 5.0 divided by 1023. Then:

  1. Rinse the electrode with distilled water, blot, and place it in pH 7.00 buffer. Wait until the voltage stops changing, often 30 to 60 seconds, and record it as V7.
  2. Rinse again and place it in pH 4.00 buffer. Record V4.
  3. Compute the slope m = (4.00 minus 7.00) divided by (V4 minus V7).
  4. For any sample, pH = 7.00 + m times (V minus V7).

Worked example: V7 = 2.50 V and V4 = 3.03 V. Then m = minus 3.00 / 0.53 = minus 5.66 pH per volt. A sample reading 2.80 V gives pH = 7.00 + (minus 5.66 times 0.30) = 7.00 minus 1.70 = 5.30. This formula works whether your board’s voltage rises or falls with acidity, because the sign comes out of the calibration.

Resolution check: a 10-bit converter on 5 V has steps of about 4.9 mV. With the slope above, one step is 0.0049 times 5.66, roughly 0.03 pH. That is fine, but it is why averaging helps; a single reading can bounce by one or two steps.

Store V7 and V4 in EEPROM so calibration survives a reset, and recalibrate regularly; hobby electrodes drift, especially in nutrient solutions.

Temperature and noise, the two things that spoil readings

The electrode slope is proportional to absolute temperature. It is about 54 mV per pH at 0 C, 59.16 mV at 25 C and about 61.5 mV at 37 C. If you calibrate at 25 C and measure at 15 C, a sample far from pH 7 reads slightly wrong. Correct by scaling the slope: multiply m by (calibration temperature in kelvin divided by sample temperature in kelvin). Close to pH 7 the effect is small; at pH 4 or 10 it can be a few hundredths of a unit per few degrees.

Noise is the more common problem in practice:

  • Ground loops. A pump, heater or second probe in the same water can inject current through the electrode, giving jumpy or offset readings. Unplug other equipment as a test; if readings settle, use an isolated board or isolate the power supply.
  • EC and pH probes together. A conductivity probe drives current into the water and can upset a non-isolated pH circuit. Read them at different times or isolate one.
  • Long or unshielded cable. Keep the BNC lead short and the analog wire away from switching supplies.
  • USB power noise. A clean regulated supply often gives steadier readings than a laptop port.

Proving it works and knowing its limits

After calibrating, read a third buffer you did not calibrate with, for example pH 10 if you used 7 and 4. Within about 0.1 pH is a good result for this kind of build. Compare it with a commercial meter in a real sample too; a pen meter such as the VIVOSUN digital pH meter makes a handy cross-check if it has been calibrated in the same buffers. For guidance on what separates a precise instrument from a rough one, see what makes a pH meter accurate.

Signs the electrode, not your code, is the problem:

  • the pH 7 and pH 4 voltages are very close together, meaning a weak slope;
  • readings take many minutes to settle;
  • the reading drifts steadily in a buffer that should be stable;
  • the glass bulb is cracked, dried out, or coated with algae or nutrient deposits.

Most hobby electrodes last somewhere around one to two years depending on care. Keep them wet in storage solution, rinse between samples, and never wipe the glass bulb hard. If you need dependable numbers for food safety, compliance or lab reports, buy a proper meter; our guide to pH meters covers the options.

Build order that saves the most time

Get the interface board reading a steady voltage with the electrode in pH 7 buffer before writing any conversion code, because noise and wiring problems are much easier to find on a raw voltage. Then add averaging, two-point calibration stored in EEPROM, and temperature correction, and check against a third buffer before you trust a single sample.

Frequently Asked Questions

Can I connect a pH probe to an Arduino without an amplifier board?

No. The electrode has a very high internal resistance and produces negative as well as positive voltages, so the Arduino input would load it and could not read the negative half. A high-impedance buffer amplifier is essential.

How accurate can an Arduino pH meter be?

With a good electrode, fresh buffers, averaging and temperature correction, about 0.1 pH is realistic. Cheap electrodes, ground loops and old buffers easily make it worse.

Can I leave the probe in my hydroponic tank permanently?

You can, but it will drift faster and need cleaning and recalibration more often, often every week or two. Use an isolated interface board if pumps or an EC probe share the tank.

Do I need temperature compensation?

If your water stays within a few degrees of the calibration temperature and your pH is near neutral, the error is small. For wide temperature swings or samples far from pH 7, add a temperature sensor and scale the slope.

Why do my readings jump when the pump turns on?

That is a classic ground loop or electrical noise problem. Try an isolated pH board, a separate power supply, or take readings with the pump briefly off.