EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Topics / Help about GSM interfacing with 8051

Help about GSM interfacing with 8051

|

Microcontroller › 8051 › Help about GSM interfacing with 8051

  • This topic has 1 reply, 2 voices, and was last updated 6 years, 1 month ago by Anonymous.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • June 23, 2016 at 5:36 pm #4494
    julius
    Participant

    I was interfacing GSM modem with AT89S52 microcontroller to send SMS to a mobile number. I tried sending the sms using hyperterminal from PC and the SMS get sent properly. But if i send the SMS using microcontroller and GSM, then the SMS does not get sent. Please help me in fixing the issue. I use DB9 serial cable to connect at89s52 and GSM modem.

    Below is the embedded c code:

    #include<reg51.h>
    sbit swtch=P0^0;
    sbit led=P0^1;
    unsigned char test[]="AT";
    unsigned char textmode[]="AT+CMGF=1";
    unsigned char mobno[]="AT+CMGS="8308941641"";
    unsigned char message[]="$GPRMC,0600100.000,A,15234.678,N,1324.987,E";
    void delay(unsigned int x)
    {
    unsigned int i;
    for(i=0;i<x;i++)
    {;}
    }
    void uart_init()   // INITIALIZE SERIAL PORT
    {
    TMOD=0x20;  // Timer 1 IN MODE 2-AUTO RELOAD TO GENERATE BAUD RATE
    TH1=0xFD; // LOAD BAUDRATE TO TIMER REGISTER
    SCON=0x50;  // SERIAL MODE 1, 8-DATA BIT 1-START BIT, 1-STOP BIT, REN ENABLED
    TR1=1; // START TIMER
    TI=1;
     
    }
    void tx_data(unsigned char serialdata)
    {
    while(TI!=1){;}
    TI=0;
    SBUF = serialdata; // LOAD DATA TO SERIAL BUFFER REGISTER
    }
    void tx_string(unsigned char a[],unsigned int len)
    {
    unsigned int z;
    for(z=0;z<len;z++)
    {
    tx_data(a[z]);
    }
    }
    void main(void)
    {
    swtch=1;
    led=0;
    uart_init();
     
    while(1)
    {
    s:if(swtch!=0)
    {
    goto s;
    }
    else
    {
    tx_string(test,2);
    tx_data(0x0D);
    tx_data(0x0A);
    //delay(50000);
    tx_string(textmode,6);
    tx_data(0x0D);
    tx_data(0x0A);
    //delay(50000);
    tx_string(mobno,20);
    tx_data(0x0D);
    tx_data(0x0A);
    //delay(50000);
    tx_string(message,43);
    tx_data(0x1A);
    led=1;
    delay(200000);
    }
    }
    }
    June 25, 2016 at 5:16 pm #13992
    Anonymous
    Guest

    Refering to the command 4.2.5:AT+CMGS from SIM900 AT command set I hope:

    In the else loop,after transmitting the mobile number it is sufficient to send 0X0D.Not necessary to send 0X0A.

    And also try without using  ’’ before and after the number.

    I have used the following code pattern for entering the mobile number:

    AT+CMGS=”1234567890”

    After sending this line just send  ‘r’  i.e..,0X0D.But 0X0A is not necessary.

    A delay of 300ms worked for me to transmit the text after transmitting number.

    And also try without using  ’’ before and after the number.

    The below code pattern worked for may work for you:   

    char mobno[]="AT+CMGS="8308941641"";

    tx_data(0x0D);

    delay(50000);     //uncomment this delay to about 300ms. it is necessary while interfacing with  uC

    tx_string(message,43);

    tx_data(0x1A);

    The rest of the code is same.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Circuit Problem August 14, 2022
  • Beam Break Sensor August 14, 2022
  • Drill speed controller fault August 14, 2022
  • uc3843 Buck-boost August 14, 2022
  • Right channel distortion on vintage fisher rs-2010 August 13, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools