SIM800L - Help & Guidance Required on Reading and Processing SMS Instructions

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!

Well, ain't that always the way. You spend hours searching online and find nothing and the moment you post in a forum asking for help, a potential solution rears its head lol.

I've been doing some more searching since posting my OP and I found this library by Cristian Steib.

I've not seen or tried this library before and it seems to be a lot lighter than the GSM lib so I'm going to see if I can work with it and adapt my program to use it for sending and receiving SMS messages. - which is all my program needs to do.

I've included the library in my sketch and have compiled it and it doesn't to take up much space at all.

With the library compiled into my program, my Progmem usage is at 37% and my Dynamic Memory is up to 42% so not bad at all. I can live with that.

Now I need to test it to see if A) It works on its own and B) If I can get it to work in my program.

If this works and I can keep the code for processing received SMS instructions down to a bare minimum, I might be okay. 30 available commands is a lot to program in and I'm just praying I can fit it all in the space remaining on the Atmega without getting to the point it's so packed, it becomes unstable.

I will report back later with my results.....

Thanks.

EDIT: I meant to ask for an opinion on something else.......

I've been taking a casual look at using EEPROM to store all the variable values that can be updated / changed by SMS instruction(s). As stated in my OP I will have around 30 variables which can be set / updated by SMS.

At the minute, I've assigned all these variables as Global Variables at the start of my code with each having a default starting value but I'm wondering if there's any benefit to moving these values into EEPROM storage besides freeing up space and retaining the values after a reset / power loss?

I am however going to be storing the Battery Voltage readings into EEPROM because I don't want to lose those readings when the power drops in the battery - so while I'm doing that, if there's anything else that might benefit from being stored into EEPROM for reasons I don't know about then I'd like to hear them so I can concentrate on writing that area in one go.

Thanks!