raw Software
RAW Software Drivers Sensor Interfaces

Control PH-4502C pH Sensor with Arduino

Robert Eisele

PH-4502C is one of the most common low-cost pH interface boards for Arduino projects. You can use it for aquarium monitoring, hydroponics, irrigation checks, and water-quality prototypes where analog pH readings are sufficient.

This guide is written as a complete start-to-finish workflow: hardware overview, wiring, calibration, voltage-to-pH conversion, filtering, temperature compensation, and tested Arduino sketches.

[PHOTO PLACEHOLDER: PH-4502C board with BNC probe connected and labels visible]

PH-4502C Overview and Specs

The board accepts a BNC glass electrode and outputs analog voltage on PO. The Arduino reads PO and maps voltage to pH using a calibrated linear model.

Parameter Typical Value
Supply voltage 5V DC
Power consumption about 0.5W
Measurement range pH 0 to pH 14
Operating temperature 0C to 60C (module-level typical)
Declared accuracy about +/-0.1 pH (probe and calibration dependent)
Response time typically up to about 60s depending on probe condition
Main output PO analog pH output
Aux output TO analog temperature-related output (board dependent)

Pinout and Trimmers

[SKETCH PLACEHOLDER: TO, DO, PO, dual GND pins, VCC, POT1, POT2]

  • PO: analog pH voltage output to Arduino ADC (usually A0)
  • TO: analog temperature-related output for software compensation workflows
  • DO: digital comparator output, threshold set by POT2
  • VCC: 5V input
  • GND: board grounds (connect both ground points in your wiring)
  • POT1: offset trimmer for midpoint calibration
  • POT2: digital threshold trimmer for DO output

For measurement accuracy, POT1 is the key control. POT2 is optional and only needed if you actively use DO as a threshold alarm line.

How pH Measurement Works

The glass electrode produces a potential linked to hydrogen-ion activity. The PH-4502C shifts and scales this signal so the MCU can sample it as voltage.

A common model for projects is:

pH = 7 + (V_offset - V_meas) / slope

  • V_offset: neutral midpoint target (often near 2.5V)
  • V_meas: measured PO voltage
  • slope: volts per pH unit (often around 0.18V/pH at room temperature)

Probe age, temperature, and buffer quality shift these values over time, so recalibration is part of normal operation.

Required Materials

Hardware

  • Arduino UNO (or compatible)
  • PH-4502C module
  • BNC pH probe
  • Jumper wires
  • Multimeter for calibration
  • pH 7.00 buffer (plus pH 4.00 and/or 10.00 for better calibration)
  • Distilled water for rinse steps

Software

  • Arduino IDE

Calibration Workflow

One-Time Electrical Offset Setup

  1. Disconnect probe from BNC.
  2. Short BNC center pin to shield with a short wire.
  3. Power board at 5V with shared ground.
  4. Measure PO using a multimeter and set POT1 close to 2.500V.

Neutral Buffer Setup

  1. Reconnect probe and rinse with distilled water.
  2. Place probe in pH 7.00 buffer and wait for stabilization.
  3. Fine-adjust POT1 until your serial output is near pH 7.

Practical Care Rules

  • Rinse between different solutions.
  • Do not wipe the glass bulb dry; this can scratch the membrane.
  • Store probe in proper storage solution to reduce drift.

Wiring PH-4502C to Arduino

PH-4502C Arduino UNO Purpose
PO A0 Main pH voltage input
TO A1 (optional) Temperature-related input
VCC 5V Module power
GND + GND GND Shared reference, connect both board grounds

For 3.3V MCUs like ESP32, protect ADC input if PO can exceed 3.3V. A simple 2:1 divider with two equal resistors (for example 10k and 10k) is a common approach.

[SKETCH PLACEHOLDER: PO to A0, TO to A1, both GND pins tied to MCU GND]

Startup Checklist (No Extra Sources Needed)

  1. Wire VCC/GND/PO first and verify analog voltage at PO.
  2. Run offset setup (shorted BNC, POT1 to around 2.500V).
  3. Run neutral buffer calibration and verify pH around 7.
  4. Upload Sketch 1 and confirm stable base reading.
  5. Move to Sketch 2 when noise is visible.
  6. Add Sketch 3 compensation only after TO behavior is validated on your board.

