General Gravity

Gravity PH sensor v2 interfaced with Heltec LoRa32 v3

userHead alex.lindon 2024-10-01 02:58:40 122 Views0 Replies

I need help with my Gravity PH sensor. The problem i'm facing is that i only get ph value of 6 to 7 even when i put the probe into a ph 4 buffer solution. I've done the calibration but its not doing anything, it says buffer solution 7 even though its 4. Please help, i'm super new to this 

 

this is the pin connection 

 

VCC - 5.v

gnd - gnd

data pin - GPIO 2

 

and these are my code 

 

#include "DFRobot_ESP_PH.h"

#include "EEPROM.h"


 

DFRobot_ESP_PH ph;

#define ESPADC 4096.0   // the esp Analog Digital Conversion value

#define ESPVOLTAGE 3300 // the esp voltage supply value

#define PH_PIN 2        // the esp gpio data pin number

float voltage, phValue;

const float fixedTemperature = 25.0; // constant temperature for pH calculation


 

void setup() {

  Serial.begin(115200);

  EEPROM.begin(32); // needed to permit storage of calibration value in eeprom

  ph.begin();


 

  // Calibration configuration

  ph.calibration(0.78, 7.0);  // voltage value for pH 7 solution

  ph.calibration(1.036, 4.0); // voltage value for pH 4 solution

}


 

void loop() {

  static unsigned long timepoint = millis();

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

  {

    timepoint = millis();

    // Read raw analog value from the pH sensor

    int rawPinValue = analogRead(PH_PIN);

    Serial.print("Raw Pin Value: ");

    Serial.println(rawPinValue);


 

    // Convert raw pin value to voltage

    voltage = rawPinValue / ESPADC * ESPVOLTAGE;

    Serial.print("Voltage: ");

    Serial.println(voltage, 4);


 

    // Convert voltage to pH value with a fixed temperature

    phValue = ph.readPH(voltage, fixedTemperature);

    Serial.print("pH: ");

    Serial.println(phValue, 4);

  }

  delay(2000); // Delay for 2 seconds (2000 milliseconds)

}