Thursday, March 8, 2012

A simple Arduino based Temperature logger System

LM35 are cheap yet accurate temperature Sensor from National instruments whose output voltage is linearly proportional to the Fahrenheit temperature. Its outputs 10mV for each degree rise in temperature (in Fahrenheit scale). The Arduino will measure the voltage input from the LM35 (Connected to Analog Pin 0 of the Arduino) and convert it to temperature reading in Celsius from the voltage measured and output the result to the serial port.

The connection of the Arduino with the LM35 temperature sensor is as given below ...

My arrangement on a Breadboard ...

After completing the connection on a breadboard , I build the code and uploaded it into the arduino board's microcontroller's program memory , which would be continuously read the sensor value and send the recorded values to the serial port of the computer.

In order to calculate the Celsius reading from the analog value, we use the following formula to calculate the temperature in Celsius


Val = is the value send to the computer by the serial port
tempC= is the calculated temperature value (in Celsius)
5 is the reference we are using
1024 is the resolution of the 10 bit internal ADC of the Arduino Microcontroller (ATMEGA328)

The Arduino Code :

float tempC;
 int Sensor = 0;

 void setup() {
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
 void loop()
float val = analogRead(Sensor); //read the value from the sensor tempC = (5.0 * val * 100.0)/1024.0; //convert the analog data to temperature

Serial.print("Temperature = ");
 Serial.print((byte)tempC); //send the data to the computer
delay(1000); //wait one second before sending new data

The Output (Temperature Values of the Sensor) can be monitored by Clicking the Serial monitor icon on upper right corner of the console (where you write your Arduino code) ......

I touched the Head of the Temperature sensor LM35 with a cotton soaked in icy cold water to check the working of the sensor. If every thing goes right you will be able to see the temperature values in your PC in a Tab as shown ....