So I've build a pH amplifier circuit which gives a reading of 0V to 3.148V (0 - 14 pH) in 0.02pH per step.
How do I now interface this to the Arduino. I know I need to use the AnalogueRead function but how do I cater for the value being from 0 to 3.148V ( and not 0-5V)
At 1.574V it should display a pH of 7.
To get better resolution you can connect the 3.3V pin to the Aref pin and in setup() write:
analogReference(EXTERNAL);
Then the 0-1024 input range maps to 0-3.3V:
float voltage = (analogRead(pin) * 3.3) / 1024.0;
Thanks - I"ll try that. I found a few references and came up with this:
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
Serial.print("pH:");
float ph = voltage * (14.000 / 3.148);
Serial.println(ph);
delay(1000);
}