Help with Ph sensor pin abbreviations

int ph_pin = A7; //This is the pin number connected to Po

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

void loop() { int measure = analogRead(ph_pin); Serial.print("Measure: "); Serial.print(measure);

double voltage = 5 / 1024.0 * measure; //classic digital to voltage conversion Serial.print("\tVoltage: "); Serial.print(voltage, 3);

// PH_step = (voltage@PH7 - voltage@PH4) / (PH7 - PH4) // PH_probe = PH7 - ((voltage@PH7 - voltage@probe) / PH_step) float Po = 7 + ((2.5 - voltage) / 0.18); Serial.print("\tPH: "); Serial.print(Po, 3);

Serial.println(""); delay(2000); }

Using this code, i m not getting results pH 20, etc is shown in serial monitor

Hello guys, Im using the Logo_PHsensor V1.1, for a final project on my university Im having a problem, i have a box full of water and i'm trying to produce a solution to use on a hidroponic system buti have a ph probe and 2 pins conected to arduito to read de EC of the solution inside the box. My problem is, everytime i have EC reader and the Ph probe inside the water, im getting a value of PH higher and higher along the time. IF i took the EC reader of the box, it get a value completly diferent and stable. Any help?

You can't measure EC and pH at the same time in small water because the EC probe insert some small current that affect pH measurement. You have to turn EC off while taking pH measurement. Maybe you can put the two probes away from each other.

hello guys, can i get some help from you? i’m doing project ph control system, by using ph probe. this is my coding

This sample code is used to test the pH meter V1.0.

Editor : YouYou

Ver : 1.0

Product: analog pH meter

SKU : SEN0161

#define SensorPin A0 //pH meter Analog output to Arduino Analog Input 0
#define Offset 0.00 //deviation compensate
#define LED 13
#define samplingInterval 20
#define printInterval 800
#define ArrayLenth 40 //times of collection
int pHArray[ArrayLenth]; //Store the average value of the sensor feedback
int pHArrayIndex=0;
void setup(void)
Serial.println(“pH meter experiment!”); //Test the serial monitor
void loop(void)
static unsigned long samplingTime = millis();
static unsigned long printTime = millis();
static float pHValue,voltage;
if(millis()-samplingTime > samplingInterval)
voltage = avergearray(pHArray, ArrayLenth)5.0/1024;
pHValue = 3.5
if(millis() - printTime > printInterval) //Every 800 milliseconds, print a numerical, convert the state of the LED indicator
Serial.print(" pH value: ");
if(pHValue >= 7.00)
if (pHValue <= 5.50)
double avergearray(int
arr, int number){
int i;
int max,min;
double avg;
long amount=0;
Serial.println(“Error number for the array to avraging!/n”);
return 0;
if(number<5){ //less than 5, calculated directly statistics

  • }*
  • avg = amount/number;*
  • return avg;*
  • }else{*
  • if(arr[0]<arr[1]){*
  • min = arr[0];max=arr[1];*
  • }*
  • else{*
  • min=arr[1];max=arr[0];*
  • }*
  • for(i=2;i<number;i++){*
    _ if(arr*<min){_
    amount+=min; //arr<min*_
    _ min=arr*;
    }else {
    amount+=max; //arr>max*

    amount+=arr; //min<=arr<=max*

    * }

    * }//for*
    * avg = (double)amount/(number-2);

    * return avg;

    and my problem is, the output pin 7 only produce 1.5v, which cannot control the relay 5v…
    can anyone help me with it? i want that the output 7 is 5v, which can control relay…_

It seems an hardware problem or you have a pH value that oscillate around 7. In the latter case put a delay of about one second at the end of the loop and check again.

hello guys, from @LeCyb code, how should i code in order to add a second PH_step variables ? i have add the first which is the 4.01 and i want to add the 9.16. I need to measure from 4 to around 8 of PH. Thankyou ;)

You should notice that there is only approx. 2V for all 0-14 PH scale, that is not very accurate, voltage distortion about 10mV can change the overall PH value about 0,1PH

So .. main question it is possible to increase the phmeter voltage output range to 0-5V

hy im using this Logo_PHsensor v1.1 for my project but want to interface with PIC16f4550 can any1 help me out how do l do that im writting my code in microC

The code from LeCyb works great, thanks a lot! Calibration values for me were almost the same, using 17 for the step divider and 2.62 for the pH7 value gives me very accurate readings.

However the variation within the data is too big to only use single data measurements. I added a rolling average to get a proper and relatively static reading:

float water_ph = 7; // variable to store average pH
float N = 20; // do average over x measurements

// exponentially weighted moving averge
double approxRollingAverage(double avg, double new_sample) {
    avg -= avg / N;
    avg += new_sample / N;
    return avg;

void loop(){
  //.... get Po like in normal code

  water_ph = approxRollingAverage(water_ph, Po);

Hi all,

Thank you for creating this topic with so much useful information. This is the only detailed explanations for the "Logo_PHsensor v1.1" board I have found in English on the web. Thanks a lot, especially to LeCyb. Now, I know why the red LED turns on and off when I turn the pot by the pins!

That being said, I'm struggling getting my board working. When I apply 5V between V+ and G, the green LED turns on so that's good. Now, when I measure the voltage between Po and the second pin G and change the resistance of the pot by the BNC connector, I always measure 1.85V (+/- 0.04V) no matter what is connected to the BNC connector (a short, open circuit or the black pH probe). The symptom seems to be very similar to the one from rgonzo2, except the difference in voltage.

Does that mean that the board is not working correctly?



Hi and thank you all,

yes and I think:

The ‘To’ Pin is the output for compensated reference.

Just sample this and subtract ‘To’ from ‘Po’.

512 as subtractor is not correct.

Then map between -7 and +7

Add 7 only for printing (0-14).

For the LOG (pH<4 or >9) I must get a better solution for me.

My own pH module is shipped at the moment.


Thanks Joe

any one ! kindly i need to buy PH sensor and its probe ( all the things related to that) to connect it with Arduino and get PH value .

Kindly send me link from where to buy ? help me its urgent . i am from Pakistan any chinees site will be my priority as shipping takes less time .

Start with the usual suspects: Aliexpress and Taobao. I get most of my stuff off Taobao (but if you don’t know Chinese or someone that does, better try Aliexpress instead).

Or you could start with a pH probe on its own and a good FET op amp, dual preferably. Op amp needs to have very low bias current. Have a look at MAX407, an old amp, but good. Maxim do a nice application note that covers pH. Use one op amp to do the buffering and the other to do the gain. Get the amp as close to the probe as possible. From memory, each pH unit produces an output of 60-mV, temperature dependent. Output is zero at pH 7, then either + 60-mV per pH unit, or - 60-mV depending on acidity or alkalinity. With a single-sided supply (I used 3.7-V lithium) you need to offset the first amp by a simple voltage divider. You can do the temperature compensation in software or hardware using a temperature sensor. By getting the probe as close as possible (some probes have the amp in the cap of the probe), you do away with all the complexities of coax and can run the output down some old Black and Decker cable, so useful for remote applications. A half AA Lithium cell could outlast the probe lifetime (draws 2.4uA) and running on a battery does away with earth loop problems. Use the same approach for any high impedance source, including other specific ion electrodes (nitrates, fluoride etc.) as a pH probe is another specific ion electrode, specific for hydrogen ion.

hello i have also this ph sensor. please guide me how much pins of pH sensor will connect with Arduino and what's the basic Arduino code to test the pH sensor. please guide me Thanks


I am using this same shield to read from my pH sensor but this is the output I am getting ⸮⸮b⸮⸮b⸮⸮Q⸮⸮Q⸮⸮k on my serial monitor.

My code is:

define pHsensorpin A0;

float pH;

void setup() {

Serial.begin(15 000); }

void loop() {

pH= analogRead(pHsensorpin); Serial.print(pH); delay(10000); }

Any idea how to get an actual value of pH out?

Any help would be much appreciated, thank you so much!

daph: Serial.begin(15 000);

Are you sure this is your code? It won't even compile like this.

Set it to a regular value, and make sure you serial monitor is set to the same speed.

daph: Any idea how to get an actual value of pH out?

Do read the rest of this thread.

Hey. I have such a module.

And I can not put on it 2.5V with a closed BNC connector. The minimum voltage I can set "Measure: 539 Voltage: 2.63"

#include "Arduino.h"

int ph_pin = A0; //This is the pin number connected to Po

void setup() {

void loop() {
  int measure = analogRead(ph_pin);
  Serial.print("Measure: ");

  double voltage = 5 / 1024.0 * measure; //classic digital to voltage conversion
  Serial.print("\tVoltage: ");
  Serial.print(voltage, 3);

What am I doing wrong?

What do you mean with "closed BNC connector"?

What's wrong with that voltage? IIRC the output has unity gain only, so about 58 mV per pH point. You won't run off scale. Just do a calibration with your probe, and you should be good to go.

wvmarle: What do you mean with "closed BNC connector"? In this article it is said that when closing the contact for Ph 7 should be 2.5V I can not install so much. Min value: Measure: 538 Voltage: 2.627 Max value Measure: 844 Voltage: 4.121