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

Problem in sending SMS through GSM module using 8051

Discussion in '8051/8951' started by Bob Parihar, Apr 29, 2015.

  1. Bob Parihar

    Bob Parihar Member

    Joined:
    Oct 8, 2014
    Messages:
    87
    Likes:
    0
    ok now i decided that i will just check each command response
    i read somewhere that gsm modem send OK for each successful retrieving of AT command
    so i gust introduced serial interrupt for that and i am checking the response of "AT"

    here is my code

    #include"lcd.h"
    unsigned char *command = "AT";

    unsigned char CTRLZ = 0x1A, count;
    unsigned char ar[5];
    void serial_init(void);
    void serial(unsigned char);
    void puts(unsigned char *p );
    void delay1(unsigned int);

    void serial0() interrupt 4 {
    if (TI==1) {
    TI=0; //clear interrupt
    }
    else {
    count=count+1;
    ar[count]=SBUF;

    RI=0; //clear interrupt
    }
    }

    void main()
    {
    count=(-1);
    init();
    serial_init();
    puts(command);
    delay1(1000);

    serial(CTRLZ);

    print(&ar[0]);
    while(1);

    }
    void serial_init(void)
    {

    TMOD=0x20; //timer 1, mode 2(8-bit autoreload) to set baud rate
    TH1=0xFD; //-3 to TH1 for 9600 baud rate
    SCON=0x50; // 8 bit txion, 1 start 1 stop bit, REN enable for both txfr and rxve
    IE=0x90;
    TR1=1; // start timer
    }

    void puts(char *p)
    {
    char *temp = p; /*temp pointer so that the actual pointer is not displaced */
    while(*temp != 0x00)
    {
    serial(*temp);
    temp++;
    }
    }

    void serial(unsigned char x)
    {

    SBUF=x;
    while(TI==0);
    TI=0;

    }

    void delay1(unsigned int x)
    { int i,j;
    for(i=0;i<x;i++)

    for(j=0;j<1275;j++);

    }

    lcd.h header file contains this code:
    #include<reg51.h>
    sbit rs=P3^3;
    sbit rw=P3^4;
    sbit en=P3^5;
    void dat(unsigned char);
    void cmd(unsigned char);
    void delay(unsigned int);
    void print(unsigned char *);
    void init();
    void num(unsigned int);


    void init()
    {

    cmd(0x38);
    delay(100);
    cmd(0x0E);
    delay(100);
    cmd(0x06);
    delay(100);
    cmd(0x01);
    delay(100);
    cmd(0x80);




    }

    void cmd(unsigned char x)
    {
    P2=x;
    rs=0;
    rw=0;
    en=1;
    delay(1);
    en=0;
    }
    void dat(unsigned char y)
    {
    P2=y;
    rs=1;
    rw=0;
    en=1;
    delay(1);
    en=0;
    }
    void delay(unsigned int z)
    {
    int j,i;
    for(i=0;i<z;i++)
    {
    for(j=0;j<1275;j++);

    }
    }
    void print(unsigned char *p)
    {

    while(*p!='\0')
    {
    dat(*p);
    p++;
    }

    }




    why iam not getting the "OK "on LCD?
     
  2. Cicero

    Cicero Active Member

    Joined:
    Nov 21, 2014
    Messages:
    335
    Likes:
    36
    Location:
    UK
    What do you mean, you're not getting what I edited?
    Did you run the code I posted?
     
  3. Bob Parihar

    Bob Parihar Member

    Joined:
    Oct 8, 2014
    Messages:
    87
    Likes:
    0
    yes it didn't worked...

    and i meant that i am not getting your code... i am not familiar with that #ifdef code lne
     
  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,161
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE

    If you do not get an OK from "AT" then nothing's going to work... The last time I dabbled in GSM, I hooked it up to a PC and got the commands working with 3 wire 9600,8,n to start with.... I cannot find the proper AT command set... I have only the extended AT set....

    http://www.google.com/url?sa=t&rct=...=q_qqV-XbrV97-T019UWLFQ&bvm=bv.92291466,d.d2s

    Its quite intense but some good info in there... Is it possible to hook it up to your PC and get it working with hyper terminal or similar...
     
  6. Bob Parihar

    Bob Parihar Member

    Joined:
    Oct 8, 2014
    Messages:
    87
    Likes:
    0


    thank you sir,
    i am using GSM module sim900A of Sim comm. company
    isn't there any difference of working ?
    will this article help me for this module?
     
  7. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,161
    Likes:
    909
    Location:
    Rochdale UK
    ONLINE
    GSM900/a is the model.... The actual modem is a Huawei EM820... So that's the datasheet to access AT command set...

    As I said.... Get it up and running on a PC first...Open a terminal program and type "AT" and see if it replies.... If it does then you know its software on your part!!!
     
  8. Cicero

    Cicero Active Member

    Joined:
    Nov 21, 2014
    Messages:
    335
    Likes:
    36
    Location:
    UK
    It just stops that part of the code being run because I wanted to mimic the Arduino code example exactly. Not really important.

    But calling works, and he's done it on Arduino as well? Apparently anyway.
     

Share This Page