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 Modem Interfacing with PIC Microcontroller

Discussion in 'Microcontrollers' started by Sathiesh Kumar, Jan 31, 2010.

  1. Sathiesh Kumar

    Sathiesh Kumar New Member

    Joined:
    Oct 13, 2009
    Messages:
    58
    Likes:
    1
    Location:
    Chennai
    i have modified the code to receive character by character.... but the message received in my mobile is ATTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT....

    WHAT MIGHT BE THE PROBLEM... I am attaching thecode...

    Code (text):
    void sms_read();
    void sms_send();
    char output[70];
    void main() {
         UART1_Init(9600);              // Initialize UART module at 9600 bps
         Delay_ms(100);                 // Wait for UART module to stabilize
         sms_read();                    //to read the sms in location 1
         delay_ms(500);
         sms_send();                    //send an sms
    }
    void sms_read()
    {
    unsigned char i;
    UART1_Write_Text("AT\n\r");
    delay_ms(500);
    UART1_Write_Text("AT+CMGF=1\n\r");
    delay_ms(500);
    UART1_Write_Text("AT+CMGR=1\n\r");
    delay_ms(500);
    UART1_Write_Text("AT+CMGR=1\n\r");
    delay_ms(500);
    while (UART1_Data_Ready() == 0) ;
    for(i=0;i<=65;i++)
    {
     output[i]=UART1_Read();
    }
    delay_ms(500);
    }

    void sms_send()
    {
    int i;
    /*UART1_Write_Text("AT\n\r");
    delay_ms(500);
    UART1_Write_Text("AT+CMGF=1\n\r");
    delay_ms(500); */
    UART1_Write_Text("AT+CMGS=");
    UART1_Write(0x22);
    UART1_Write_Text("+919444721638");
    UART1_Write(0x22);
    UART1_Write_Text("\n\r");
    delay_ms(500);
    UART1_Write_Text(output);
    UART1_Write(26);// send ctrl + Z

    }
     
  2. haxan

    haxan New Member

    Joined:
    Nov 17, 2009
    Messages:
    387
    Likes:
    0
    Hmmm. Can you check the value of the output array ? Does it have the desired string you want? (I think it contains all the rest of the junk with the actual SMS because you are just outputting the output array without removing the unwanted data) after you read the SMS

    However that is not the actual issue here. But it will be easier to debug once we know about that.

    If the output string doesn't have the actual SMS. You should try adding a delay in the loop
     
    Last edited: Feb 23, 2010
  3. Sathiesh Kumar

    Sathiesh Kumar New Member

    Joined:
    Oct 13, 2009
    Messages:
    58
    Likes:
    1
    Location:
    Chennai
    i cant able to read a sms using pic microcontroller... i tried different options ... but it doesnt work out... can any one send me a sample code to read an sms using pic... its not necessary that the code should be written in MikroC compiler... i can convert the code...

    Please help...
     
  4. dave

    Dave New Member

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


     
  5. LogX

    LogX New Member

    Joined:
    Mar 1, 2010
    Messages:
    8
    Likes:
    0

    Hi..
    I'm new to PIC.
    I"m trying to interface modem --> max232 --> PIC16F873A

    How to initialize the modem (using assembly code)?
    How should i connect it?

    Please reply ASAP.
    Thank You.
     
  6. Sathiesh Kumar

    Sathiesh Kumar New Member

    Joined:
    Oct 13, 2009
    Messages:
    58
    Likes:
    1
    Location:
    Chennai
    whats the type of modem you are using...
     
  7. Wilksey

    Wilksey Member

    Joined:
    Aug 16, 2009
    Messages:
    553
    Likes:
    20
    Location:
    Somerset, UK
    You shouldn't hijack posts, you should start your own thread!

    For a start this thread is about interfacing using C, not assembly.

    If you are new to PIC I suggest reading Nigel's tutorial.
    Nigel's PIC Tutorial Page
     
  8. LogX

    LogX New Member

    Joined:
    Mar 1, 2010
    Messages:
    8
    Likes:
    0
    Its MOD 9001 GSM/GPRS Modem.
    I already checked the modem using hyperterminal, its working.
    But my problem is the pic doesnt interact with modem.
    Im not sure whether the connection is wrong or the coding is wrong.
    What is the coding to intialize max232 and modem (assembly)?
     
  9. raymee85

    raymee85 New Member

    Joined:
    Mar 3, 2010
    Messages:
    3
    Likes:
    0
    to : Sathiesh Kumar

    hi..i also now on development my project using GSM..
    using PIC16F84 0r 877..
    can u ask me about the connection between the GSm and PIC?
    Is it only ATI command can be use for connect these two element?

    hope can get your help..

    thanx.. =)
     
  10. haxan

    haxan New Member

    Joined:
    Nov 17, 2009
    Messages:
    387
    Likes:
    0
    Please kindly start your own thread and you will find help there aswell. Mr Sathiesh Kumar is trying to make it work. I believe he has problems regarding SMS read.
     
  11. raymee85

    raymee85 New Member

    Joined:
    Mar 3, 2010
    Messages:
    3
    Likes:
    0
    oh..i'm sorry..cause i'm new here.. actually i just want to know about the connections between the modem and PIC.. about the PIC programming is under construction..
    Beside that, i just want to know about mr sathiesh circuit connections..

    ..i'm sorry again if i'm in wrong thread.. hope all of u can give some informations..

    thanx for ur help..

    =)
     
  12. haxan

    haxan New Member

    Joined:
    Nov 17, 2009
    Messages:
    387
    Likes:
    0
    raymee85 that depends on what type of GSM modem you are using. If it is serial based, the usual connections are:

    [PIC] ======== [MAX232] ======== [GSM MODEM]
    [RX,TX] [TX,RX]

    RX of PIC goes to TX of GSM modem
    TX of PIC goes to RX of GSM modem
    in between you add the MAX232 IC for level conversion (you can see its pin connection from its datasheet)
    Also make sure you common out the GND (ground)
     
  13. raymee85

    raymee85 New Member

    Joined:
    Mar 3, 2010
    Messages:
    3
    Likes:
    0

    thanx haxan...yes i using the max232.. i only design for receiver part..mean that, my GSM only receive data..may i ask u again??..
    for data that received by GSm modem, did the PIC auto detect the data?..
    because..now, i'm confuse what command that i should use on the programming for read the data..in my PIC, i will program to compare the received data with certain value..
     
    Last edited: Mar 7, 2010
  14. sam1983

    sam1983 New Member

    Joined:
    Jun 22, 2010
    Messages:
    1
    Likes:
    0
    hi sathiesh
    I am also working on GSM and microcontroller interface.
    i am facing the problem to pass proper AT commands from microcontroller.
    GSM modem is working properly when connected to Hyperterminal.
    It doest respond properly once get connected to Microcontroller.
    As i have read that u also hv faced the same problem, can u just help me out with this problem.
     
  15. mushu_mist

    mushu_mist New Member

    Joined:
    Aug 4, 2008
    Messages:
    5
    Likes:
    0
    I am facing exactly same problem. Please help.
     
  16. israr123

    israr123 New Member

    Joined:
    Jul 21, 2010
    Messages:
    1
    Likes:
    0
    microcontroller At89c51 interfacing GSM modem

    Please any 1 know the connections b/w microcontroller and gsm modem to send and read sms using At commands without using PC just Microcontroller and GSM modem.
    how to connect pins of UC and Gsm modem if any 1 has circuit diagram please show.
     
  17. hellboy

    hellboy New Member

    Joined:
    Dec 30, 2010
    Messages:
    1
    Likes:
    0
    To Mr. Satieh Kumar

    i am having the same problem with my PIC to GSM system can i ask how you wer able to solve the problem? Thank you
     
  18. Wilksey

    Wilksey Member

    Joined:
    Aug 16, 2009
    Messages:
    553
    Likes:
    20
    Location:
    Somerset, UK
    Some guidelines to connecting a modem (Analog or GSM) to a MCU.

    Dont forget that some GSM modems require the hardware control lines to operate properly.

    DCD, DTR, RTS etc.

    However, most modems will accept AT commands without these, it mainly becomes an issue when you attempt to connect or recieve a call, never had an issue with SMS before, so cant say about that.

    One thing to do is if your modem isn't behaving itself and you only have pins 2,3 and 5 on a 9 pin 232 connection (RX, TX and GND), I believe GND is pin 7 on a 25way, and I believe that 2 and 3 are reversed, is to disable all flow control and force control lines on, and ignore carrier detection etc.

    Commands such as:
    AT&Cx
    AT&Sx
    AT&Dx

    Dont forget to AT&W to save the profile.

    Some modems require an ATZ to load the default profile on startup, I have a 56k Modem with an Agere chipset, which misbehaves very badly if it doesn't receive an ATZ as its first command!

    It really can be modem dependant. Also check your connections to the MAX232.

    Remember, Pin 13 (R1In) goes to Pin 3 (TX), Pin 14 (T1Out) goes to Pin 2 (RX) on a 9 WAY 232 Connection, also dont forget to connect Pin 5 to GND, it is used as a reference to the RX/TX lines.
    Pin 11 (T1In) goes to your MCU TX, and Pin 12 (R1Out) goes to your MCU RX.

    Dont forget to read your datasheet!! Some 232 chips require 0.1uF caps (also take note of polarity if using polarised caps) and some require 1uF caps, and dont forget the decoupling cap on the power supply (0.1uF will suffice).

    If using a 25 way 232, Pin 3 is RX and Pin 2 is TX and Pin 7 is GND, so basically using the above guide, just swap Pins 2 and 3 around and connect Pin 7 to GND instead of Pin 5.

    Also, if your modem is TTL you can ignore the MAX232 chip, but dont forget to connect RX to TX and vice versa between the modem and MCU.
    Hope this helps some people out with their issues!

    Regards

    Wilksey
     
  19. Ratheeshbr

    Ratheeshbr New Member

    Joined:
    Apr 4, 2007
    Messages:
    12
    Likes:
    0
    Gsm-pic

    HI
    Sathiesh,
    Did your problem get solved?
    I am also at the same stage!
     
  20. athul

    athul New Member

    Joined:
    Jan 30, 2011
    Messages:
    3
    Likes:
    0
    hi..
    i am also doing a project which requires interfacing of pic 16f877 with a gsm module .. can u pls give me the interfacing diagram immediately?
     
  21. Ratheeshbr

    Ratheeshbr New Member

    Joined:
    Apr 4, 2007
    Messages:
    12
    Likes:
    0
    Hope this will be enough

    [PIC] ======== [MAX232] ======== [GSM MODEM]
    [RX,TX] [TX,RX]

    RX of PIC goes to TX of GSM modem
    TX of PIC goes to RX of GSM modem
    in between you add the MAX232 IC for level conversion (you can see its pin connection from its datasheet)
    Also make sure you common out the GND (ground)
     

Share This Page