nthnn / PH4502C-Sensor

Comprehensive and easy-to-use Arduino library for PH4502C pH level and temperature sensor.
https://nthnn.github.io/PH4502C-Sensor/
MIT License
7 stars 2 forks source link

Temperature? #3

Closed chriscummings closed 11 months ago

chriscummings commented 11 months ago

Nathanne,

I'm trying to understand converting the TO pin voltage to a human readable celsius or fahrenheit. I see in your example you are calling ph4502c.read_temp(). However, when I look at that function, it seems like it just returns the straight pin value, not any sort of conversion.

int PH4502C_Sensor::read_temp() {
    return analogRead(this->_temp_pin);
}

For example, I'll just get a value of 752.00. I can't find any datasheet explaining what the equation should be for temperature.

Thank you.

nthnn commented 11 months ago

Hi Chris!

Even I can't seem to find any useful information about the sensor's temperature pin from the manufacturer or from the internet. Exact reason why I wrote read_temp() function the way it is.

However, the best way I can recommend to convert it to a meaningful temperature value is to calibrate it on the go. For instance,

int sensorValue = analogRead(sensorPin);
float temperature = map(sensorValue, 0, 1023, minTemperature, maxTemperature);

Just replace the minTemperature with the lowest temperature possible that you can get from your sensor, same with the maxTemperature for highest temperature you can get.

chriscummings commented 11 months ago

Nathanne,

Thank you for your response! 👍

I'll see if I can find the high/low temp info on the thermistor before I try to thermally test it myself.

chriscummings commented 11 months ago

Closing. Thanks again!