Modify GSM module code to receive SMS and do actions accordingly

Hello there!

I'm new here and to Arduino! I'm sorry first of all for my English, I'm not a native speaker but I will try my best to explain my situation to you. So I'm making a project with a device. Device consists of a 4 contact relay, Arduino UNO connected to a GSM/GPRS module, PIR sensor and a 4x4 keypad. Now I have the code which works with my GSM module to receive and send SMS messages but I need to modify it so I could when I receive SMS accordingly do something (for example: turn 1st relay contact, turn all on and so on...) On top of that I'll also add 4x4 keypad which will basically do the same but on the button presses accordingly, so I'll need to figure out how to make them friendly to each other and error-free And there will be a PIR sensor implemented too but I don't think it will be hard to make it work with the rest of the code. So here I upload the "barebones" of the code to only receive and send SMS, any ideas how to modify it as I has described above? I also add .word file that is basically the structure I'll be making my project. 1 button on the keypad will turn on the relay contact 1 and at the same time SMS message "ON1" would do the same thing and so on...

Thanks for asnwers and suggestions!!

EDIT: Oops looks like this forum doesn't accept .word files, so I guess you'll just have to kind of imagine the working principle I'm trying to achieve!

SMSSender.ino (1.28 KB)

I made some adjustments and now the device suppose to be programmed for main 8 functions with SMS and keypad. I don't know if it works yet because I don't have my arduino in hand now. But my concern is the part where I make my char array sms_text = sms_content <-- which is string. Can I do something like that? Maybe there is another way to do this?

Thanks!

SMSSender.ino (5.5 KB)

Hello again!

I have managed to succesfully create code for my 4x4 keypad matrix to turn on relays, BUT as soon as I plug in my gsm/gprs shield to arduino, something goes wrong - I think that gsm shield and keypad module doesn't work with each other and I dont know how to fix that. So the thing is as soon as plug in the GSM shield keypad doesn't work AT ALL! And let's say when I press 'C' or 'D' on keypad the blue light on the GSM shield lights up and it seems that the shield just restarts. I upload my code so you can take a look at it. Please, maybe someone knows how to make them work together or maybe I am missing something?

Thanks!

SMSSender.ino (4.17 KB)

Hello again!

I've managed to somehow connect GSM with my Keypad without disabling functionality of the keypad, but now, everytime my loop which looks like this:

if (sms_position) 
       {
           // read new SMS
           Serial.print("SMS postion:");
           Serial.println(sms_position,DEC);
           sms.GetSMS(sms_position, phone_number, sms_text, 100);
           // now we have phone number string in phone_num
           Serial.println(phone_number);
           // and SMS text in sms_text
           Serial.println(sms_text);
       }   
       else
       {
           Serial.println("NO NEW SMS,WAITTING");
       }     
       delay(1000);

returns me -2 as a sms_position, so it keeps going and overloading the program and my keypad is working very slowly, and it does not receive any messages and I think that's the problem why. But why does it give -2, not -1 or something, how the hell does this even happen? Maybe some of you guys have encountered such problem before and could help me out? Thanks!

This is the GSM shield I use: https://www.ebay.com/itm/SIM900-Quad-band-GSM-GPRS-Shield-for-Arduino-UNO-MEGA-Leonardo/221176159800?epid=1555353015&hash=item337f205e38:g:ZgEAAOSw-29ZPqAk

Hello again!

I think I've managed to find out the problem. If someone experiences same problems, make sure your 2 and 3 digital i/o's are not connected to anything! Because software serial uses those 2 pins to communicate, and I thought it would use the rx and tx pins - guess I was wrong.

Happy coding!