Ph sensor inverted?

i'm using a ph sensor (SKU__SEN0161 from dfrobot) and when the ph value should be raising, it is going down. i tried different methods for the voltage to ph conversion and they all gie the same

code:

#include "DFRobot_PH.h"
#include "DFRobot_EC.h"
#include <EEPROM.h>

#include "DFRobot_PH.h"
#include <EEPROM.h>

#define PH_PIN A1
float voltage,phValue,temperature = 25;
DFRobot_PH ph;

void setup()
{
    Serial.begin(115200);  
    ph.begin();
}

void loop()
{
    static unsigned long timepoint = millis();
    if(millis()-timepoint>1000U){                  //time interval: 1s
        timepoint = millis();
        //temperature = readTemperature();         // read your temperature sensor to execute temperature compensation
        voltage = analogRead(PH_PIN)/1024.0*5000;  // read the voltage
        phValue = ph.readPH(voltage,temperature);  // convert voltage to pH with temperature compensation
        Serial.print("temperature:");
        Serial.print(temperature,1);
        Serial.print("^C  pH:");
        Serial.println(phValue);
    }
    ph.calibration(voltage,temperature);           // calibration process by Serail CMD
}

float readTemperature()
{
  //add your code here to get the temperature from your temperature sensor
}

Try measuring the voltage directly with a voltmeter (e.g. DMM). This si to establish that the voltage going to your Arduino is doing the right thing (or not).

I'm unsure about the order in which this would be processed. Anyway its not clear.
voltage = (analogRead(PH_PIN)/1024.0) * 5000 - or -
voltage = analogRead(PH_PIN)/(1024.0 * 5000)

I'd suggest
voltage = analogRead(PH_PIN) * 5.0 / 1024.0;
voltage *= 1000; //to get millivolts

and serial print voltage to see what values you are actually reading.

What if an increasing voltage actually means that the PH is decreasing?

Are you washing the sensor in de-ionized water. each time, before inserting it in the solution?

sorry for the late answer, i do wash it with deionized water

sorry for late answer, this is what's actually happening but i don't know how to get the correct value increasement/decreasement

Agree with @johnerrington on the calculation. It's not clear in what order the computation will be carried out. However, it looks like the code is from the DFRobot example for the pH sensor.

@gocaca , You don't say if you've carried out the calibration process. Looking at the library on github, there are values that are stored in EEPROM as part of the cal process.

The output from a conventional pH electrode has a negative slope when you measure millivolts out against pH value.
The output is roughly 60-mV per pH unit.
At pH 7 the output is zero millivolts.
So at pH 0, strong acid, you should get about +0.4 volts, and at pH 14, strong alkali, about -0.4 volts.
To get this into an analogue input, an operational amplifier for high impedance outputs is used.
Ideally, this will follow the electrode output.
Two thing you could do.
Use a DMM and some known acid and alkali solutions to check your modules outputs. Use something like sodium hydroxide and hydrochloric acid. The module should have offset built in to bring the bipolar raw pH electrode output into a range suitable for the board you are using.
Make up a simple voltage divider with a battery.
Check what your Arduino is reading.

I did follow the calibration process with two solution, it does calibrate for the 4 ph solution but when I put the probe in the 7 ph solution the values goes to 1 instead of 7

1 Like

Thank you I will try that when I can

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.