pH Calculator

Use this calculator to convert measured voltage into pH and estimate temperature-compensated output.

  • Raw pH: 7.00
  • Temperature compensated pH: 7.00

Arduino Example 1: Basic pH Reading

#include <Arduino.h>

const int pHSense = A0;
const int samples = 10;

float toPH(float voltage, float vOffset = 2.5f, float slope = 0.18f) {
  return 7.0f + ((vOffset - voltage) / slope);
}

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

void loop() {
  long sum = 0;
  for (int i = 0; i < samples; ++i) {
    sum += analogRead(pHSense);
    delay(10);
  }

  float voltage = (5.0f / 1024.0f) * (sum / (float)samples);
  float ph = toPH(voltage);

  Serial.print("V=");
  Serial.print(voltage, 3);
  Serial.print(" pH=");
  Serial.println(ph, 2);

  delay(1500);
}

Arduino Example 2: Moving Average with Outlier Trimming

#include <Arduino.h>

#define SAMPLES 30
#define TRIM 5

const int pHSense = A0;

float toPH(float voltage, float vOffset = 2.5f, float slope = 0.18f) {
  return 7.0f + ((vOffset - voltage) / slope);
}

float readFilteredPH() {
  int buf[SAMPLES];
  for (int i = 0; i < SAMPLES; ++i) {
    buf[i] = analogRead(pHSense);
    delay(30);
  }

  for (int i = 0; i < SAMPLES - 1; ++i) {
    for (int j = i + 1; j < SAMPLES; ++j) {
      if (buf[i] > buf[j]) {
        int t = buf[i];
        buf[i] = buf[j];
        buf[j] = t;
      }
    }
  }

  long sum = 0;
  for (int i = TRIM; i < SAMPLES - TRIM; ++i) {
    sum += buf[i];
  }

  float voltage = (5.0f / 1024.0f) * (sum / (float)(SAMPLES - 2 * TRIM));
  return toPH(voltage);
}

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

void loop() {
  Serial.print("pH=");
  Serial.println(readFilteredPH(), 2);
  delay(1000);
}

Arduino Example 3: Temperature Compensation

#include <Arduino.h>

const int pHSense = A0;
const int tempSense = A1;

float toPH(float voltage, float vOffset = 2.5f, float slope = 0.18f) {
  return 7.0f + ((vOffset - voltage) / slope);
}

float readTemperatureC() {
  int raw = analogRead(tempSense);
  return raw * 5.0f / 1024.0f * 100.0f;
}

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

void loop() {
  long sum = 0;
  for (int i = 0; i < 10; ++i) {
    sum += analogRead(pHSense);
    delay(10);
  }

  float voltage = (5.0f / 1024.0f) * (sum / 10.0f);
  float rawPH = toPH(voltage);
  float tempC = readTemperatureC();

  // Coefficient depends on your probe and compensation model.
  float compPH = rawPH + (tempC - 25.0f) * 0.003f;

  Serial.print("Temp=");
  Serial.print(tempC, 1);
  Serial.print("C pH=");
  Serial.println(compPH, 2);

  delay(1500);
}

PH-4502C vs Alternatives

Module Typical Cost Interface Typical Use
PH-4502C Low Analog Prototyping and monitoring
DFRobot Gravity pH Medium Analog Similar analog workflow
Atlas Scientific EZO-pH High I2C/UART Production and high-accuracy systems

Frequently Asked Questions

Can I use PH-4502C in saltwater or hydroponics?

Yes. Rinse the probe with distilled water after measurements and keep storage conditions correct to preserve probe life and stability.

How often should I recalibrate?

Typical interval is every 2 to 4 weeks. In harsh or high-temperature environments, weekly calibration is safer.

Can I use it with ESP32 or other 3.3V MCUs?

Yes, but protect ADC input from 0-5V PO using a voltage divider or proper signal conditioning.

Troubleshooting Checklist

  • Readings fluctuate: improve grounding and use filtered sampling.
  • Offset drifts: redo calibration and verify buffer freshness.
  • Response is very slow: check probe hydration and stabilization time.
  • Values always acidic or alkaline: inspect conversion constants and ADC scaling.
  • Long-term instability: ensure correct probe storage between measurements.