Help with code using SIM7600 4G Hat and Arduino

I am using the attached code to send & receive SMS messages between my phone and the SIM7600 unit. I am currently running into a problem where the unit says "+SMS FULL" in the serial monitor when it receives a text from me. I have tried moving around the deleteSMS command but can not find a spot that provides correct results. Any help would be greatly appreciated.

#include <OneWire.h>                // These Libraries allow concise interpretation of the
#include <DallasTemperature.h>      // measurements from the Dallas temperature sensor
#include <SoftwareSerial.h>
#include "Adafruit_FONA.h"

#define tempData 2                  // Temperature data is read through digital pin 2
#define GSM_TX  3
#define GSM_RX  4
#define GSM_PWR 5
#define GSM_RST 20                  // Random number?
#define GSM_BAUD  9600


SoftwareSerial SIM7600SS = SoftwareSerial(GSM_TX, GSM_RX);
SoftwareSerial *SIM7600Serial = &SIM7600SS;

OneWire myWire(tempData);           // OneWire object creation named "myWire"
DallasTemperature sensors(&myWire); // Pass our oneWire reference to Dallas Temperature sensor 


Adafruit_FONA SIM7600 = Adafruit_FONA(GSM_RST);

char handlerNumber[32] = "**********";
char SIM7600InBuffer[64];           // For incoming SMS
char SMSbuffer[32];                 // Store the SMS content in here
uint16_t SMSLength;
String SMSString = "";

static int inOut = 0;
int Updates = 10;
int Upper = 85;
int Lower = 30;
int x = 0;
int y = 0;
int z = 0;

void setup() {

  pinMode(GSM_PWR, OUTPUT);
  pinMode(GSM_PWR, INPUT_PULLUP);

  Serial.begin(115200);
  Serial.println("Interfacing SIM7600 GSM Module with Arduino UNO");
  Serial.println("Initializing... (May take a minute)");


  SIM7600Serial->begin(GSM_BAUD);              // 9600 Baud, slow so we can follow
  if (!SIM7600.begin(*SIM7600Serial)) {
    Serial.println("Couldn't find SIM7600");
    while (1);                                          
  }
  Serial.println(F("SIM7600 is OK"));          // Uses flash-based memory

  Serial.println("GSM is ready!");

  SIM7600.sendSMS(handlerNumber, "Hello, welcome to the K9 Environmental Monitor Unit.\n\nIs your dog located inside or outside?");
  
  sensors.begin();                  // Initialize the DS18B20 temperature sensor

   
}

void loop() {

  
  char* bufPtr = SIM7600InBuffer;        // Create a pointer to the location of the incoming text


  if (SIM7600.available()) {             // If there is data incoming
    int slot = 0;                        // This will be the slot number of the SMS
    int charCount = 0;

    if (z == 0){
       for(int x = 0; x < 4; x = x + 1) {
          boolean deleteSMSDone = SIM7600.deleteSMS(slot);
          if (deleteSMSDone == true) {
            Serial.println("OK!");
            z = 1;
            break;
          }
        }
    }

    do {
      *bufPtr = SIM7600.read();          // Store the read incoming SMS
      Serial.write(*bufPtr);             // Write it to the serial monitor (non-ASCII)
      delay(1);

      // While not at the end of the string, there is more available, and we have room to store it
    } while ((*bufPtr++ != '\n') && (SIM7600.available()) && (++charCount < (sizeof(SIM7600InBuffer) - 1))); 

    *bufPtr = 0;                         // Add a terminal NULL

    if (1 == sscanf(SIM7600InBuffer, "+CMTI: \"SM\",%d", &slot)) {  // Scan string for an SMS recieved notification
      Serial.print("slot: ");                                       // If there was an SMS, get slot #
      Serial.println(slot);

      if (!SIM7600.getSMSSender(slot, handlerNumber, 31)) {        // Get sender phone number 
        Serial.println("Didn't find SMS message in slot!");
      }
      Serial.print("FROM: "); 

      if (!SIM7600.readSMS(slot, SMSbuffer, 250, &SMSLength)) {     // Pass in buffer and max length
        Serial.println("Failed!");
      }
      else {
        SMSString = String(SMSbuffer);
        Serial.print("SMS: "); 
        Serial.println(SMSString);
      }

      if (x = 1){
         Updates = SMSString.toInt();
         Serial.println(Updates);
         x = 0;
      }
      if (x = 2){
         Upper = SMSString.toInt();
         Serial.println(Upper);
         x = 0;
      }
      if (x = 3){
         Lower = SMSString.toInt();
         Serial.println(Lower);
         x = 0;
      }


  // Begin to compare strings


      // Is the dog located inside or outside
      if (SMSString == "Inside"){
         inOut = 0;
         SIM7600.sendSMS(handlerNumber, "Default Settings:\n\n-Update every 10 minutes\n-Upper temperature limit: 85\n-Lower temperature limit: 30\n\nWould you like to change these settings? (Yes/No)");
      }
      else if (SMSString == "Outside"){
         inOut = 1;
         SIM7600.sendSMS(handlerNumber, "Default Settings:\n\n-Update every 10 minutes\n-Upper temperature limit: 85\n-Lower temperature limit: 30\n\nWould you like to change these settings? (Yes/No)");
      }

      // Would you like to update the settings
      if (SMSString == "Yes"){
         SIM7600.sendSMS(handlerNumber, "Ok, which parameter?\n\nEnter Updates, Upper or Lower.");
      }
      else if (SMSString == "No"){
         SIM7600.sendSMS(handlerNumber, "Ok, default settings it is!\n\nRespond with Settings at any time to view the current parameters");
      }

      // What would you like to update
      if (SMSString == "Updates"){
         x = 1;
         SIM7600.sendSMS(handlerNumber, "How often would you like sensor updates? (In minutes)");
      }
      else if (SMSString == "Upper"){
         x = 2;
         SIM7600.sendSMS(handlerNumber, "What would you like the upper temperature limit to be?");
      }
      else if (SMSString == "Lower"){
         x = 3;
         SIM7600.sendSMS(handlerNumber, "What would you like the lower temperature limit to be?");
      }

// THIS IS THE DELETE FUNCTION

       while(1) {
          boolean deleteSMSDone = SIM7600.deleteSMS(slot);
          if (deleteSMSDone == true) {
            Serial.println("OK!");
            break;
          }
          Serial.println("YO BITCH IM RIGHT HERE");
        }

   }
 

    static int tempReading;

    sensors.requestTemperatures();    // Send request to get temperature readings

    tempReading = sensors.getTempFByIndex(0);
//    Serial.print(tempReading);     // "ByIndex(0) refers to the first temp sensor in
//    Serial.print(" - Fahrenheit temperature: ");  // a circuit. Many temp sensors can be strung together.
//    Serial.println(sensors.getTempFByIndex(0));

    if ((tempReading >= Upper) && (y = 0)){
      SIM7600.sendSMS(handlerNumber, "Warning - Upper Temperature Limit Reached!");
      Serial.println(Upper);
      Serial.println(tempReading);
      y = 1;
    }
    
  
  }
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.