LM35 Temperature Sensor Simulation

Simulation of a temperature sensor LM35 using proteus and MicroC

Video details at Youtube

Step 1: Connecting the Components

I used Proteus 8.0 to simulate the LM35 temperature sensor with micro controller PIC16f887

and a 16x2 LCD , all the connection are shown in the figure.

the LM35 ca be used in a range of -55 to 150 Celsius

but for now we are interested int the range of 2 to 150 Celsius with a 0.5 degree error.

Part list from amazon:

LM35

PIC16F887

LCD 16x2

22 pF capacitors

8 Mhz crystal

10K ohm resistors

Step 2: Coding

I used MicroC to program and compile the following code:

//4/2018

//subscribe for more on youtube at: Circuitalist

///LCD pin

sbit LCD_RS at RB6_bit;
sbit LCD_EN at RB5_bit;

sbit LCD_D4 at RB4_bit;

sbit LCD_D5 at RB3_bit;

sbit LCD_D6 at RB2_bit;

sbit LCD_D7 at RB1_bit;

sbit LCD_RS_Direction at TRISB6_bit;

sbit LCD_EN_Direction at TRISB5_bit;

sbit LCD_D4_Direction at TRISB4_bit;

sbit LCD_D5_Direction at TRISB3_bit;

sbit LCD_D6_Direction at TRISB2_bit;

sbit LCD_D7_Direction at TRISB1_bit;

//**********************************

unsigned int adc_rd; // 10 bit for 16f887
char *txt; //pointeur texte

long tlong;

float val;

char tempval[4];

float temp;

void main() {

INTCON = 0; //ALL INTERRUPT DISABLE
ANSEL = 0X01; // PIN RA0 CONFIGURED AS ANALOG

ANSELH = 0; // Configure other ANALOG pins as digital I/O

C1ON_BIT = 0; //Disable comparators

C2ON_BIT = 0; //Disable comparators TRISA.RA0 = 1;

TRISB = 0 ;

LCD_init();
Lcd_Cmd(_LCD_CURSOR_OFF);

Lcd_Cmd(_LCD_CLEAR);

////////////////////////////StartUp

txt = "Circuitalist";

Lcd_Out(1, 1, txt);

txt = "Temp. Sensor";

Lcd_Out(2, 1, txt);

delay_ms(1500);

///////////////////////////

Lcd_Cmd(_LCD_CLEAR);

while(1) {

adc_rd = ADC_read(0);

val = (adc_rd * 5000.0)/1023.0; //Convert to mV resolution
temp = val/10.0 ; //convert mV to celsius

if (temp<=12){
FloatToStr(temp,tempval);

Lcd_Out(1,1,"Thx for watching");

LCD_Out(1,7,tempval);

Lcd_Out(1,16,"C");

Lcd_Out(2,1,"Subscribe....");

}

if (temp>12 & temp <=25){

FloatToStr(temp,tempval);

Lcd_Out(1,1,"Temp= ");

LCD_Out(1,7,tempval);

Lcd_Out(1,16,"C");

Lcd_Out(2,1,"Warm");

}

if (temp>25){

FloatToStr(temp,tempval);

Lcd_Out(1,1,"Temp= ");

LCD_Out(1,7,tempval);

Lcd_Out(1,16,"C");

Lcd_Out(2,1,"Hot ");

}

}

}

Step 3: Finally

if everything goes right you should see results on the LCD.

check my youtube video Circuitalist

Share

    Recommendations

    • IoT Challenge

      IoT Challenge
    • Party Challenge

      Party Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest

    Discussions