Hello all,
I am using an ARDUINO nano with sim800l module. I uploaded a simple sketch to send/receive SMS. While the usb cable is connected to my PC, every things goes well and I can send\ rceive SMS. after I detach the cable the project work well, but after unplug power supply and plug it again (or ever reset only the SIM800l), it doesn't send/receive SMS until I connect it to serial port again. the voltage of the moduleis 4.2 volt. Any one can help me?
My simple code is s bellow (which obtained it by googling)
#include <SoftwareSerial.h>
//SoftwareSerial mySerial(10,11); // (Rx,Tx > Tx,Rx)
#include <Sim800l.h>
#include <Wire.h>
#define RX 10
#define TX 11
#define SIM800_DTR 5 //SIM800 DTR pin
//SoftwareSerial mySerial(RX, TX);
SoftwareSerial mySerial(RX, TX);
char incomingByte;
String inputString;
int relay = 13; // Output for Relay Control
void setup()
{
pinMode(relay, OUTPUT);
pinMode(SIM800_DTR, OUTPUT);
digitalWrite(relay, LOW); // Initial state of the relay
// Serial.begin(9600);
mySerial.begin(9600);
while(!mySerial.available()){
mySerial.println("AT");
delay(1000);
// Serial.println("Connecting...");
}
//Serial.println("Connected!");
mySerial.println("AT+CMGF=1"); //Set SMS to Text Mode
delay(1000);
mySerial.println("AT+CNMI=1,2,0,0,0"); //Procedure to handle newly arrived messages(command name in text: new message indications to TE)
delay(1000);
mySerial.print("AT+CMGR=1");
delay(1000);
mySerial.println("AT+CMGL="REC UNREAD""); // Read Unread Messages
delay(1000);
mySerial.println("AT+CMEE=1"); //Activate the extended error report
delay(1000);
mySerial.println("AT+CREG?");
delay(1000);
mySerial.println("AT+COPS=?");
}
void loop()
{
digitalWrite(SIM800_DTR, LOW); //wake up SIM900
delay(5000);//
mySerial.println("AT"); //A dummy command which sustains SIM wakeup.
delay(10);
mySerial.println("AT");
delay(10);
mySerial.println("AT+CSCLK=0");
if(mySerial.available()){
delay(100);
// Serial Buffer
while(mySerial.available()){
//digitalWrite(relay, HIGH);
incomingByte = mySerial.read();
inputString += incomingByte;
}
delay(10);
inputString.toUpperCase(); // Uppercase the Received Message
delay(1000);
//turn RELAY ON or OFF
if (inputString.indexOf("ON") > -1){
digitalWrite(relay, HIGH);
delay(2000);
}
if (inputString.indexOf("OFF") > -1){
digitalWrite(relay, LOW);
delay(2000);
// Serial.println("off!");
}
delay(50);
//Delete Messages & Save Memory
if (inputString.indexOf("OK") == -1){
mySerial.println("AT+CMGDA="DEL ALL"");
mySerial.print("AT+CMGR=1");
mySerial.print("AT+CMGDA="");
mySerial.println("DEL ALL"");
delay(1000);}
inputString = "";
incomingByte = "";
}
}