May 7, 2014

TEMPERATURE SENSOR - LM35 -MSP430G2553 - ENERGIA

I think ENERGIA make programming in very simple manner.Here i am interfacing LM35 which  is a low cost temperature sensor with wide operating range using ADC .Here measured temperature will send via UART. Use serial terminal to see data.
LM35 works up to 35V. Its output type is is anolog. Its output voltage increases 10mV when temperature increases by 10C .. For examples if temperature is 30 0C then its output voltage equal to 300mV.


/*
Author --- Jimmy Jose
Microcontroller --- MSP430G2553
Temperature sensor---LM35
ADC Voltage reference---3.4V(step size =3.32mV , Resolution = 10 bits)
*/
unsigned int a; // for storing adc converted values
void setup()
{
 Serial.begin(9600); //starts serial (protocol--uart communication)
}

void loop()
{
 a=analogRead(A3)/3; //Here 3 used to convert real temperature value
 Serial.print(a);           //send value over uart
 Serial.write(0xd);     //to go to next line (think about what happen when you enter key in  the keyboard)
 delay(1000);            //measures temperature in every one second.
}