Problem with PH-4502C sensor calibration

Hello everyone,
I am an absolute beginner with arduino but with a little research I got the pH-sensor PH-4502C working - almost.
I used the following code to measure the pH:

#include <Arduino.h>

float resolution;                                
int measurings;
float voltage;
float pHvalue;
float b = 0.00;
float m = 0.167;

void setup()                                     
{   
  Serial.begin(9600);                            
  resolution = 1024.0;                           
                                              
  delay(100);                                   
}


void loop()                                      
{
  measurings=0;                                  
  for (int i = 0; i < 10; i++)                   
  {
    measurings = measurings + analogRead(A0);     
    delay(10);                                  
  }
    voltage = ((5 / resolution) * (measurings/10)); 
                                                   
    pHvalue = ((7 + ((2.5 - voltage) / m)))+ b;    
    
    Serial.print("pH= ");                          
    Serial.println(pHvalue);                          
    delay(1000);                                    
}

Before starting with the measurment you have to calibrate PH-4502C.
Therefore I used the following sketch:

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


void loop() 
{
 int sensorValue = analogRead(A0);
 float voltage = sensorValue * (5.0 / 1024.0);
 Serial.println(voltage);
 delay(1000);
}

You have to put the pH-electrode in a calibration liquid with pH = 7,00. Then you have to adjust the offset potentiometer of PH-4502C until P0 measures 2.5V: Arduino pH-meter using PH-4502C | Web, Mobile & IoT — CimpleO

Now my problem:
When I do this P0-reading while turning the potentiometer, sometimes the values don't go down to 2.5V. They just stop at 2.59V or something, even if I am still turning the screw.
It sounds so easy: calibrate the sensor in the way, it is set at 2.5V when pH = 7, but this simple thing doesn't work.
Does anyone know that problem? I am glad about any help. Thank you!

Your analog reading is based on the 5 volts feeding your Arduino. If the 5 volts varies any, you will get different results for your potentiometer reading. Try using a more stable power source.

Paul

Hello Paul,
Thank you for your quick reply. Can you recommend a certain power source? I should use one that also supplies 5V, I guess?

Do you or anyone else have an explanation for the fact that the voltage cannot be regulated further down?
Theoretically it should be even possible to regulate the potentiometer of the pH-Sensor in a way that it shows a voltage lower than 2.5V, shouldn't it?
But I don't even reach 2.5V, ist stays at values higher than 2.5V.

You should find these calibration notes helpful: https://tlfong01.blog/2019/04/26/ph-4502c-ph-meter-calibration-notes/

The Arduino does not measure absolute voltages. It measures voltage relative to its power supply voltage. That is never exactly 5.0 V, although your program assumes that to be the case.

You need a multimeter to measure voltages with reasonable accuracy.

You are correct that the adjustment should allow a wider range than you observe. I suspect that there is something wrong with your setup, but you have not given enough details to guess what that might be.

This pH meter produces an output that is indeed 2.5V +/- the pH reading itself (58 mV per pH point, so your effective range is just 2-3V for pH of 0-14, 20% of the ADC range, one of the reasons I don't like this board).

The problem is indeed that this is an absolute voltage - measure it with your multimeter to know the actual voltage. This should allow you to get the actual point where it reads 2.5V. When you're at it, also measure the Vcc of your Arduino, chances are it's about 4.3-4.5V, which is normal when powered over USB which is 4.9-5.1V minus a diode drop. That will give you a really hard time getting the voltage reading down.

A regular 5V supply (to the 5V pin, not RAW or Vin or even the USB socket) such as a mobile phone charger should work wonders. Otherwise a 7-9V supply on the RAW pin should give a very stable 5V inside the Arduino. Both assuming there is nothing else connected to the Arduino or the power supply itself.

Sorry for my late response. Thank you both very much for your help :slight_smile:

@jremington which details concerning the setup do you need to guess what is wrong?

I will definitely try the suggestions you made, as soon as I have a multimeter.
I hope I can ask you further questions, if necessary.

Because it was suspected, that there is something wrong with the setup, I put this here, just to be on the safe side:

I almost don't dare to ask because I'm a little bit afraid it is a very silly question, but:
How can I measure the voltage of the pH reading with a multimeter? :confused:
I think I'm able to measure the voltage which is supplied by the Arduino UNO but I have no more ideas how to measure the 2,5 V with the multimeter.
I'm especially referring to these calibration notes: ph-4502c ph meter calibration notes – tlfong01.blog
I guessed that I need to measure the voltage at A0/P0 but the multimeter always says the voltage is about 4,8 V whereas the calibration sketch tells me the values are about 2,6 V.
Thank you so much for helping me!

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


void loop() 
{
 int sensorValue = analogRead(A0);
 float voltage = sensorValue * (5.0 / 1024.0);
 Serial.println(voltage);
 delay(1000);
}

To measure the voltage output by the pH meter, connect the multimeter + lead to the pH meter output, and the multimeter - lead to the pH meter GND or 0V input.

Hi everyone,
I'm having the same problem of lisielly
When I do this P0-reading while turning the potentiometer, sometimes the values don't go down to 2.5V. They just stop at 2.59V or something, even if I am still turning the screw.

I tried using both an Arduino NANO and UNO but the P0 pin output value, turning the screw, stay between approx. 2.5-4.8 V.
In first case I thought the PH4502-C board potentiometer was broken. So I bought more boards but still the same problem.
I also tried with an external power supply, the problem remain.
Someone has found the solution?

gustr:
Hi everyone,
I'm having the same problem of lisielly
When I do this P0-reading while turning the potentiometer, sometimes the values don't go down to 2.5V. They just stop at 2.59V or something, even if I am still turning the screw.

I tried using both an Arduino NANO and UNO but the P0 pin output value, turning the screw, stay between approx. 2.5-4.8 V.
In first case I thought the PH4502-C board potentiometer was broken. So I bought more boards but still the same problem.
I also tried with an external power supply, the problem remain.
Someone has found the solution?

And what does your DVM show the voltage to be? What specific potentiometer are you using?
Paul

The DVM range has to be from 0V to 5V because:

  1. the *PH4502C *board is supplied by a 5V power supply (e.g. a standard smartphone charger)
  2. short-circuit BNC Connector
  3. connect my DV+ pole to *PH4502C *P0 pin and DV- pole to *PH4502C *GND pin

I expect, adjusting the offset potentiometer (the nearest the *PH4502C *BNC connector) to read a voltage varying from 0V to 5V but in my case is varies between 2.5V and 5V.

I tried with three different *PH4502C *board with the same results.

So I suppose to do something wrong even if I can't figure out what is wrong.

Have you studied This description of how to calibrate the board?
Paul

Yes, I also tried this guide.

The Arduino serial plot on "analogRead(PH_ANALOG_PIN)" returns an output that change (varying the POT.) between approx. 520-1022 instead of 0-1023.

gustr:
Yes, I also tried this guide.

The Arduino serial plot on "analogRead(PH_ANALOG_PIN)" returns an output that change (varying the POT.) between approx. 520-1022 instead of 0-1023.

Doesn't that match pretty close to your DVM readings?
Paul

Yes, exactly, it is in line with my DVM readings.

What I'm trying to understand is why I can't read the full P0 output range value, that is 0-5V from DVM or 0-1023 from Arduino analog pin (as described in the above mentioned guides) but only half range of values.

gustr:
Yes, exactly, it is in line with my DVM readings.

What I'm trying to understand is why I can't read the full P0 output range value, that is 0-5V from DVM or 0-1023 from Arduino analog pin (as described in the above mentioned guides) but only half range of values.

How many calibration pots are on your board?
Paul

With regular pH probes, the pH voltage output changes by about -57 mV/pH point, with the output at 0V at pH=7. Those boards add an offset of about 2.5V. The pots don't change this slope.

Using pH=4 and pH=7 calibration liquids you should find about 171 mV or 35 ADC points difference. Your reading will also change with any change in Vcc, the default ADC reference.

To overcome this problem I've built my own pH sensor boards, with a mid point of about 0.5V, so you can read it against the internal 1.1V reference for both better stability and improved range.

wvmarle:
To overcome this problem I've built my own pH sensor boards, with a mid point of about 0.5V, so you can read it against the internal 1.1V reference for both better stability and improved range.

Can you kindly explain me how did you achieved this. When and if you have little time available

It's basically an OpAmp circuit similar to this PH-4502C sensor, but using a 0.5V offset instead of a 2.5V offset.

I still have to build up the latest incarnation of this project - now full galvanic isolation (running off its own battery; communicating over opto-isolated Serial). The EC sensor based on the same trick works well. Just haven't gotten around to it.