Help with Ph sensor pin abbreviations

same here, i can't using that module to arduino,

hi, i found solution, Po is ADC output for interfacing to analog input arduino, but the problem is went PH water is low ADC output from Po is high value, and wen PH water is high ADC output from Po is low, how to reverse this in float code?

Do you mean this:-

// pHRead.ino

// Constants:-
const byte pHpin = A0;    // Connect the sensor's Po output to analogue pin 0.

// Variables:-
float Po;

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

void loop()
{
    Po = 1023 - analogRead(pHpin);  // Read and reverse the analogue input value from the pH sensor.
    Po = map(Po, 0, 1023, 0, 14);   // Map the '0 to 1023' result to '0 to 14'.
    Serial.println(Po);             // Print the result in the serial monitor.
    delay(1000);                    // Take 1 reading per second.
}

Reverses the analog pin input reading from '1023 to 0' to '0 to 1023', maps it between 0 and 14, then prints it to the serial monitor.
An input of 511 is neutral and will return 7.

Edit: I should add that when writing this I was assuming that the range of the pH sensor is 14. I'm fairly sure that's right.
(And I made a silly mistake at first, but all fixed now. :slight_smile: )

OldSteve:
Do you mean this:-

// pHRead.ino

// Constants:-
const byte pHpin = A0;    // Connect the sensor's Po output to analogue pin 0.

// Variables:-
float Po;

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

void loop()
{
    Po = 1023 - analogRead(pHpin);  // Read and reverse the analogue input value from the pH sensor.
    Po = map(Po, 0, 1023, 0, 14);  // Map the '0 to 1023' result to '0 to 14'.
    Serial.println(Po);            // Print the result in the serial monitor.
    delay(1000);                    // Take 1 reading per second.
}



Reverses the analog pin input reading from '1023 to 0' to '0 to 1023', maps it between 0 and 14, then prints it to the serial monitor.
An input of 511 is neutral and will return 7.

Edit: I should add that when writing this I was assuming that the range of the pH sensor is 14. I'm fairly sure that's right.
(And I made a silly mistake at first, but all fixed now. :) )

Thank you sir very much, i'll try now...

i got problem, went analog read 450-476-480, ph is just got 7.00

ayafsay:
i got problem, went analog read 450-476-480, ph is just got 7.00

Sorry about that. I just realised that 'map()' will not generate fractions. I only tested inputs of 0, 1023 and 511, so it looked OK.

Instead, try this:-

// pHRead.ino

// Constants:-
const byte pHpin = A0;    // Connect the sensor's Po output to analogue pin 0.

// Variables:-
float Po;

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

void loop()
{
    Po = (1023 - analogRead(pHpin)) / 73.07;   // Read and reverse the analogue input value from the pH sensor then scale 0-14.
    Serial.println(Po, 2);                    // Print the result in the serial monitor.
    delay(1000);                              // Take 1 reading per second.
}

Thank again @OLDStave, i'll try now...

ayafsay:
Thank again @OLDStave, i'll try now...

Glad to help. Let me know how you go. This version should be much better.

And now if I ever get one of those pH modules, I'll know how to use it. :smiley:

Hi all,

First of all, I'm only speaking about the board labelled "www.auto-crtl.com" and "Logo_PHsensor v1.1". The one with only 6 pins in front of the BNC plug (not on the side) as you can see in image Pinout1.jpg.

