Digital thermometer with auto saving log file in excel by Pic microcontroller

By | February 28, 2014

Digital thermometer with auto saving log file in excel by Pic microcontroller is vary advance, useful and realistic project. The implementation filed of this project is wide. Now a day’s atmospheric prediction saves lots of life. And for getting wright prediction we have to analysis lots of recorded data. By using this project it can be easily serve the purpose.

Project description:

To know the project description you should know that how it works? In this project “Digital thermometer with auto saving log file inDigital thermometer with auto saving log file in excel by Pic microcontroller excel by Pic microcontroller “we use LM34 IC as a temperature sensor which sense the atmospheric temperature and send the analog value of it. Now we know microcontroller can only process digital value so we convert the analog value which sends by LM34, by inbuilt ADC unit of PIC16f877. After converting the reference temperature value microcontroller process it with some mathematical formula to convert the reference value in Centigrade scale. We interface DS1307 IC for getting the time and calendar in real time mode. To know the details step by step tutorial on “how to interface DS1307 with PIC16f877 microcontroller?” you may follow my old post Interfacing DS1307 Real time clock with PIC16f877. Now big question is how to create log file in excel and save it to PC? For now that you have to see the bellow video where you find the step by step process on how using windows HyperTerminal software, we can receive data via comport (serial communication) and capture the data in CSV format. So for saving the data in CSV format we have to send comma separated data with exact format via UART from PIC16F877 microcontroller.  

CSV Data format and Creation inside PIC:Digital thermometer with auto saving log file in excel by Pic microcontroller

It is a major thing we have to do for sending data in CSV format. As we know the name CSV means comma separated values so we have to send every data separated by comma. And as per Excel for changing column we have to press Tab Key and for change Row we have to press Enter Key. To make our format accordingly our plan we have to send data followd by comma and others key. In this project, we save the data at three column for temperature, time and date see in fig. For that we use code (In Mikroc for Pic) given bellow.

    UART1_Write_text(tem);       // send data (temperature) via UART

    UART1_Write(0x2c);             //” comma

    UART1_Write(0x09);             //  Tab

    UART1_Write_text(time);      // send data (time) via UART

    UART1_Write(0x2c);            //” comma

    UART1_Write(0x09);            // Tab

    UART1_Write_text(date);     // send data (Date) via UART

    UART1_Write(0x2c);            //” comma

    UART1_Write(0x0D);     // Enter

 

Here you see the complete Proteus simulation circuit diagram of my project Digital thermometer with auto saving log file in excel by Pic microcontroller.

Digital thermometer with auto saving log file in excel by Pic microcontroller

Here you see complete C Code of my project Digital thermometer with auto saving log file in excel by Pic microcontroller.

Embedded C Code
// Name : Digital thermometer with auto saving log file in excel by Pic microcontroller
// Author : Subham Dutta
// Date : 28-02-14
// Website : www.nbcafe.in

sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
char *l,m[5],n[7],o[7];

int ma=0,ma1=0,mi=0 ;
char uart_rd,tem;
int b,sec,mm,hh,dd,mo,yr,dela;
unsigned short read_ds1307(unsigned short address)
{
unsigned short r_data;
I2C1_Start();
I2C1_Wr(0xD0); //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 –> 0xD0
I2C1_Wr(address);
I2C1_Repeated_Start();
I2C1_Wr(0xD1); //0x68 followed by 1 –> 0xD1
r_data=I2C1_Rd(0);
I2C1_Stop();
return(r_data);
}
char time[] = “00:00:00”;
char date[] = “00-00-00″;

unsigned char BCD2UpperCh(unsigned char bcd)
{
return ((bcd >> 4) + ‘0’);
}

unsigned char BCD2LowerCh(unsigned char bcd)
{
return ((bcd & 0x0F) + ‘0’);
}
date_time()
{
sec = read_ds1307(0);
mm = read_ds1307(1);
hh = read_ds1307(2);
dela = read_ds1307(3);
dd = read_ds1307(4);
mo = read_ds1307(5);
yr = read_ds1307(6);

time[0] = BCD2UpperCh(hh);
time[1] = BCD2LowerCh(hh);
time[3] = BCD2UpperCh(mm);
time[4] = BCD2LowerCh(mm);
time[6] = BCD2UpperCh(sec);
time[7] = BCD2LowerCh(sec);

date[0] = BCD2UpperCh(dd);
date[1] = BCD2LowerCh(dd);
date[3] = BCD2UpperCh(mo);
date[4] = BCD2LowerCh(mo);
date[6] = BCD2UpperCh(yr);
date[7] = BCD2LowerCh(yr);
return;
}

store_data()
{
UART1_Write_text(tem); // and send data via UART
UART1_Write(0x2c); //” coma
UART1_Write(0x09);
UART1_Write_text(time);
UART1_Write(0x2c); //” coma
UART1_Write(0x09);
UART1_Write_text(date);
UART1_Write(0x2c); //” coma
UART1_Write(0x0D);
delay_ms(1000);
}

void main ()
{

int i=0,j,t;
ADCON1=0x04;
TRISA=0x01;
TRISd=0x00;

lcd_init();
lcd_cmd(_LCD_CURSOR_OFF);

UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
I2C1_Init(100000);
while(1)
{

t=ADC_Read(0);
t=t*0.4887;
inttostr(t,o);
l=ltrim(o);
lcd_out(2,1,”Temp :”);
Lcd_out(2,7,l);
Lcd_out(2,11,”C”);
if ( i < t)
{
i=t;
}
tem=o;
date_time();
store_data();
Lcd_out(1,1,”Time:”);
Lcd_out(1, 6, time);
Delay_ms(1000);
lcd_cmd(_LCD_CLEAR);
Lcd_out(1,1,”Date:”);
Lcd_out(1, 6, date);
}
}

 

Now see step by step video tutorial on our project  Digital thermometer with auto saving log file in excel by Pic microcontroller

7 thoughts on “Digital thermometer with auto saving log file in excel by Pic microcontroller

  1. pratheep

    hi
    i am trying to do this project.i downloaded windows hyperterminal,trying to connect to com1 port but that option is not showing please help me
    thank you in advance

    Reply
  2. pratheep

    sir,
    I am trying to do temperature with auto log file,I followed the steps given and dumped the code in micro controller,it is showing the temperature but not displaying the time and date and also not displaying in hyper terminal,can you please help me

    Reply
  3. Suryakant

    Hi,,,,is there any way to connect usb port of laptop to serial pin of development board or RX TX of controllers .
    I don’t want to connect USB to serial convertor in between this two thing?

    Reply
  4. emontarzan

    can you send me the proteus simulation with code?i’ll grateful to you

    Reply
  5. aab

    Hi,
    How can use this code in MPlab C18 compiler.
    Are the code the same or need some modification. If you explaining how

    Thanks,

    Reply
  6. Dumi

    Can you Explain following codes

    unsigned char BCD2UpperCh(unsigned char bcd)
    {
    return ((bcd >> 4) + ‘0’);
    }

    unsigned char BCD2LowerCh(unsigned char bcd)
    {
    return ((bcd & 0x0F) + ‘0’);

    Reply



Leave a Reply

Your email address will not be published. Required fields are marked *