SIM module continuously sending SMS messages after threshold reached

Looks like that is because...

  if (tempF < tLimit && opened == false) {
    ColdSMS ();
    opened = true;
  }

opened gets set to true when the cold SMS is sent, which stops any further cold SMS getting sent.

But then if the switch is triggered or the volume goes above the threshold...

  if (buttonState == HIGH && lastButtonState == LOW || totalMilliLitres > 300 && totalMilliLitres - flowRate <= 300) {
    opened = false;
    lastButtonState = buttonState;
    FullSMS ();
  }

opened gets set to false again, which allows another cold SMS to be sent.

Maybe you got confused about what opened is for? Maybe you need another bool variable? You could call it cold or something.

if (tempF < tLimit && cold == false) {
    ColdSMS ();
    cold = true;
  }
1 Like

You're right, I was using the same bool variable for cold as I was for full which doesn't make sense. I created a bool variable for cold and used that and it works perfectly know. The only concern I had was that once it goes below freezing and sends the SMS and the temperature for some reason goes above freezing, and then back below freezing it wont send the SMS.

But I rationalized leaving it alone at this point because it makes no difference if the temperature was below freezing at one point during the cycle, and then again later on in the cycle because for all we know, the liquid could already be frozen.

The other part is that other than acts of god, I don't see how the temperature could drop below freezing, and then go above freezing, and then back below freezing unless the cycle was started during the night, which would generally never happen because the people for who this system is intended for work from 9am-5pm.

Either way, I'll call this sketch the final version for all intents and purposes and hope than anyone who runs across this will find it useful

// For SIM7000 cellular shield
#include "Adafruit_FONA.h" // https://github.com/botletics/SIM7000-LTE-Shield/tree/master/Code
#include <SoftwareSerial.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;
// For SIM7000 shield
#define FONA_PWRKEY 6
#define FONA_RST 7
#define FONA_TX 10 // Microcontroller RX
#define FONA_RX 11 // Microcontroller TX

#define LED 13

// Using SoftwareSerial
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;

Adafruit_FONA_LTE fona = Adafruit_FONA_LTE();

uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);
char imei[16] = {0}; // Use this for device ID
char replybuffer[255]; // Large buffer for replies
uint8_t type;
uint8_t counter = 0;
bool opened = false;
bool cold = false;


char URL[100]; // Make sure this is long enough for your request URL
//char body[100]; // Only need this is you're doing an HTTP POST request

//const int FLOWSWITCH = 2; // Use pin 2 to wake up the Uno/Mega
const int  buttonPin = 3;
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

//int buttonState4 = 0;         // current state of the button
//int lastButtonState4 = 0;     // previous state of the button


const char * phone_number = "+18000000006"; // Include country code, only numbers
const char * text_message1 = "FULL!"; // Change to suit your needs
const char * text_message2 = "FREEZING!"; // Change to suit your needs

