Arduino with sim900 module is disabled after a day or course sim900 module is completely safe and always receives sms but the Arduino module led after one or more days is no longer able to enable or disable. #include <SoftwareSerial.h> SoftwareSerial SIM900 (7, 8); char incoming_char = 0; // Will hold the incoming character from the Serial Port. int led_status = 0; int led1 = 10; int led2 = 13; void setup () { pinMode (led1, OUTPUT); pinMode (led2, OUTPUT); SIM900power (); Serial.begin (19200); // Set the baud rate SIM900.begin (19200); // For GSM shield delay (20000); // Give time to log on to network.
SIM900.print ( "AT + CMGF = 1 \ r"); // Set SMS mode to text delay (100); SIM900.println ( "AT + CNMI = 2,2,0,0,0 \ r"); //SIM900.print("AT+CLIP=1\r "); // Turn on caller ID notification
digitalWrite (led1, LOW); // Set led to LOW digitalWrite (led2, LOW); // Serial.println ( "AT + CMGD = 1,4"); // Delete all SMS in box }
void sendSMS (char led_status) {// SEND SMS
SIM900.print ( "AT + CMGF = 1 \ r"); // AT command to send SMS message delay (1000); SIM900.println ( "AT + CMGS = " + 9xxxxxxxx \ "\ r"); // Recipient's mobile number, in international format delay (1000); if (led_status == 0) { SIM900.println ( "ALARM ON"); } else
#include <SoftwareSerial.h>
SoftwareSerial SIM900 (7, 8);
char incoming_char = 0; // Will hold the incoming character from the Serial Port.
int led_status = 0;
int led1 = 10;
int led2 = 13;
void setup () {
pinMode (led1, OUTPUT);
pinMode (led2, OUTPUT);
SIM900power ();
Serial.begin (19200); // Set the baud rate
SIM900.begin (19200); // For GSM shield
delay (20000); // Give time to log on to network.
SIM900.print ( "AT + CMGF = 1 \ r"); // Set SMS mode to text
delay (100);
SIM900.println ( "AT + CNMI = 2,2,0,0,0 \ r");
//SIM900.print("AT+CLIP=1\r "); // Turn on caller ID notification
digitalWrite (led1, LOW); // Set led to LOW
digitalWrite (led2, LOW);
// Serial.println ( "AT + CMGD = 1,4"); // Delete all SMS in box
}
void sendSMS (char led_status) {// SEND SMS
SIM900.print ( "AT + CMGF = 1 \ r"); // AT command to send SMS message
delay (1000);
SIM900.println ( "AT + CMGS = \" + 9xxxxxxxx \ "\ r"); // Recipient's mobile number, in international format
delay (1000);
if (led_status == 0)
{
SIM900.println ( "ALARM ON");
}
else
{
SIM900.println ( "ALARM OFF");
}
delay (1000);
SIM900.println ();
delay (5000); // Give module time to send SMS
}
void SIM900power ()
// Software equivalent of pressing the GSM shield "power" button
{
digitalWrite (9, HIGH);
delay (1000);
digitalWrite (9, LOW);
delay (7000);
}
void loop () {
// # A1s on & # a0s off
if (SIM900.available ()> 0)
{
incoming_char = SIM900.read ();
if (incoming_char == '#')
{
delay (10);
incoming_char = SIM900.read ();
if (incoming_char == 'a')
{
delay (10);
incoming_char = SIM900.read ();
if (incoming_char == '0')
{
digitalWrite (led1, LOW);
digitalWrite (led2, LOW);
}
else if (incoming_char == '1')
{
digitalWrite (led1, HIGH);
digitalWrite (led2, HIGH);
}
else if (incoming_char == 'S')
{
digitalRead (led1);
led_status = digitalRead (led1);
led_status = digitalRead (led2);
Serial.print (led_status); // Prints status on serial terminal
sendSMS (led_status);
}
delay (10);
}
// End AT command with a ^ Z, ASCII code 26
delay (5000);
led_status = digitalRead (led1);
led_status = digitalRead (led2);
Serial.print (led_status); // Prints status on serial terminal
sendSMS (led_status);
SIM900.println ((char) 26);
}
}
}
delay (1000); SIM900.println (); delay (5000); // Give module time to send SMS } void SIM900power () // Software equivalent of pressing the GSM shield "power" button { digitalWrite (9, HIGH); delay (1000); digitalWrite (9, LOW); delay (7000);
}
void loop () { // # A1s on & # a0s off if (SIM900.available ()> 0) { incoming_char = SIM900.read (); if (incoming_char == '#') { delay (10); incoming_char = SIM900.read (); if (incoming_char == 'a') { delay (10); incoming_char = SIM900.read (); if (incoming_char == '0') { digitalWrite (led1, LOW); digitalWrite (led2, LOW); } else if (incoming_char == '1') { digitalWrite (led1, HIGH); digitalWrite (led2, HIGH); } else if (incoming_char == 'S') { digitalRead (led1); led_status = digitalRead (led1); led_status = digitalRead (led2); Serial.print (led_status); // Prints status on serial terminal sendSMS (led_status); } delay (10); } // End AT command with a ^ Z, ASCII code 26
delay (5000);
led_status = digitalRead (led1); led_status = digitalRead (led2); Serial.print (led_status); // Prints status on serial terminal sendSMS (led_status); SIM900.println ((char) 26); } } }