A very simple project
This simple project measures temperatures and writes date, time and temperature to the PC
The sensor is the National SemiConductor LM35, a three terminal device with an analogue output of 10mV/°C
Connecting the LM35 is simple, connect the Vs to pin 29, Gnd to pin 0 and Vout to pin 20.
Make pin 20 an anaolgue input in the code and simply measure Vout from the LM35.
I measure the voltage as a floating point variable which needs to be multiplied by 3.3 to give the input in volts then by 100 to give a temperature in °C
Most of my code is taken up with setting the clock, soemthing which will become redundant once I get my battery backup working.
The only two lines that count are
AnalogIn ain(p20);
temp = ain.read() *330 ;
2 comments
You need to log in to post a comment
Tried this and it works great! You'll need to put a 1uF capacitor on your supply line though, as the ripple of powering it from USB can cause some seriously unstable results.
My temperature graph can be found here: http://timetric.com/series/01o0bfLGTgywBcYiCqxJ8Q/
In addition, it seems as though the setup I have measures temperatures about 5-6'c higher than they actually are. This seems to be down to the LM35 producing a voltage too high (0.33v at 24'c). I will investigate further.