LM35 Interfacing with MSP-EXP430G2 TI Launchpad

Overview of LM35

LM35
LM35

 

LM35 is a temperature sensor that can measure temperature in the range of -55°C to 150°C.

It is a 3-terminal device that provides an analog voltage proportional to the temperature. The higher the temperature, the higher is the output voltage.

The output analog voltage can be converted to digital form using ADC so that a microcontroller can process it.

For more information about LM35 and how to use it, refer to the topic LM35 Temperature Sensor in the sensors and modules section.

 

Connection Diagram of LM35 with MSP-EXP430G2 TI Launchpad

Interfacing LM35 With MSP-EXP430G2 TI Launchpad
Interfacing LM35 With MSP-EXP430G2 TI Launchpad

 

Measure Temperature using LM35 and MSP-EXP430G2 TI Launchpad

Measuring the temperature of surroundings using LM35 and displaying it on the serial monitor of Energia.

 

Here, the LM35 output is given to analog pin A4 (P1_4) of MSP-EXP430G2 TI Launchpad. This analog voltage is converted to its digital form and processed to get the temperature reading.

 

Tread Carefully: MSP-EXP430G2 TI Launchpad board has a RAM of 512 bytes which is easily filled, especially while using different libraries. There are times when you need the Serial buffer to be large enough to contain the data you want and you will have to modify the buffer size for the Serial library. While doing such things, we must ensure that the code does not utilize more than 70% RAM. This could lead to the code working in an erratic manner, working well at times, and failing miserably at others. 

There are times when the RAM usage may exceed 70% and the codes will work absolutely fine, and times when the code will not work even when the RAM usage is 65%. 

In such cases, a bit of trial and error with the buffer size and/or variables may be necessary.

 

LM35 Temperature Measurement Code for MSP-EXP430G2 TI Launchpad

const int lm35_pin = A4;	/* LM35 O/P pin */

void setup() {
  Serial.begin(9600);
}

void loop() {
  int temp_adc_val;
  float temp_val;
  temp_adc_val = analogRead(lm35_pin);	/* Read Temperature */
  temp_val = (temp_adc_val * 3.22);	/* Convert adc value to equivalent voltage */
  /* 3.3V/1024 = 3.22 */
  temp_val = (temp_val/10);	/* LM35 gives output of 10mv/°C */
  Serial.print("Temperature = ");
  Serial.print(temp_val);
  Serial.print(" Degree Celsius\n");
  delay(1000);
}

 

Video of Temperature Measurement using LM35 and MSP-EXP430G2 TI Launchpad


Components Used

TI Launchpad MSP-EXP430G2
TI Launchpad MSP-EXP430G2
1
LM35 Temperature Sensor
LM35 is a sensor which is used to measure temperature. It provides electrical output proportional to the temperature (in Celsius).
1
Breadboard
Breadboard
1

Downloads

LM35_Interfacing_With_TI_Launchpad_INO Download
Ad