Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Atmega328 in-built temperature sensor

Status
Not open for further replies.

Mystogan

New Member
Hello guys,
I am trying to use the in-built temp.sensor of arduino(AtMega328).
It is belived to perform around +/-10 °C accuracy.
But i am trying to get it work with as much little error as possible.I have googled and found that it can be done after an initial 'caliberation'.

I have tried the code from
https://code.google.com/p/tinkerit/wiki/SecretThermometer,

My problem is I didnt understand the code,particularly the following lines:-
// Read temperature sensor against 1.1V reference
ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3);
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = (result - 125) * 1075;

It seems like we have to adjust two parameters for caliberating the sensor.

Can someone explain how to adjust these parameters to get good accuracy and precision of readings, atleast in the room temperature ranges?(I mean around 20°C-50°C)
Also it would be great if you can explain the above mentioned lines of the code.

Thanks in advance..
 
I don't think its as unreliable as that . I thought +/-2 C
A register generally holds a word
Called one byte or 2 nibbles or 8 bits
Like 11111111 or 11011001
These values tell the chip what to do
By shifting the bits right or left you change the word and consequently what the chip does
Its pretty complex and you can do it to any register I think
To understand what your post is doing you must look to the register and see how it is set before the action and how it is set after the action
In some registers for instance changing a 0 to 1 turns on a port (say an LED attached).
_BV(????#) is a macro I think (a stored instruction set)
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top