I am trying to set up the equation to convert the analog input from the sensor into a pH value. This is my first foray into Arduino so Ii have a very basic knowledge of the system but I am wondering how to get more accurate data in from the sensor in the code and be able to calibrate it?

int ph_pin = A1; //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 / 1023.0 * measure; //classic digital to voltage conversion

Serial.print("\tVoltage: ");

Serial.print(voltage, 5);

float Offset = 3.91007; // Offset = voltage value from measurement in a 7.0 pH standard

float Po = 7 + ((Offset - voltage) / 0.18);

Serial.print("\tPH: ");

Serial.print(Po, 3);

Serial.println("");

delay(1000);

}

More Kenneth Larsen's questions See All
Similar questions and discussions