int flowPin = 2;    //This is the input pin on the Arduino
double flowRate;    //This is the value we intend to calculate.
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
volatile int count; //This integer needs to be set as volatile to ensure it updates correctly during the interrupt process.
float tempC;
float tempF;
float tLimit = 45.0;
void setup() {
  Serial.begin(115200);
  //  while (!Serial) delay(1); // Wait for serial, for debug
  Serial.println(F("*** Burgalert 7000 ***"));


  pinMode(flowPin, INPUT);           //Sets the pin as an input
  attachInterrupt(0, Flow, RISING);  //Configures interrupt 0 (pin 2 on the Arduino Uno) to run the function "Flow"
  flowRate          = 0.0;
  totalMilliLitres  = 0;
  //pinMode(BUTTON, INPUT); // For the interrupt wake-up to work
  pinMode(FONA_RST, OUTPUT);
  digitalWrite(FONA_RST, HIGH); // Default state
  pinMode(FONA_PWRKEY, OUTPUT);
  pinMode(buttonPin, INPUT);
  powerOn(true); // Power on the module
  moduleSetup(); // Establish first-time serial comm and print IMEI

  fona.setNetworkSettings(F("hologram")); // For Hologram SIM card, change appropriately

  Serial.print("Locating devices...");
  sensors.begin();
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  //  Serial.print("Parasite power is: ");
  //  if (sensors.isParasitePowerMode()) Serial.println("ON");
  //  else Serial.println("OFF");

  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");

  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
  // show the addresses we found on the bus
  Serial.print("Device 0 Address: ");
  printAddress(insideThermometer);
  Serial.println();

  // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
  sensors.setResolution(insideThermometer, 9);

  Serial.print("Device 0 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer), DEC);
  Serial.println();
}

void loop() {
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  printTemperature(insideThermometer); // Use a simple function to print out the data
  tempC = sensors.getTempCByIndex(0);
  tempF = (tempC * 1.8) + 32;
  count = 0;      // Reset the counter so we start counting from 0 again
  //interrupts();   //Enables interrupts on the Arduino

  delay (1000);   //Wait 1 second
  // noInterrupts(); //Disable the interrupts on the Arduino
  // Only send SMS if the switch was closed
  //Start the math
  flowRate = (count * 2.25);        //Take counted pulses in the last second and multiply by 2.25mL
  flowRate = flowRate * 60;         //Convert seconds to minutes, giving you mL / Minute
  flowRate = flowRate / 1000;       //Convert mL to Liters, giving you Liters / Minute
  totalMilliLitres += flowRate;
  buttonState = digitalRead(buttonPin);
  Serial.println(flowRate);         //Print the variable flowRate to Serial
  Serial.println(totalMilliLitres);
  if (buttonState == HIGH && lastButtonState == LOW || totalMilliLitres > 300 && totalMilliLitres - flowRate <= 300) {
    opened = false;
    lastButtonState = buttonState;
    FullSMS ();
  }




  if (tempF < tLimit && cold == false) {
    ColdSMS ();
    cold = true;
  }

}

// Power on/off the module
void powerOn(bool state) {
  if (state) {
    Serial.println(F("Turning on SIM7000..."));
    digitalWrite(FONA_PWRKEY, LOW);
    delay(100); // Turn on module
    digitalWrite(FONA_PWRKEY, HIGH);
    delay(4500); // Give enough time for the module to boot up before communicating with it
  }
  else {
    Serial.println(F("Turning off SIM7000..."));
    fona.powerDown(); // Turn off module
  }
}

void moduleSetup() {
  fonaSS.begin(115200); // Default SIM7000 shield baud rate

  Serial.println(F("Configuring to 9600 baud"));
  fonaSS.println("AT+IPR=9600"); // Set baud rate
  delay(100); // Short pause to let the command run
  fonaSS.begin(9600);
  if (! fona.begin(fonaSS)) {
    Serial.println(F("Couldn't find FONA"));
    while (1); // Don't proceed if it couldn't find the device
  }

  type = fona.type();
  Serial.println(F("FONA is OK"));
  Serial.print(F("Found "));
  switch (type) {
    case SIM7000A:
      Serial.println(F("SIM7000A (American)")); break;
    case SIM7000C:
      Serial.println(F("SIM7000C (Chinese)")); break;
    case SIM7000E:
      Serial.println(F("SIM7000E (European)")); break;
    case SIM7000G:
      Serial.println(F("SIM7000G (Global)")); break;
    default:
      Serial.println(F("???")); break;
  }

  // Print module IMEI number.
  uint8_t imeiLen = fona.getIMEI(imei);
  if (imeiLen > 0) {
    Serial.print("Module IMEI: "); Serial.println(imei);
  }
}

bool netStatus() {
  int n = fona.getNetworkStatus();

  Serial.print(F("Network status ")); Serial.print(n); Serial.print(F(": "));
  if (n == 0) Serial.println(F("Not registered"));
  if (n == 1) Serial.println(F("Registered (home)"));
  if (n == 2) Serial.println(F("Not registered (searching)"));
  if (n == 3) Serial.println(F("Denied"));
  if (n == 4) Serial.println(F("Unknown"));
  if (n == 5) Serial.println(F("Registered roaming"));

  if (!(n == 1 || n == 5)) return false;
  else return true;

}

void Flow()
{
  count++; //Every time this function is called, increment "count" by 1
}

void FullSMS () {
  pinMode(FONA_RST, OUTPUT);
  digitalWrite(FONA_RST, HIGH); // Default state
  pinMode(FONA_PWRKEY, OUTPUT);
  pinMode(buttonPin, INPUT);
  powerOn(true); // Power on the module
  moduleSetup(); // Establish first-time serial comm and print IMEI

  fona.setNetworkSettings(F("hologram")); // For Hologram SIM card, change appropriately
  while (!netStatus()) {
    Serial.println(F("Failed to connect to cell network, retrying..."));
    delay(2000); // Retry every 2s
  }
  Serial.println(F("Connected to cell network!"));

  // Send a text to your phone!
  if (!fona.sendSMS(phone_number, text_message1)) {
    Serial.println(F("Failed to send text!"));
  }
  else {
    Serial.println(F("Sent text alert!"));
  }
}

void ColdSMS () {
  pinMode(FONA_RST, OUTPUT);
  digitalWrite(FONA_RST, HIGH); // Default state
  pinMode(FONA_PWRKEY, OUTPUT);
  //pinMode(buttonPin, INPUT);
  powerOn(true); // Power on the module
  moduleSetup(); // Establish first-time serial comm and print IMEI

  fona.setNetworkSettings(F("hologram")); // For Hologram SIM card, change appropriately
  while (!netStatus()) {
    Serial.println(F("Failed to connect to cell network, retrying..."));
    delay(2000); // Retry every 2s
  }
  Serial.println(F("Connected to cell network!"));

  // Send a text to your phone!
  if (!fona.sendSMS(phone_number, text_message2)) {
    Serial.println(F("Failed to send text!"));
  }
  else {
    Serial.println(F("Sent text alert!"));
  }
}
void printTemperature(DeviceAddress deviceAddress)
{
  // method 1 - slower
  //Serial.print("Temp C: ");
  //Serial.print(sensors.getTempC(deviceAddress));
  //Serial.print(" Temp F: ");
  //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit

  // method 2 - faster
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == DEVICE_DISCONNECTED_C)
  {
    Serial.println("Error: Could not read temperature data");
    return;
  }
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

The problem that can happen with that occurs when the temperature hovers around freezing. It can appear, because of natural fluctuations or noise in the sensor, that the temperature drops below freezing multiple times, and multiple SMS get sent. One commonly used technique to avoid that is to use "hysteresis". If the temperature rises, for example, a degree (or two, or five) above freezing, the cold flag can be reset ready to detect another drop.

  if (tempF < tLimit && cold == false) {
    ColdSMS ();
    cold = true;
  }
  else if (tempF > tLimit+2.0 && cold == true) {
    cold = false;
  }

You are very talented, that worked perfectly. Now when Temp goes below freezing, then goes above freezing, the flag is reset allowing for a subsequent SMS.

One minor Issue, I'm attempting to include the temperature at the point at which the bool flag is triggered for cold, but I cant seem to figure it out. When I create another SMS variable with
const char * text_messageF = tempBuff; I can only send either tempBuff, or "FREEZING!", but not both. I tried doing if (!fona.sendSMS(phone_number, text_message2, text_messageF)) which didn't work, I also tried const char * text_messageF = tempBuff + "FREEZING!"; which resulted in no joy and finally if (!fona.sendSMS(phone_number, text_message2, text_messageF)). Do you have any advice for this? I tried doing something with sprintf but erased it.

  tempC = sensors.getTempCByIndex(0);
  tempF = (tempC * 1.8) + 32;
  dtostrf(tempF,1, 2, tempBuff);

// For SIM7000 cellular shield
#include "Adafruit_FONA.h" // https://github.com/botletics/SIM7000-LTE-Shield/tree/master/Code
#include <SoftwareSerial.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;
// For SIM7000 shield
#define FONA_PWRKEY 6
#define FONA_RST 7
#define FONA_TX 10 // Microcontroller RX
#define FONA_RX 11 // Microcontroller TX

#define LED 13

// Using SoftwareSerial
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;

Adafruit_FONA_LTE fona = Adafruit_FONA_LTE();

uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);
char imei[16] = {0}; // Use this for device ID
char replybuffer[255]; // Large buffer for replies
uint8_t type;
uint8_t counter = 0;
bool opened = false;
bool cold = false;

