Introduction
This experiment shows how to use a pH sensor with an Arduino to measure the pH level of water, which is an important indicator of water quality.

Components Needed
- pH Sensor Module
- Arduino (e.g., Uno, Nano)
- Jumper wires
Circuit Setup
- Connect the pH sensor's output to an analog input pin (e.g., A0) on the Arduino.
- Connect the sensor's VCC and GND pins to the Arduino's 5V and GND, respectively.
The pH sensor will output an analog voltage that corresponds to the pH level.

Code for pH Measurement
Upload the following code to your Arduino to measure pH levels:
const int pHSensorPin = A0;
float voltage, pHValue;
void setup() {
Serial.begin(9600);
}
void loop() {
voltage = analogRead(pHSensorPin) * (5.0 / 1023.0);
pHValue = 3.5 * voltage; // Example conversion formula
Serial.print("pH Value: ");
Serial.println(pHValue);
delay(1000);
}
Explanation
The pH sensor provides a voltage output that corresponds to the pH level of the water. The Arduino reads this value and converts it to a pH value, which is then displayed on the Serial Monitor.
Troubleshooting
- If the sensor readings are inaccurate, check the calibration of the sensor.
- Ensure the sensor is properly connected to the correct analog pin and powered correctly.