I have this ADC board: https://www.amazon.com/ACROBOTIC-Digital-Converter-Breakout-Raspberry/dp/B06XY7572V
That has integrated thermistor and photoresistor Board connected to l2c:
Pi SDA -> Module SDA
Pi SCL -> Module SCL
Pi 3V3 -> Module VCC
Pi GND -> Module GND
Using this library to read values from the board: https://github.com/sunfounder/SunFounder_SensorKit_for_RPi2/blob/master/Python/PCF8591.py
All the jumpers are set to read values from integrated sensors:
ADC 0 - LDR
ADC 1 - NTC THERMISTOR
According to the description:
The ADC on the PCF8591 has a resolution of 8-bits, so it can read up to 4 independent signal values between 0V and Vref in increments of Vref/255. Similarly, the 8-bit DAC can generate one signal whose values range between 0V~Vref (reference voltage) in 255 steps
So I was able to read the values from all channels with this code:
for i in range(0,4):
value = PCF.read(i)*3.3/255
print('PCF %s = %1.3f',i, value)
PCF.write(PCF.read(i))
And here is an output:
PCF 0 = 2.989
PCF 1 = 3.3
PCF 2 = 3.222
PCF 3 = 1.643
Thermistor channel returns 3.3 or (255), which means the calculation below will not make sense because of division by zero:
Vr = 3.3 * 255 / 255
Rt = 10000 * Vr / (3.3 - Vr)
temp = 1/(((math.log(Rt / 10000)) / 3950) + (1 / (273.15+25)))
temp = temp - 273.15
So what I'm doing wrong and how can I convert those values into proper temperature?
Also need some help with the LDR too, not sure how to convert that voltage to the value in lux.
0? ..... what is the temperature when the reading is255? ...... then simply interpolate the temperature from readings in between those two values ..... if the temperature response curve of the sensor is non-linear, then use additional points along the curve to increase the accuracy of the reading – jsotola Feb 28 '19 at 00:38Rt = 10000 * Vr / (3.3 - Vr)and then using the result thusRt / 10000? – jsotola Feb 28 '19 at 01:59