[vc_row][vc_column width=”1/1″][vc_column_text]LM35 Linear Temperature Sensor can be used to detect ambient air temperature. This sensor is produced by National Semiconductor Corporation and offers a functional range between 0 degree Celsius to 100 degree Celsius. Sensitivity is 10mV per degree Celsius. The output voltage is proportional to the temperature.
It is commonly used as a temperature measurement sensors. It includes thermocouples, platinum resistance, thermal resistance and temperature semiconductor chips, which commonly used in high temperature measurement thermocouples. Platinum resistance temperature used in the measurement of 800 degrees Celsius, while the thermal resistance and semiconductor temperature sensor suitable for measuring the temperature of 100-200 degrees or below, in which the application of a simple semiconductor temperature sensor has good linearity and high sensitivity.
The output of LM35 has a linear relationship to the temperature in degree Celsius. When the temperature is 0 degree Celsius, the output is 0V, and when the temperature rises for 1 degree Celsius, the output voltage will increase 10mV.
The equation is as follows:
V (T)=10 mV * T
In this post, we look at how to use LM35 on a pcDuino.
[/vc_column_text][vc_tour][vc_tab title=”BOM” tab_id=”1384560501-1-63″][vc_column_text]1. pcDuino experiment platform
2. 1 x LM35 temperature sensor
3. 1 x Red LED, 1x Green LED, 1 x Blue LED
4. Resistor of value 220 ohm
5. Jumper wire[/vc_column_text][/vc_tab][vc_tab title=”Wire Diagram” tab_id=”1384560501-2-7″][vc_column_text][/vc_column_text][/vc_tab][vc_tab title=”How it works” tab_id=”1384561084906-2-2″][vc_column_text]ADC2 to ADC5 on pcDuino outputs from 0-4095, i.e., 0V corresponds to a reading of 0, and 3.3V corresponds to a reading of 4095. Other voltage can be mapped accordingly.
From the principle of LM35, we know that when the temperature rises for 1 degree Celsius, the output voltage will increase 10mW.
When the voltage is 0.2v to 0.3V (which means temperature is between 20 degree Celsius to 30 degree Celsius), the reading of ADC will be 248 to 372. The green LED will turn on at this time. It means the environment is comfortable.
When the voltage is 0.3v to 0.4V (which means temperature is between 30 degree Celsius to 40 degree Celsius), the reading of ADC will be 372 to 496. The yellow LED will turn on at this time. It means the environment is uncomfortable.
When temperature is below 20 degree Celsius or higher than 40 degree Celsius, red LED will turn on to indicate that the environment is extremely uncomfortable.
[/vc_column_text][/vc_tab][vc_tab title=”Code” tab_id=”1384561387501-3-5″][vc_column_text]The full code can be downloaded from here (temperature).
The code is shown below:
int led_green=9;
int led_yellow=10;
int led_red=11;
int sensorPin =A5;
void setup()
{
int j;
for(j=9;j<=11;j++)
{
pinMode(j,OUTPUT);
}
}
void loop()
{
int sensorValue;
while(1)
{
sensorValue=analogRead(sensorPin);
printf("sensorValue=%d\n", sensorValue);
if(sensorValue>248&&sensorValue<372)
{
digitalWrite(led_green,HIGH);
printf("I am here");
digitalWrite(led_yellow,LOW);
digitalWrite(led_red,LOW);
}
else if(sensorValue>=372&&sensorValue<496)
{
digitalWrite(led_yellow,HIGH);
digitalWrite(led_green,LOW);
digitalWrite(led_red,LOW);
}
else
{
digitalWrite(led_red,HIGH);
digitalWrite(led_yellow,LOW);
digitalWrite(led_green,LOW);
}
}
}
[/vc_column_text][/vc_tab][vc_tab title=”Program in Action” tab_id=”1384561445171-4-10″][vc_column_text]When the environment is between 20 degree Celsius and 30 degree Celsius, the green LED will turn on:
When we heat it using hand to above 30 degree Celsius, the yellow LED will turn on:
When we burn it using a lighter, the red LED will turn on:
Leave a Reply
You must be logged in to post a comment.