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:

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):
print('PCF %s = %1.3f',i, value)
``````

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.

• you have not provided enough information .... what is the temperature when the reading is `0`? ..... what is the temperature when the reading is `255`? ...... 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 Feb 28 '19 at 0:38
• where did you get the equations? ..... it is pointless to calculate the first one Feb 28 '19 at 0:43
• @jsotola that code was from example here: sunfounder.com/learn/… I was using SundFounder github library to Read PCF values and decided that their code will work also.In their example that equations was like this Vr = 5 * float(analogVal) / 255 according to the input voltage and the result I'm getting from the sensor, it will be similar to 3.3 * 255 / 255, right?
– Woof
Feb 28 '19 at 0:47
• couple of things leap out ..... (1) you are using a voltage divider, which means that the output range will start somewhere above 0V and end somewhere below 5V, unless there is a component failure ......... (2) the person that wrote the example program did not really think about all the details ... what is the point of evaluating `Rt = 10000 * Vr / (3.3 - Vr)` and then using the result thus `Rt / 10000`? Feb 28 '19 at 1:59
• @jsotola could you please propose some solution to make this thing work with the components I have? Or some good links I can read about it
– Woof
Feb 28 '19 at 2:19