## Simple Digital Thermometer

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

JohnCrow
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 720 times
Contact:

### Simple Digital Thermometer

Simple Digital Thermometer

Introduction

My earlier temperature projects have all used the LM35 device.
This is a 3 pin device in either a TO-92 or TO-202 style package.

The device comes in a few different accuracies, but all operate with the same basic 10 mV/°C output.

The main problem with the LM35 is it only reads positive temperatures
(without external signal conditioning circuitry.)

This project uses the LM335 type device.
It comes in the same TO-92 package, but it has an output of 10mV/K
This allows it to read negative temperatures.
The device selected here reads from -40°C to 100°C (233.15K to 373.15K)

K = Kelvin
This is the absolute thermodynamic temperature scale, where 0K = absolute zero = -273.15°C
It is not referred to as degrees Kelvin, as in degrees Celsius, but just Kelvin.

Therefore
0°C = 273.15 K
100°C = 373.15 K

The output from the device is converted to temperature as follows
Remember to use the floating point calculations in Flowcode and not the standard mathematical operators.

Temp = fmul ( ADC_Voltage, 100)

Now convert to °C from Kelvin
Temp2 = fsub( Temp , 273.15)

Example ADC Voltage = 2.1115 V
Temp = 2.9818 * 100
Temp = 298.18

Temp2 = Temp - 273.15
Temp2 = 298.18 - 273.15
Temp2 = 25.03
Temp2 is then converted to a string to be displayed on the LCD

Equipment :

EB-006 Programmer with PIC 16F877A
EB-005 LCD Display
EB-016 Prototype Board

LM335Z Temperature Sensor - Connected to ADC5 (Port E Bit 0)
10k-ohm Preset Pot (Multi Turn preferred)
1k8 Resistor

The 10k-ohm pot is used to calibrated the sensor. It is adjusted until the display shows the ambient temperature in the room measured as close to the LM335 as possible.
Once set is should not need to be adjusted again.

LM335.jpg (119.01 KiB) Viewed 5144 times

Circuit.jpg (39.96 KiB) Viewed 5143 times

LM335Z Local Temperature Display-PortE.fcf
These users thanked the author JohnCrow for the post (total 4):
kersing (Sun May 20, 2012 10:23 am) • medelec35 (Sun May 20, 2012 10:26 am) • jgu1 (Sun May 20, 2012 5:58 pm) • mauro (Fri Jun 01, 2012 1:43 pm)
Rating: 20%

1 in 10 people understand binary, the other one doesn't !

medelec35
Valued Contributor
Posts: 8816
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2559 times
Been thanked: 3715 times
Contact:

### Re: Simple Digital Thermometer

Hi John
This will be handy in a quiet a few applications

Thanks for sharing.

Martin
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

JohnCrow
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 720 times
Contact:

### Re: Simple Digital Thermometer

To simplfy the circuit even more the variable resistor can be left out and the adj pin left unconnected.
The output is then taken between the 1k8 resistor and the V+ connection on the device.
1 in 10 people understand binary, the other one doesn't !

kersing
Valued Contributor
Posts: 1930
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 568 times
Been thanked: 1078 times
Contact:

### Re: Simple Digital Thermometer

Hi John,

In your experience, what is the best device for calibration? I've tried digital thermometers but after having three of them within a couple of centimeters and all showing different temperatures (1.8 degree centigrade between highest and lowest) I've got reservations about using them as a reference.

Regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

JohnCrow
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 720 times
Contact:

### Re: Simple Digital Thermometer

Hi Jac
My thoughts on these semiconductor temperature sensors.

The LM35 can normally be between 0.5°C and 1.5°C depending on which version you are using.
Dont think any are highly accurate. If you look at my Touch Screen Temp Monitor, im using 4 LM35's in that one and they are all reading the same. I have the sensors in a matix protoboard, so they are all fairly close together.

Ive only just started to look at the LM335 device. Having the trim pot does seem to make it more accurate. Not tried seeing how it changes over a range. Want to wait till I can leave it in the sun for a while (quite a rare thing in England at the moment ) after setting it at about 20°C and compare it to an accurate thermometer.
Have just tried freezer spray and took it down to -40°C,although no way of knowing how accurate this is.

Even the LM335 only claims 0.5°C accuracy though.

Other options are the DS18S20 one wire bus device, or another device I have used in the past is the AD594/595 thermocouple amplifier, which gives a direct linear dc output from a thermopcouple, but again I seem to remember these dont allow negative temperatures.

They all work fairly well, just depends how much accuracy you need for you application. If you need more than 1 device you may need to select on test to get a couple of devices to read the same.
1 in 10 people understand binary, the other one doesn't !

jgu1
Posts: 1176
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1102 times
Been thanked: 294 times
Contact:

### Re: Simple Digital Thermometer

Hi John!

Another good project from you. Nice of you to share with us.

Regard

Jorgen.
These users thanked the author jgu1 for the post:
JohnCrow (Sun May 20, 2012 6:17 pm)
Rating: 5%

jgu1
Posts: 1176
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1102 times
Been thanked: 294 times
Contact:

### Re: Simple Digital Thermometer

Hi John!
A question!

I have now tried to make your fine project with lm 335 but only with a potentiometer. I can see, depending on the voltage of the analog input, skips the decimals after the decimal between 0 and 3 decimal places. Is it not possible to keep it constant at 1 or 2 decimal places. If, how do you do it.

Jorgen.

JohnCrow
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 720 times
Contact:

### Re: Simple Digital Thermometer

Hi Jorgen

Is it not possible to keep it constant at 1 or 2 decimal places. If, how do you do it.

It is posible to fix the length of the decimals when converting a float to string for printing. See this thread.
It does need you to edit one of the flowcode files, so for this application Im happy with it changing between 2 & 3 places of decimals depending on how many digits are in the integer part. (Think it was set to a string length of 5 places)

viewtopic.php?f=29&t=8373&p=24361&hilit=string+length#p24361

I have now tried to make your fine project with lm 335 but only with a potentiometer

Do you mean you are not using the 1k8 resistor in the 5V line? Not sure what effect that will have on the operation.
These users thanked the author JohnCrow for the post:
jgu1 (Fri Jun 01, 2012 9:50 am)
Rating: 5%

1 in 10 people understand binary, the other one doesn't !

jgu1
Posts: 1176
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1102 times
Been thanked: 294 times
Contact:

### Re: Simple Digital Thermometer

Hi John!

I will look at it,thank´s

Concerning the potentimeter. It was insted of LM335 the analog input. I am waiting for a LM335.

Regard

Jorgen

JohnCrow
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 720 times
Contact:

### Re: Simple Digital Thermometer

Ahh Ok I see what you mean now.
1 in 10 people understand binary, the other one doesn't !