Go Down

Topic: Temperature sensor (Read 5370 times) previous topic - next topic


Nov 30, 2009, 10:26 pm Last Edit: Nov 30, 2009, 10:39 pm by carl47 Reason: 1
I am making a weather station using Arduino 2009.
The Arduino adc has 10 bits as do most of the digital sensors.
My indoor temperature range is 0 to 40 C. Using the full range of
the adc the best accuracy I could get is 0.04 C per binary step.

There are many temperature sensors on the market:


The digital output devices all have a LM335 type device a dc amplifier,
a adc converter and then a serial transmit circuit.
The format of the serial data can be the Dallas Semiconductor 1-Wire or I2C or SPI.

The AD7416 is only a few dollars and has a 0.25 C per binary step and is at:


Looking now at the old standby the Lm335 is at:


If I connect the LM335 output to an analog input and use the 5.0v internal AREF
the following will occur:

0.5C per binary step

If I set AREF to 3.3v and include in code         analogReference(EXTERNAL);
the following will occur:

0.3C per binary step

We are not getting the accuracy because the Lm335 voltage swing is only a
small proportion of the adc operating range.
We need a dc amplifier. One device has it incorporated. The AD22103 is at:


We now get this result:

0.1C per binary step

This is getting close but we cant have negative temperatures.
My outdoor temperature range is to be -10 to 50 C.
I decided that the best answer for my requirements was to use a LM335 and
a seperate dc amplifier.

The amplifier needs to be single supply and have a large % voltage swing.
You do need a larger regulated voltage. I power my arduino with 9v so I used
that supply and then divided down to give me the full 0 to 5v swing.

I chose the LM3900. Application notes are at:


We now get this result:

0.04C per binary step

The sensor circuit and other files are at the site given below.
Download LM335.zip


Code: [Select]
/*  A simple temperature sensor check program
   The circuit uses one point calibration.
   Adjust the pot to give the known ambient temperature.

const int analogpin = 0;  // Analog input pin

void setup()
 Serial.begin(9600);   // initialize serial communications at 9600 bps:

void loop()
 int adcvalue = analogRead(analogpin);    // read the analog in value:            
 Serial.print("sensor = " );                        
 Serial.print(adcvalue);    // print the adc value to the serial monitor:
 double temp = adcvalue / 25.6;  //convert it to Celsius
 Serial.print("\t temp = ");      
 Serial.println(temp);   // print the temperature
 delay(1000);   // wait 1 second before next sample                    


Nov 30, 2009, 10:43 pm Last Edit: Dec 01, 2009, 03:56 am by tytower Reason: 1
I had to go to the digital DS18B20 [thanks] sensor to get accurate results .
Analog sensors seemed accurate but when you looked hard they fell down . Whether you run from usb or battery is important . The usb voltage in on mine was 4.68V so adc  was mapped to 0 to 4680 rather than 0 to 5000. But then when you went to battery it all changed and your conversions were out again.

I established that accuracy could be +-2 C with analog devices . Hence the shift to Dallas and OneWire


I guess tytower meant DS18B20 from Maxim.  ;)



Thanks...you are right about the USB supply.
Not only is it variable it carries digital noise. It is clean enough
for digital but has too much noise for analog circuitry.

At the RMIT university they use a Atmel board for student projects.


You can see that they use L-C filters for Vcc and another for the Aref.

I have my Arduino setup as a remote monitor. It runs from a
regulated 9v supply.
When connected to the computer with USB it will
still be using that supply.
At their core all digital sensors have an analog sensor. They will
have a very stable adc. As long as the arduino adc is stable(with stable Vcc)
a LM335 can be just as good.

I have been comparing my logged data over a couple of weeks with my
Oregon weather station. There is very close agreement - not scientific
I know but I'm not commercial It's just for myself.

The DS18B20 can be set to 12 bit adc so that it can give:

0.0625 C per binary step

So it will work as well as my circuit.


If anyone has tried this circuit for a  temperature sensor, some feedback would be appreciated.


Which circuit are you referring to?.

Is the RMIT board available for purchase?.


I am using the DS18B20 in my project. Works fine and the 1-wire interface is pretty handy.



Which circuit are you referring to?.

Thats my circuit for the lm335 with a dc amp.
I'm happy with it, but if any one tries the circuit and has a different result I would like to hear about it.

The RMIT board is at:


1-wire interface is pretty handy.

I know it is a really good system.
It does lock you in once you use it. I would like the freedom of using
whatever weather device I choose.

Thanks for your replies.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131