I also bought this little board from China and it is difficult to make it working. Most topics are related to other boards (Atlas, Sparkfun, Sparky's Widgets, etc.) and nothing is working. And when the subject is speaking about the correct card, the information is incorrect or computation are made with random numbers coming from the sky.

Some words are in italic to avoid "experts" saying it's incorrect (because it is incorrect) but for our small projects and for understanding I intentionaly use those "simple" terms.


General info about pH to know

The pH is a value between 0 (acid) and 14 (basic) with a neutral value of 7.

The curve (log10) of the pH is a mix between linear and exponential as you can see in pH_curve.png. It means that you can almost measure a linear value between 4 and 9 pH. Less than 2 and more than 12 is almost impossible to determine something (too acid or too basic).

The probe is like a (tiny) battery when placed in a liquid. Depending the pH it output a positive or negative voltage of a couple of millivolts. This value is too small and other tech stuff like impedance make it unusable directly with an Arduino that's why you need an "op amp". The op amp board just convert the millivolts of the probe into to something acceptable for Arduino (positive between 0 and 5v).

There are 3 common buffer solutions used for pH measurement: pH 4.01, pH 6.86 and pH 9.18 (7.0 and 10.0 exists). I suggest the powder instead the liquid because it's cheaper, expire after longer and the powder can't be contamined (vs bottle). You should read the product instructions but usually you have to put the content of the bag into 250ml of water and stir. You can use any water with an average pH (6-8) because the powder will saturate the water at the correct pH level. I personnaly use tap water (pH 7.4) and didn't see any difference between distilled, osmosed and demineralized water. Buffers are not stable in the time, this means that you cannot keep the solution for weeks or months.


Board description

  • BNC plug: Where you put the probe. It seems to work with any probe with a calibration difference. I tested 3 models (cheap blue, cheap black and a short black from a EC+pH kit).
  • Pin To: Should be the temperature but I can't make it works.
  • Pin Do: High/Low 3.3v adjustable limit.
  • Pin G/GND: Probe ground. It is useful when the ground is not the same as your Arduino. In some circumstances the ground voltage of the liquid to measure can be different.
  • Pin G/GND: Power ground (direct from Arduino).
  • Pin V+/VCC: Input power 5V DC (direct from Arduino).
  • Blue potentiometer close to BNC: pH offset.
  • Blue potentiometer close to pins: limit adjustment.
  • Black component with 103 printed (not the one between potentiometers): thermistor for temperature compensation.

"Calibration"

A single word for many things because in our case there are 2 different calibrations. The "offset" value and the "step" value.

  • The offset.
    The offset is the shifting of all pH values to a specific voltage range. If a pH 7 output a voltage of 2.2v and pH 8 a voltage of 2.1v, then a shift of +0.3v move the pH 7 to 2.5v and the pH 8 to 2.4v. This can be done on the board or via software but it's probably easyer on the board because it's probe independant and there are less programming to do.

Connect GND (both) and Vcc to Arduino GND and 5v. Remove the probe and do a short circuit between the the small BNC hole and the external part of BNC. Put a voltmeter (or Arduino) to measure the voltage between GND and Po. Adjust the pot (close BNC) until the output is 2.5v. Now the pH 7 have an exact value of 2.5v (511 with analogRead function) because the probe will output 0 millivolt.

  • The steps.
    Now you need one or more buffer solutions depending the range and precision you want. Ideally you should know the range of the measure you want to do with your system. I use water between pH 5 and pH 7, then I choose the buffer 4.01 (and 6.86 to verify my stuff). If you usually measure pH between 8 and 10 choose buffer 9.18 (eventually 6.86 also).
    Connect the (clean) probe and put it in the buffer then let it stabilize for a minute. You know it's stable when it goes up and down (3.04 then 3.05 then 3.03 then 3.04) .Take note of the voltmeter (or Arduino) value, in my example it's 3.05v.

That's all, now you can use it with the code below.


The code

The PH_step calculation is quite simple. You take the difference between the two known voltage, in my example 2.5v@pH7 and 3.05v@pH4.01 which is -0.55v. It's the voltage range equivalent of the pH range from 7 to 4.01, which is 2.99 pH units. A small division of the voltage by pH units gives you a volts per pH number (0,1839... in my case).

The PH_probe is calculated by taking the known pH 7 voltage (2.5v) where we add some PH_step to match the probe voltage. This means that a pH of 8 have a voltage value of 2.5v (pH 7) + 0.1839 (1 unit/step); pH 9 then is 2.5v + 0.1839 + 0.1839 = 2.87v.

No magic number, no ridiculous stuff, just maths :).

If you need under and over pH 7, I suggest you have two PH_step variables. One for the lower part (use buffer 4.01) and another for the upper part (use buffer 9.16). The probe is almost linear but far from perfect and you can have a side more linear than the other.

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);
}

