GSM module not working after power off I am making a project on gsm module(sim 900a unofficial shield), when I will send a SMS led will turn ON. after uploading code, module works fine, and led turned ON after sending message. But when I power off sim900a and Arduino, and power on back, it's not working, led not power up after sending message, when I reupload sketches it is working fine, means every time after power off I need to upload code again, I am learning c and don't have much knowledge? Is my code right? Or some other fault?

#include &lt;SoftwareSerial.h&gt; //software serial library for serial communication b/w arduino &amp; GSM

    SoftwareSerial mySerial(8, 9);//connect Tx pin of GSM to pin 8 of arduino &amp;&amp; Rx pin of GSM to pin no 9 of arduino

    int led = 7;
    String message;


    void setup()
    {
      mySerial.begin(9600);   // Setting the baud rate of GSM Module  
      Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
      delay(100);

      mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
      delay(1000);
      pinMode(led,OUTPUT);
      digitalWrite(led,LOW);
    }

    void loop()
    {
      if (mySerial.available()&gt;0){
      message = mySerial.readString();
      }

      if(message.indexOf("ON") &gt; -1){
          Serial.println("LED ON");
         digitalWrite(led,HIGH);
         }
        else if(message.indexOf("OFF") &gt; -1){

          Serial.println("LED OFF");
          digitalWrite(led,LOW);

      }

      delay(10);
    }


Circuit diagram
The GSM takes time to start up.  Your program needs to be far more complex than the simple "Throw commands at it and hope" method you are using.

First you need to query the modem repeatedly until it responds.  This is usually done with the AT command.  A sequence would look like:

Send: AT
(Wait for OK response or timeout)
Send: AT
(Wait for OK response or timeout)
Send: AT
(Wait for OK response or timeout)
Send: AT
(Wait for OK response or timeout)
Recv: OK


Once the modem has booted and is ready to receive commands you can start sending commands.  You shouldn't just "print and delay" though like you are at the moment. Instead you should send the command and then examine the response to see if the command worked ("OK") or failed ("ERR").