Have you actually measured the voltage the LM35 is outputting with a multimeter? I would trust the LM35 far more than the ATmega's ADC to go completely down to 0 V.
From the graph you included, it looks like something is hitting a rail somewhere.
If it is indeed the LM35 outputting the errant voltages, try a pulldown (~50 kilohm?) on the output to ground (or better yet, -5 V).
You're measuring a very small voltage with the built-in ADC - 20 °C is only 200 mV. Furthermore, without a negative power rail, the sensor is only really good to 2 °C, and any bias current on the output (from the ADC) will probably affect the readings you get.
You don't limit what the sensor sees. The sensor reports what it sees. Your question is kind of like asking "I'm only interested in hot women. How can I adjust my eyes to not see ugly women?" You have no control over what the sensor sees.
Similarly, the ADC resolution (and sensor accuracy/resolution) will determine how fine-grained your temperature readings are, and how accurate they are. Generally this is never an issue unless you are specifically trying to save code or data space by looking only at 8 bits, for instance. Even in that case, you can always just read the upper 8 bits of the ADC (effectively making it an 8-bit ADC).
If you really feel you need to limit the range coming into the ADC, you can use an op-amp to shift and amplify the sensor signal so that 70-90 fits into 0-5 instead of the normal -55-150, but that's almost always not what you want to do because it's actually quite difficult to scale analog values without introducing noise or offsets.
It sounds like what you're after is something like this:
main_loop()
{
while(1) {
int temp;
temp = read_temp();
if (temp >= 85) {
turn_fan_on();
} else if (temp <= 80) {
turn_fan_off();
}
};
}
You should add some code in there to only process that loop every second or so, and maybe check for out of range values to trigger an LED or something so you are informed when the sensor is detecting a bad condition. Maybe another check which reports a probable fan failure if the temp is above 95?
Sounds like a fun little project to get started with these concepts. Good luck!
Best Answer
I think there are sensors like this on the market, but probably sold as industrial devices (not integrated circuits) and they may be a lot more expensive than LM34 integrated circuit.
Sure.
You can use operational amplifier in non-inverting configuration to amplify your voltage by 10. It's very simple to build.
Image from Wikipedia:
$$ V_{\text{out}} = \left(1 + \frac{ R_{\text{2}} }{ R_{\text{1}} } \right) V_{\text{in}}\!\ $$
You can use 2k\$\Omega\$ (R1) and 18k\$\Omega\$ (R2) resistors to get gain x10. Use 1% tolerance resistors if your measurement acurracy is important.
LM34 with x10 amplifier connected to output is good idea.
Probably (it depends on voltage range you need) you can use LM358 amplifier.
Edited:
It's low cost
rail-to-railamplifier that can work at input and output voltage = 0V, perfect for applications like this. Not all operational amplifiers can do that.