TroubleshootingArduino

pH sensor V2 returns nan for pHValue

userHead Zappie 2022-10-19 05:04:09 1215 Views2 Replies

After connecting the pH sensor V2, the pHvalue is given as nan.

The voltage however is measured and responds to different solutions. 

 

I downloaded the library directly from the library manager in arduino.

I have tried clearing the EEPROM using this code, but to no avail.

 

#include <EEPROM.h>

#define KVALUEADDR 0x0A

void setup(){

for(byte i = 0;i< 8; i++ ){

EEPROM.write(KVALUEADDR+i, 0xFF);

}

}

void loop(){

}

2023-02-01 14:12:35

Hi

Could you please share a screenshot of your serial monitor?

It seems that the module is working fine, but there is something wrong within the pH.readPH function.

if you can kindly provide the value of the voltage while measuring, I can diagnose the problem

Hope it can help you.

userHeadPic Tonny12138
2022-10-19 05:10:08

Sorry here is the code; i let arduino ignore the lines that are used when a temperature sensor is added.

 

//PH Sensor (SKU:SEN0161-V2)

#include "DFRobot_PH.h"

#include <EEPROM.h>

#define PH_PIN A1

float voltage,phValue,temperature = 25;

DFRobot_PH ph;

 

//Temperature sensor (LM35)

//const int lm35_pin = 20;         //* LM35 pin

//int LM_Temperature_sensor_read;

 

void setup()

{

Serial.begin(115200);

//Ph Sensor.  

  ph.begin();

 

// LM35 Sensor.

 //pinMode(lm35_pin, INPUT);  

}

 

void loop()

{

    static unsigned long timepoint = millis();

    if(millis()-timepoint>1000U)                          //time interval: 1s

    {

      timepoint = millis();

      voltage = analogRead(PH_PIN)/1024.0*5000;        // read the voltage

      //LM_Temperature_sensor_read = analogRead(lm35_pin);

     // temperature = (LM_Temperature_sensor_read*0.488);   // read your temperature sensor to execute temperature compensation

      phValue = ph.readPH(voltage,temperature);        // convert voltage to pH with temperature compensation

      Serial.print("temperature:");

      Serial.print(temperature,1);

      Serial.print(" C  ");

      Serial.print("voltage: ");

      Serial.print(voltage,2);

      Serial.print("  pH:");

      Serial.println(phValue,3);

    }

    ph.calibration(voltage,temperature);               // calibration process by Serail CMD

}

userHeadPic Zappie