Hi everyone,
I'm playing with a gsm module (sim800L) and noticed a 'strange' thing happening while trying to put the arduino to sleep and handling a message received. What happens is that I put the arduino to sleep, it goes sleeping (using LowPower lib) but it wakes if it receives a message through the sim800 module. How is this happening, since I dont have any interrupt pins from the gsm to arduino, only GND, TX, RX ?
I known that the GPRS_Shield_Arduino library is using SoftwareSerial, but in which way could the SoftwareSerial wake the arduino ?
GPRS_Shield_Arduino Library link
#include <GPRS_Shield_Arduino.h>
#include <SoftwareSerial.h>
#include <LowPower.h>
#define PIN_TX 7
#define PIN_RX 8
#define BAUDRATE 9600
#define MESSAGE_LENGTH 160
char message[MESSAGE_LENGTH];
int messageIndex = 0;
char phone[16];
char datetime[24];
GPRS gprsTest(PIN_TX, PIN_RX, BAUDRATE); //RX,TX,PWR,BaudRate
#define LED 13
void setup()
{
Serial.begin(9600);
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
while (!gprsTest.init())
{
Serial.print("init error\r\n");
delay(1000);
}
delay(3000);
Serial.println("Init Success, please send SMS message to me!");
}
void loop()
{
sleep();
readsms();
}
void readsms()
{
messageIndex = gprsTest.isSMSunread();
if (messageIndex > 0) //At least, there is one UNREAD SMS
{
gprsTest.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);
//In order not to full SIM Memory, is better to delete it
digitalWrite(LED, HIGH); //some visual indication that I received a message
delay(3000);
digitalWrite(LED, LOW);
gprsTest.deleteSMS(messageIndex);
Serial.print("From number: ");
Serial.println(phone);
Serial.print("Datetime: ");
Serial.println(datetime);
Serial.print("Recieved Message: ");
Serial.println(message);
}
}
void sleep()
{
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
}