Go Down

Topic: Sending SMS for Remote Control - SOLVED (Read 748 times) previous topic - next topic

Fuksen

Jan 06, 2018, 10:47 pm Last Edit: Jan 09, 2018, 09:11 am by Fuksen
Anybody here having experience with sending SMS to a SIM900 GPRS Shield connected to Uno?

I have been trying with two different geeetech.com shields without success. Receiving SMS by the shield appears to be the part not working, because making SMS or voice calls works perfectly ok. I have been trying with different codes, but still not receiving SMS. I am using pin 7 and pin 8 for serial connection to Uno. Both module are connected to gnd of course and they are powered from each their 5V ps via Vin. By the way, I tried with "AT serial control", Typing AT in the serial monitor results a feed-back of the typed AT command - but the "OK" acknowledge, did not come!

Below you see the code I'm using for receiving the SMS.
It should be waiting my SMS call (having the message with either ... #a0 ... or ... #a1 ... ) from the mobile phone and upon receipt reading/converting the SMS message to turn on/off pin 13 of Uno. The only reaction I get is, that the serial monitor on start op the shield, prints the word Ready...

The below code looks simple, but the shield or code do not work! I guess it should work with any GPRS shield having SIM900!
Link to the project: https://www.geeetech.com/wiki/index.php/GPRS_Shield_V2.0#Interface_Function

Code: [Select]

#include <SoftwareSerial.h>

char inchar; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(7,8);

int led = 13;

void setup()
{
Serial.begin(19200);
// set up the digital pins to control
pinMode(led, OUTPUT);
digitalWrite(led, LOW);

// wake up the GSM shield
SIM900.begin(19200);
delay(20000); // give time to log on to network.
SIM900.print("AT+CMGF=1\r"); // set SMS mode to text
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0\r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(100);
Serial.println("Ready...");
}

void loop()
{
//If a character comes in from the cellular module...
if(SIM900.available() >0)
{
 inchar=SIM900.read();
 if (inchar=='#')
 {
   delay(10);

   inchar=SIM900.read();
   if (inchar=='a')
   {
     delay(10);
     inchar=SIM900.read();
     if (inchar=='0')
     {
       digitalWrite(led, LOW);
     }
     else if (inchar=='1')
     {
       digitalWrite(led, HIGH);
     }
     delay(10);
      SIM900.println("AT+CMGD=1,4"); // delete all SMS
   }
 }
}
}

mallison359


Go Up