Simple and robust C++ library to handle SIM800L chip for sending and receiving SMS
- Receiving SMS (polling approach with callbacks, non-blocking)
- Sending SMS
- Check GSM network connection
- Software reset for the SIM module
- SMS text content is automatically converted to lowercase and normalized
- Some SMS text scanning methods are actually pretty inefficient
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <SIM800L.h>
SoftwareSerial simSerial(5,6); // (RX , TX)
SIM800L sim;
void messageCallback(SMSMessage& sms);
void setup()
{
Serial.begin(115200);
Serial.println("SIM800L TEST");
sim.begin(&simSerial);
Serial.print("Time to start: ");
Serial.print((float)( millis() / 1000.0f ), 1);
Serial.println(" s");
sim.onMessage(messageCallback);
sim.onConnectionStateChanged([](bool connected){
Serial.print(F("@ SIM: Connection status: "));
Serial.println(connected);
});
}
void loop()
{
sim.run();
}
void messageCallback(SMSMessage& sms)
{
sms.print();
if( sms.search("info") )
{
const char str[] = "SOME INFO";
strcpy(sms.message, str);
sms.size = strlen(str);
sim.sendMessage(sms);
}
}
Gmail: rdalzotto@itba.edu.ar