char tempBuff[12];
char URL[100]; // Make sure this is long enough for your request URL
//char body[100]; // Only need this is you're doing an HTTP POST request

//const int FLOWSWITCH = 2; // Use pin 2 to wake up the Uno/Mega
const int  buttonPin = 3;
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

//int buttonState4 = 0;         // current state of the button
//int lastButtonState4 = 0;     // previous state of the button


const char * phone_number = "+18000000006"; // Include country code, only numbers
const char * text_message1 = "FULL!"; // Change to suit your needs
const char * text_message2 = "FREEZING!"; // Change to suit your needs
const char * text_messageF = tempBuff;

int flowPin = 2;    //This is the input pin on the Arduino
double flowRate;    //This is the value we intend to calculate.
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
volatile int count; //This integer needs to be set as volatile to ensure it updates correctly during the interrupt process.
float tempC;
float tempF;
float tLimit = 45.0;
void setup() {
  Serial.begin(115200);
  //  while (!Serial) delay(1); // Wait for serial, for debug
  Serial.println(F("*** Burgalert 7000 ***"));


  pinMode(flowPin, INPUT);           //Sets the pin as an input
  attachInterrupt(0, Flow, RISING);  //Configures interrupt 0 (pin 2 on the Arduino Uno) to run the function "Flow"
  flowRate          = 0.0;
  totalMilliLitres  = 0;
  //pinMode(BUTTON, INPUT); // For the interrupt wake-up to work
  pinMode(FONA_RST, OUTPUT);
  digitalWrite(FONA_RST, HIGH); // Default state
  pinMode(FONA_PWRKEY, OUTPUT);
  pinMode(buttonPin, INPUT);
  powerOn(true); // Power on the module
  moduleSetup(); // Establish first-time serial comm and print IMEI

  fona.setNetworkSettings(F("hologram")); // For Hologram SIM card, change appropriately

  Serial.print("Locating devices...");
  sensors.begin();
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  //  Serial.print("Parasite power is: ");
  //  if (sensors.isParasitePowerMode()) Serial.println("ON");
  //  else Serial.println("OFF");

  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");

  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
  // show the addresses we found on the bus
  Serial.print("Device 0 Address: ");
  printAddress(insideThermometer);
  Serial.println();

  // set the resolution to 9 bit (Each Dallas/Maxim device is capable of several different resolutions)
  sensors.setResolution(insideThermometer, 9);

  Serial.print("Device 0 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer), DEC);
  Serial.println();
}

void loop() {
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  printTemperature(insideThermometer); // Use a simple function to print out the data
  tempC = sensors.getTempCByIndex(0);
  tempF = (tempC * 1.8) + 32;
  dtostrf(tempF,1, 2, tempBuff);
  
  count = 0;      // Reset the counter so we start counting from 0 again
  //interrupts();   //Enables interrupts on the Arduino

  delay (1000);   //Wait 1 second
  // noInterrupts(); //Disable the interrupts on the Arduino
  // Only send SMS if the switch was closed
  //Start the math
  flowRate = (count * 2.25);        //Take counted pulses in the last second and multiply by 2.25mL
  flowRate = flowRate * 60;         //Convert seconds to minutes, giving you mL / Minute
  flowRate = flowRate / 1000;       //Convert mL to Liters, giving you Liters / Minute
  totalMilliLitres += flowRate;
  buttonState = digitalRead(buttonPin);
  Serial.println(flowRate);         //Print the variable flowRate to Serial
  Serial.println(totalMilliLitres);
  if (buttonState == HIGH && lastButtonState == LOW || totalMilliLitres > 300 && totalMilliLitres - flowRate <= 300) {
    opened = false;
    lastButtonState = buttonState;
    FullSMS ();
  }


  if (tempF < tLimit && cold == false) {
    ColdSMS ();
    cold = true;
  }
  else if (tempF > tLimit+2.0 && cold == true) {
    cold = false;
  }



}

// Power on/off the module
void powerOn(bool state) {
  if (state) {
    Serial.println(F("Turning on SIM7000..."));
    digitalWrite(FONA_PWRKEY, LOW);
    delay(100); // Turn on module
    digitalWrite(FONA_PWRKEY, HIGH);
    delay(4500); // Give enough time for the module to boot up before communicating with it
  }
  else {
    Serial.println(F("Turning off SIM7000..."));
    fona.powerDown(); // Turn off module
  }
}

void moduleSetup() {
  fonaSS.begin(115200); // Default SIM7000 shield baud rate

  Serial.println(F("Configuring to 9600 baud"));
  fonaSS.println("AT+IPR=9600"); // Set baud rate
  delay(100); // Short pause to let the command run
  fonaSS.begin(9600);
  if (! fona.begin(fonaSS)) {
    Serial.println(F("Couldn't find FONA"));
    while (1); // Don't proceed if it couldn't find the device
  }

  type = fona.type();
  Serial.println(F("FONA is OK"));
  Serial.print(F("Found "));
  switch (type) {
    case SIM7000A:
      Serial.println(F("SIM7000A (American)")); break;
    case SIM7000C:
      Serial.println(F("SIM7000C (Chinese)")); break;
    case SIM7000E:
      Serial.println(F("SIM7000E (European)")); break;
    case SIM7000G:
      Serial.println(F("SIM7000G (Global)")); break;
    default:
      Serial.println(F("???")); break;
  }

  // Print module IMEI number.
  uint8_t imeiLen = fona.getIMEI(imei);
  if (imeiLen > 0) {
    Serial.print("Module IMEI: "); Serial.println(imei);
  }
}

bool netStatus() {
  int n = fona.getNetworkStatus();

  Serial.print(F("Network status ")); Serial.print(n); Serial.print(F(": "));
  if (n == 0) Serial.println(F("Not registered"));
  if (n == 1) Serial.println(F("Registered (home)"));
  if (n == 2) Serial.println(F("Not registered (searching)"));
  if (n == 3) Serial.println(F("Denied"));
  if (n == 4) Serial.println(F("Unknown"));
  if (n == 5) Serial.println(F("Registered roaming"));

  if (!(n == 1 || n == 5)) return false;
  else return true;

}

void Flow()
{
  count++; //Every time this function is called, increment "count" by 1
}

void FullSMS () {
  pinMode(FONA_RST, OUTPUT);
  digitalWrite(FONA_RST, HIGH); // Default state
  pinMode(FONA_PWRKEY, OUTPUT);
  pinMode(buttonPin, INPUT);
  powerOn(true); // Power on the module
  moduleSetup(); // Establish first-time serial comm and print IMEI

  fona.setNetworkSettings(F("hologram")); // For Hologram SIM card, change appropriately
  while (!netStatus()) {
    Serial.println(F("Failed to connect to cell network, retrying..."));
    delay(2000); // Retry every 2s
  }
  Serial.println(F("Connected to cell network!"));

  // Send a text to your phone!
  if (!fona.sendSMS(phone_number, text_message1)) {
    Serial.println(F("Failed to send text!"));
  }
  else {
    Serial.println(F("Sent text alert!"));
  }
}

void ColdSMS () {
  pinMode(FONA_RST, OUTPUT);
  digitalWrite(FONA_RST, HIGH); // Default state
  pinMode(FONA_PWRKEY, OUTPUT);
  
  powerOn(true); // Power on the module
  moduleSetup(); // Establish first-time serial comm and print IMEI
 
  fona.setNetworkSettings(F("hologram")); // For Hologram SIM card, change appropriately
  while (!netStatus()) {
    Serial.println(F("Failed to connect to cell network, retrying..."));
    delay(2000); // Retry every 2s
  }
  Serial.println(F("Connected to cell network!"));

  // Send a text to your phone!
  if (!fona.sendSMS(phone_number, text_messageF)) {
    Serial.println(F("Failed to send text!"));
  }
  else {
    Serial.println(F("Sent text alert!"));
  }
}
void printTemperature(DeviceAddress deviceAddress)
{
  // method 1 - slower
  //Serial.print("Temp C: ");
  //Serial.print(sensors.getTempC(deviceAddress));
  //Serial.print(" Temp F: ");
  //Serial.print(sensors.getTempF(deviceAddress)); // Makes a second call to getTempC and then converts to Fahrenheit

  // method 2 - faster
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == DEVICE_DISCONNECTED_C)
  {
    Serial.println("Error: Could not read temperature data");
    return;
  }
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

Edit: also tried const char * Text3[] = {text_messageF, text_message2}; and then if (!fona.sendSMS(phone_number, Text3)) but gave me an error saying error: no matching function for call to 'Adafruit_FONA_LTE::sendSMS(const char*&, const char* [2])' which I take makes sense in regards to my attempt because Text3 is has an array of two values, text_messageF and text_message2

I have deleted your other cross-post @agz2007.

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

void ColdSMS () {
  char message[20];

  strcpy(message, tempBuff);
  strcat(message, text_message2);

  pinMode(FONA_RST, OUTPUT);
  digitalWrite(FONA_RST, HIGH); // Default state
  pinMode(FONA_PWRKEY, OUTPUT);
  
  powerOn(true); // Power on the module
  moduleSetup(); // Establish first-time serial comm and print IMEI
 
  fona.setNetworkSettings(F("hologram")); // For Hologram SIM card, change appropriately
  while (!netStatus()) {
    Serial.println(F("Failed to connect to cell network, retrying..."));
    delay(2000); // Retry every 2s
  }
  Serial.println(F("Connected to cell network!"));

  // Send a text to your phone!
  if (!fona.sendSMS(phone_number, message)) {
    Serial.println(F("Failed to send text!"));
  }
  else {
    Serial.println(F("Sent text alert!"));
  }
}
1 Like

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