Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

Has someone come up with a solution with the above stated problem?

We are using Arduino Duemilanove and SIM 900 GSM module (http://robokits.co.in/shop/index.php?main_page=product_info&products_id=303)

We've tried to work on the similar problem of lightning Leds from port 9-12 when we send an sms #aibicidi, where i = 0 or 1, 0 =off, 1=on. Eg. #a1b1c1d1 will switch on all the Led's.

When we upload the code and run it through serial monitor and enter the #a1b1c1d1 in the serial monitor, we can see all the led's lighten up. But if we send the sms with having content "#a1b1c1d1", we dont see any function of leds.

It would be great if anyone can give some guidance about the same.

 char inchar; //Will hold the incoming character from the Serial Port.


 int led1 = 9;
 int led2 = 10;
 int led3 = 11;
 int led4 = 12;

 void setup()
 {
 // prepare the digital output pins
 pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(led3, OUTPUT);
 pinMode(led4, OUTPUT);
 digitalWrite(led1, LOW);
 digitalWrite(led2, LOW);
 digitalWrite(led3, LOW);
 digitalWrite(led4, LOW);
 //Initialize GSM module serial port for communication.


 Serial.begin(9600);
 delay(3000); // give time for GSM module to register on network etc.
 Serial.println("AT+CMGF=1"); // set SMS mode to text
 delay(200);
 Serial.println("AT+CNMI=3,3,0,0"); // set module to send SMS data to serial out upon receipt 
 delay(200);
 }

 void loop() 
 {
 //If #a1b1c1d1 comes as sms, all led's should light up.
 if(Serial.available() >0)
 {
 inchar=Serial.read(); 
 if (inchar=='#')
   {
   delay(10);
   inchar=Serial.read(); 

 //first led
   if (inchar=='a')
     {
   delay(10);
   inchar=Serial.read();

 if (inchar=='0')
   {
   digitalWrite(led1, LOW);
   } 
 else if (inchar=='1')
   {
   digitalWrite(led1, HIGH);
   }
 delay(10);


 //Second led
 inchar=Serial.read(); 

 if (inchar=='b')
   {
   inchar=Serial.read();
 if (inchar=='0')
 {
 digitalWrite(led2, LOW);
 } 

 else if (inchar=='1')
 {
 digitalWrite(led2, HIGH);
 }
 delay(10);

 // Third led
 inchar=Serial.read(); 
 if (inchar=='c')
 {
 inchar=Serial.read();
 if (inchar=='0')
 {
 digitalWrite(led3, LOW);
 } 
 else if (inchar=='1')
 {
 digitalWrite(led3, HIGH);
 }
 delay(10);

 //Fourth led

 inchar=Serial.read(); 
 if (inchar=='d')
 {
 delay(10);
 inchar=Serial.read();
 if (inchar=='0')
 {
 digitalWrite(led4, LOW);
 } 
 else if (inchar=='1')
 {
 digitalWrite(led4, HIGH);
 }
 delay(10);
 }
 }
 Serial.println("AT+CMGD=1,4"); // delete all SMS
 }
 }
 }
 }
 }
share|improve this question
 
I was able to solve the above state problem. Get to this link, to the last post: edaboard.com/thread284929.html –  Uttam Pal Apr 17 at 10:47
1  
You may want to put your experience down as an answer, elaborating a bit on the content of your provided link, then accept your own answer. Not a link-only answer, of course, as those add little value to this site, and become meaningless when the link target changes location or the site dies at some point. –  Anindo Ghosh May 24 at 5:40
add comment

2 Answers

your code is good for serial terminal, but not for GSM modem. It always take command in form of AT use AT+CMGR=1 to read the message.... send this command to modem and see the reply....

share|improve this answer
 
This would retrieve 1 message, but without deleting it, the same message would remain in the queue, choking the application. –  Anindo Ghosh May 24 at 5:38
add comment

Do the modification AT+CNMI=2,2,0,0,0 instead of AT+CNMI=3,3,0,0 from our previous code. Then the relay will work.

share|improve this answer
1  
What on earth does "our previous code" refer to? –  Dave Tweed Aug 23 at 11:15
 
@Dave Tweed It is a reference to an answer in a thread on the board linked to in the comment posted by OP on his own post. Perfectly simple old chap. LOL. –  mikeY Aug 23 at 15:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.