|
Post by agz2007 on Jan 19, 2023 17:44:54 GMT
Hello,
I've used this module to set up a bunch of triggers that send SMS alerts, but I was wondering if there is a command or something I could use to display on an LCD if the sim module is connected and operational. I would also use this command to prevent other parts of the code from running for example this bit of code. is there something I could use that would prevent the ESP32 from sending the texts if fona is not ok? Also, is there a way to send SMS messages to the SIM7000 module so that I can remotely start and stop a pump?
if (percent < bLimit && bat == false) {
batSMS ();
bat = true;
}
void batSMS () {
char message2[25];
strcpy(message2, batBuff);
strcat(message2, text_message3);
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() && (millis() < 30000)) {
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, message2)) {
Serial.println(F("Failed to send text!"));
}
else {
Serial.println(F("Sent text alert!"));
}
}
|
|
|
Post by Botletics on Jan 20, 2023 3:44:48 GMT
Please see the SMS_Response example for sending SMS to the SIM7000 to have it do stuff. As far as checking whether or not it's connected to the network, you could just use getNetworkStatus() and check if it's 1 or 5 like the example code does.
|
|
|
Post by agz2007 on Feb 6, 2023 23:09:48 GMT
Please see the SMS_Response example for sending SMS to the SIM7000 to have it do stuff. As far as checking whether or not it's connected to the network, you could just use getNetworkStatus() and check if it's 1 or 5 like the example code does. Thank you so much, I got it to work. Thanks! bool Status() { int n = fona.getNetworkStatus();
Serial.print(F("Network status ")); Serial.print(n); Serial.print(F(": "));
if (n == 0){ Serial.println(F("Not registered"));
lcd.setCursor(0, 1);
lcd.print("Not registered ");
}
if (n == 1) { Serial.println(F("Registered (home)"));
lcd.setCursor(0, 1);
lcd.print("Registered (home)");
}
if (n == 2){ Serial.println(F("Not registered (searching)"));
lcd.setCursor(0, 1);
lcd.print("Not registered ");
}
if (n == 3){ Serial.println(F("Denied"));
lcd.setCursor(0, 1);
lcd.print("Denied ");
}
if (n == 4){ Serial.println(F("Unknown"));
lcd.setCursor(0, 1);
lcd.print("Unknown ");
}
if (n == 5){ Serial.println(F("Registered roaming"));
lcd.setCursor(0, 1);
lcd.print("Connected ");
}
if (!(n == 1 || n == 5)) false;
else return true;
}
|
|