Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[AVR] Temprature sensors. LM35 vs MCP9700

Status
Not open for further replies.

stanlo45

Newbie level 4
Joined
Mar 25, 2009
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,323
Hi, I'm using Arduino R3 nano to read tempratures from 2 sensors.
A LM35 and a MCP9700.
There is quite a difference between the readings. Which sensor should I believe?
I also have a digital sensor in the room that is reading 22,6.

Sample output.
LM35 : 23.86 MCP9700 : 20.13 Temp AVG : 21.99
LM35 : 23.87 MCP9700 : 20.13 Temp AVG : 22.00
LM35 : 23.88 MCP9700 : 20.14 Temp AVG : 22.01
LM35 : 23.89 MCP9700 : 20.13 Temp AVG : 22.01
LM35 : 23.90 MCP9700 : 20.14 Temp AVG : 22.02
LM35 : 23.90 MCP9700 : 20.14 Temp AVG : 22.02
LM35 : 23.90 MCP9700 : 20.14 Temp AVG : 22.02
LM35 : 23.90 MCP9700 : 20.15 Temp AVG : 22.03
LM35 : 23.89 MCP9700 : 20.15 Temp AVG : 22.02
LM35 : 23.89 MCP9700 : 20.14 Temp AVG : 22.02
LM35 : 23.88 MCP9700 : 20.14 Temp AVG : 22.01
LM35 : 23.85 MCP9700 : 20.13 Temp AVG : 21.99
LM35 : 23.83 MCP9700 : 20.12 Temp AVG : 21.97

Thank in advance. Stan
 

I don't see why there is anything wrong between the two, they are tracking very well.

I just see a need for calibration being done on the sensor(s).
 

.... and did you compensate for the zero offset on the MCP9700? The devices are not directly interchangeable.

Brian.
 

Hi Brian,

Yes I did compensate for zero offset.

Code C - [expand]
1
2
3
4
5
// LM35
    TA[0] = TA[0] + analogRead(A0)*vREF/1024*100;
// MCP9700
    TA[1] = TA[1] + (analogRead(A1)- 500)*vREF/1024*100;
    delay(2);



Regards, Stan
 

AH yes, calibration, that's going to be challenge.
Thank you for your response. Stan
 

Hi,

my recommendation: Read the datasheets. Both datasheets specify accuracy.
At least this is the way I`d do it.

Klaus
 

Calibration is difficult for a hobbyist, but you can perform a pair of steps:

-Put some ice on a bucket, and let it slowly melt. When you have about 50/50 ice and water, that will be your 0-C point
-If you live at sea level or close to it, you can get water to start boiling, and that will be your 100-C point.
 

Code:
TA[1] = TA[1] + (analogRead(A1)- 500)*vREF/1024*100;
Are you sure that subtracting 500 is the correct value. I'm not familiar with the Arduino Nano but the final measured voltage should have around 400mV subtracted. The exact amount has to be determined as detailed above.

What vREF did you use?

Brian.
 

The other option to "calibrate" either of the parts is to use a reference like the digital sensor in the room as the "golden" reference and adjust the reading accordingly with an offset. This only has a chance of working correctly if the calculation of the reading from the sensor to a temperature is correctly done and if the sensor you use (LM or MCP) gives linear readings across its temperature range.
 

Hi Brian vREF is the internal reference voltage the arduino.
Its 1.1v on the data sheet. I measured it to be 1.097 volts.
 

I will try the ice.
I live at about 5700 feet above see level so boiling water would be around 96-98 degrees.
I though of using a medical thermometer around 35 degrees. It has a scale marked off at 0.1 degree intervals.
 

I have digital sensor from our old Computer centre, so I will compare my readings to that at the moment.
I'm not sure how accurate it is.
 

Assuming the ADC is 10-bits, with 1.097 vREF the ADC would read 373 with 400mV input.

Where does the 500 come from in your calculation?

For reference, I use MCP9701 devices extensively, they are the same temperature sensor but with an internal amplifier to align their output with typical ADC steps. I find them very accurate although I do calibrate them by adding long wires to a bundle at a time and placing them together inside a fridge at 2C for 30 minutes.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top