Hi,
I am using one of these small and basic SIM800L modules in my project (see attached image)
I have the module up and running fine and I can send SMS messages from the SIM800L with no problems.
What I want to do now is receive SMS messages, process them and act on the instructions.
There are LOTS of examples on the internet but most of them are outdated, don't do what I want or rely on libraries to do them.
I really don't want to use a library because space is precious in my project and libraries with functions and features I wont use are just wasted space.
To send SMS messages I have a simple function which communicates with the SIM800L module over serial directly and this seems to work every time it's asked to work. Code included below.
// SEND SMS DATA / MESSAGES FUNCTION
void txSMS(){
//char smsAlertMsg[] = "Timer A Transmission Successful"; //SMS Alert Message - TESTING SIMPLE TEXT MESSAGE
if(powerState == 0){
digitalWrite(PWR_EN, HIGH); // MAIN POWER CONTROL - TURN ON MAIN 3.7V POWER - DC REGULATOR - LOW = OFF | HIGH = ON
delay(450);
powerState = 1;
}
digitalWrite(GSM_PWR, HIGH); // GSM POWER CONTROL - TURNS GSM ON - LOW = OFF | HIGH = ON
delay(20000); // Wait for Network Connection to Establish (LED Blinks Once Every Second)
Serial.println(F("AT+CMGF=1")); // Set Modem to SMS TEXT MODE READY FOR SENDING SMS
delay(100);
Serial.print(F("AT+CMGS=\""));
Serial.print(mobNumber);
Serial.print(F("\"\r"));
delay(100);
//Serial.println(smsAlertMsg); // testing
float temperature = averageTemperature(temperatures, opHours);
//float battLevel = averageBattLevel(battLevels, opHors);
Serial.print(F("Average Temp: "));
Serial.print(temperature);
//Serial.println("Battery V: ");
//Serial.print(battLevel);
Serial.print((char)26);
delay(100);
Serial.println();
delay(2000);
if(powerState == 1){
digitalWrite(PWR_EN, LOW); // MAIN POWER CONTROL - TURN OFF MAIN 3.7V POWER - DC REGULATOR - LOW = OFF | HIGH = ON
powerState = 0;
}
digitalWrite(GSM_PWR, LOW); // GSM POWER CONTROL - TURNS GSM OFF - LOW = OFF | HIGH = ON
}
The function above sends me the average temperature based on several readings taken over the period the project is awake and working.
What I Want to Do:-
My project spends most of its time in Power Down Sleep Mode until it's time to wake up, take readings and send data back home.
But at least twice per day, I want to wake the project up, check the GSM module for any new SMS messages and process / act on them if there are.
I have a list of 30 commands which all start with a 3 character prefix and then an option. Such as:
ABC = 1 or 0
CDE = 1 or 0
but a couple of commands take float values such as 144.0000. E.g.
RXF = 144.0000
and a couple of commands take integer values such as
SQL = 11
VOL = 10
These are all program variables I want to be able to change / update via SMS instruction.
How I would like it to work is like this:
My project wakes up and powers up the GSM module.
Then check to see if there are any new SMS messages.
Read the SMS message(s) and store them in the arduino for processing.
Turn off the GSM module to save power and process the SMS messages.
Update any variables etc and perform any actions
Go back to sleep.
The part I'm now stuck on is how to read in SMS messages from the GSM, store them temproarily and then process them.
I need to be able to process a single command instruction OR multiple instructions.
So for example, I want to turn ABC off. I send ABC0. But later I want to issue several commands such as: ABC0, CDE1, FRQ144.000, SQL5
Now I'm already using 36% of Progmem in my Atmega and 41% Dynamic Memory so whatever solution I go with must be pretty streamlined.
I have tried several different codes and such from the internet but I've had no luck with any of them.
Any ideas or pointers in the right direction welcomed.
Thanks!