Image

I decided to try another schematic for measurement of the temperature this time with LM335Z low cost sensor.

LM335Z have 0V at absolute zero temperature i.e. -273.2C and it’s output increase with 10mV/C so at room temperature the sensor will output about 2.73V

to measure this temperature with Duinomite is piece of cake:

10 SETPIN 1,1  ’setup PIN(1) as analog input

20 PRINT “ROOM TEMPERATURE IS”;PIN(1)*100-273

the problem is that PIC32 Analog input can’t take more than 3.3V on it’s ADC, so maximal temperature measured will be 57C well this still is enough for some application, but why not measure the complete temperature range -40C+100C ? (if you use LM135 the range will be -55+150C)

to do this we have to add resistor ladder which to divide the output voltage, TassyJim uses 18K/27K in his project posted at TheBackShed forum, and I found his 0.6 round divider as nice so decided to use same values.

then  I wrote this simple code:

10 SETPIN 1,1

20 PRINT “ROOM TEMPERATURE IS: “; PIN(1)*166.7-273

RUN

ROOM TEMPERATURE IS: 24.5645

it’s really not so hot in my office so I start thining what is wrong and I found it – I used 5% resistors as I had no preciese resistors so the voltage divider was not exactly 0.6 but something else and was mixing my result, no problem I took preciese ohm meter and measured R2 and R3 the values are:

R2 = 17 860 ohm

R3 = 26 600 ohm

aha so the voltage divider is 0.59829! and the coefficient I have to use in the formula is 100/0.59829 = 167.1

I corrected the formula:

20 PRINT “ROOM TEMPERATURE IS: “; PIN(1)*167.1-273

RUN

ROOM TEMPERATURE IS: 23.6145

so with not preciese resistors I got preciese result because DM-BASIC have no problems to work multiply real numbers .

Advertisements