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

Sim900 not working with Arduino

Discussion in 'Arduino' started by Vicky58911, Sep 7, 2017.

  1. Vicky58911

    Vicky58911 New Member

    Joined:
    Sep 7, 2017
    Messages:
    3
    Likes:
    0
    Recently I bought Sim900a module and Arduino Mega 2560 to run my old code for sending sms and call, but now there is a problem as I am unable to send sms or either call, my code is attached below.



    #include <SoftwareSerial.h>
    SoftwareSerial gsm(2,3);
    void setup()
    {
    gsm.begin(9600); // Setting the baud rate of GSM Module
    Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
    delay(100);
    }
    void loop()
    {
    if (Serial.available()>0)
    switch(Serial.read())
    {
    case 's':
    Send();
    break;
    case 'r':
    Recieve();
    break;
    case 'S':
    Send();
    break;
    case 'R':
    Recieve();
    break;
    }
    if (gsm.available()>0)
    Serial.write(gsm.read());
    }
    void Send()
    {
    Serial.print("Sending");
    gsm.println("AT+CMGF=1");
    delay(1000);
    gsm.println("AT+CMGS=\"+xxxxxxxxxxxx\"\r"); // Replace x with mobile number
    delay(1000);
    gsm.println("Hello I am GSM modem!!!");// The SMS text you want to send
    delay(100);
    gsm.println((char)26); // ASCII code of CTRL+Z
    delay(1000);
    }
    void Recieve()
    {
    Serial.print("Receiving");
    gsm.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
    delay(1000);
    }
     
  2. Wp100

    Wp100 Active Member

    Joined:
    Feb 3, 2009
    Messages:
    964
    Likes:
    43
    Location:
    England
  3. Vicky58911

    Vicky58911 New Member

    Joined:
    Sep 7, 2017
    Messages:
    3
    Likes:
    0
    I am currently living in Pakistan, Asia and I bought the correct sim900a module as mentioned in your link from http://www.w11stop.com/simcom-gsm-sim-900a-module
    my sim900a is working fine as this module has been used for other projects also. I think the problem lies either with my code or my arduino mega.
     
  4. dave

    Dave New Member

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


     
  5. Wp100

    Wp100 Active Member

    Joined:
    Feb 3, 2009
    Messages:
    964
    Likes:
    43
    Location:
    England

    Have a look at this link and also search on 'software serial with arduino mega'
    https://www.arduino.cc/en/Reference/SoftwareSerial
     
  6. Vicky58911

    Vicky58911 New Member

    Joined:
    Sep 7, 2017
    Messages:
    3
    Likes:
    0
    The code worked when i changed the software serial from(2,3) to (10,11) since Arduino Mega does not support software serial on (2,3) pins
     

Share This Page