pH limit (Do pin)
You can adjust the pot close to the pins to adapt a pH limit. If the limit is reached, a red led on the board (near the green one) switch on/off and the Do pin pass from 3.65v to 0.77v. This can be used as HIGH or LOW values with the digitalRead() function or any other interrupt.


Temperature
The To pin should do something about temperature but I'm not mastering LM358 op amp stuff. The thermistor should adjust the pH value but didn't notice any remarkable change (liquid = 20°C, thermistor = 50°C). Anyway, at normal (18-25°C) temperature there is no pH difference with temperature compensation for a hobby purpose. For a simple aquarium you need pH between 6.5 and 7.5, then a measure variation of 0.1 or 0.2 is fine.

Pinout 1.jpg

Can I get a step by step how to hook this sensor up, Mine does not seem to work. I tried adjusting the voltage and it doesn't move from 2.46v.

@rgonzo2: Hook your voltmeter "V+" to module "V+" and "V-" to "Po" on the module. Adjust with the pot near the BNC connector.

Hi there,

I bought a ph & temperature shield (E-201-C) from lei-ci.com, for arduino from china and i couldn't find the schematic online.
The leads coming out have the following symbols: T2, T1, Po, Gnd, Gnd, Vcc
What do they stand for?
I Need help to conect to Mega 2560 or Uno r3 shield.
Tal for help.

Compre un sensor de PH y temperatura con placa E-201-C desde lei-ci.com.
No puedo encontrar el esquema eléctrico de la placa que tiene 6 pines en el lateral.
necesito ayuda para poder conectar a placa Mega 2560 o UNO R3.

MUCHAS GRACIAS

@JoseAngelRet: Scroll to the description here Arduino PH Meter Board Only

@LeCyb
Great info. But, I found that I get one value with the BNC shorted and a different value with a probe in 7.0 solution. In short I just measured my raw input in 7.0 solution and then the raw input in a 4.01 solution and mapped the outputs..
Yes, it's a linear map not log, but that should be close enough for me.

765 and 665 are the analog reads in 4.01 and 7.01 solutions.

void loop() {
     float mappedv = mapfloat(analogRead(0), 765, 665, 4.01, 7.01);   // Map the '0 to 1023' result to '0 to 14'.
     Serial.println(mappedv);
     delay(100);
}

float mapfloat(long x, long in_min, long in_max, long out_min, long out_max){
 return (float)(x - in_min) * (out_max - out_min) / (float)(in_max - in_min) + out_min;
}

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)
{
pinMode(LED,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
Serial.begin(9600);
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)
{
pHArray[pHArrayIndex++]=analogRead(SensorPin);
if(pHArrayIndex==ArrayLenth)pHArrayIndex=0;
voltage = avergearray(pHArray, ArrayLenth)5.0/1024;
pHValue = 3.5
voltage+Offset;
samplingTime=millis();
}
if(millis() - printTime > printInterval) //Every 800 milliseconds, print a numerical, convert the state of the LED indicator
{
Serial.print("Voltage:");
Serial.print(voltage,2);
Serial.print(" pH value: ");
Serial.println(pHValue,2);
digitalWrite(LED,digitalRead(LED)^1);
printTime=millis();
}
if(pHValue >= 7.00)
{
digitalWrite(7,HIGH);
}
if (pHValue <= 5.50)
{
digitalWrite(8,HIGH);
}
else
{
digitalWrite(7,LOW);
digitalWrite(8,LOW);
}
}
double avergearray(int
arr, int number){
int i;
int max,min;
double avg;
long amount=0;
if(number<=0){
Serial.println("Error number for the array to avraging!/n");
return 0;
}
if(number<5){ //less than 5, calculated directly statistics
for(i=0;i<number;i++){
amount+=arr*;*

  • }*
  • 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 {
    if(arr>max){
    amount+=max; //arr>max*

    max=arr*;
    }else{
    amount+=arr; //min<=arr<=max*

    * }
    }//if*

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

    * 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 :wink: