1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

GSM Based Temprature Monitoring system

Discussion in '8051/8951' started by Bob Parihar, May 23, 2015.

  1. Bob Parihar

    Bob Parihar Member

    Joined:
    Oct 8, 2014
    Messages:
    87
    Likes:
    0
    as u see in the topic i am doing this project.. using AT89s52 MCU
    i am doing the code segment of temperature sensing and gsm sms sending.. and they both works properly independently .. but i am having problem in combining those in a same code.. please help
    i am using LM35 and gsm900A
    i am attaching both independent working code and the combined code.. please tell me where i am wrong..
     

    Attached Files:

  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,170
    Likes:
    910
    Location:
    Rochdale UK
    ONLINE
    You keep messing your self up in pointers..

    your function..
    Code (c):
    void gsm_send(unsigned int ch3) {......}
    Your declaration specifies an int

    Code (c):

    void gsm_send(unsigned int ch3)
    {
       data_send(ch);
       //data_res();
       Delay_ms(100);
       data_send(ch1);
       Delay_ms(100);
       //data_res();
       data_send(ch2);
       Delay_ms(100);
       //data_res();
       data_send(a);
       data_send(ch9);
       data_send(a);
       data_send("\r\n");
       Delay_ms(100);
       num(ch3);
       Delay_ms(100);
       SBUF=0x1a;
       while(TI==0);
       TI=0;
    }
     
    Now data_send wants a pointer!!!! that means you need an array... You need to convert an int to an ascii array.

    You have tried with a function " data_res"..

    Un fortunately your compiler ( I'm assuming C51) doesn't have the atoi() function... Try this

    Code (c):

      data_send(itoa(gsm_val));

    unsigned char* itoa( unsigned int numb)                           // My crass interpretation on itoa()..
       {
       char res[6];       // result
       char *tr = &res[5];     // traverse backwards
       *tr-- = 0;         // null
     
       do
           {
           *tr-- = numb%10+48;
           }while((numb/=10) >0);
       return ++tr;
       }
     
    Now you don't need send_gsm()....
     
    Last edited: May 23, 2015
  3. Bob Parihar

    Bob Parihar Member

    Joined:
    Oct 8, 2014
    Messages:
    87
    Likes:
    0
    Thanks for your answer sir.

    the data_send function is
    void data_send(unsigned char *p)
    having arguments of char type pointer
    and i am sending data_send(ch); (i mean passing a variable of char type initialized globally)
    and the gsm_send function

    void gsm_send(unsigned int ch3)
    ch3 is of int type because the temprature is in numerical form
    and further this numerical value in ch3 variable is send to num() function which process it and convert the number into ASCII

    as i said my independent gsm CODE is working find.. only problem is in combining
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,170
    Likes:
    910
    Location:
    Rochdale UK
    ONLINE

    I am looking at your code....

    In the ISR you call gsm_send(gsm_val); then that routine ( in gsm.h ) doesn't do any conversion at all

    Code (c):

    void gsm_send(unsigned int ch3)
    {
       data_send(ch);
       //data_res();
       Delay_ms(100);
       data_send(ch1);
       Delay_ms(100);
       //data_res();
       data_send(ch2);
       Delay_ms(100);
       //data_res();
       data_send(a);
       data_send(ch9);
       data_send(a);
       data_send("\r\n");
       Delay_ms(100);
       num(ch3);       //<----- This does nothing!!!!
       Delay_ms(100);
       SBUF=0x1a;
       while(TI==0);
       TI=0;
    }
     
    Also, depending on the compiler.... gsm_val needs to be volatile as its being used it two functions... the compiler may not include it!!!

    The above routine isn't doing what you think it is....
     
  6. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,170
    Likes:
    910
    Location:
    Rochdale UK
    ONLINE
    Appologies.... I missed the dat routine in the numb routine....

    Still using your code, try declaring gsm_val as volatile.... it might work...
     
    • Like Like x 1
  7. Bob Parihar

    Bob Parihar Member

    Joined:
    Oct 8, 2014
    Messages:
    87
    Likes:
    0
    to test that my ISR is working properly or not i just used
    gsm_send (123);
    a simple constant 123 to check if the control goes to ISR or not.. but it seems that its not.. because i didn't receive any text...
     

Share This Page