HI FRIEND please i cant get any output when i send ON from message or OFF for turn on my relay
this is my code
#include <Sim800L.h>
#include <SoftwareSerial.h>
// Configure software serial port
SoftwareSerial Sim800L(10, 11);
// Variable to store text message
char incomingMessage;
String textMessage;
// Relay connected to pin 13
const int relay = 13;
void setup() {
pinMode(relay, OUTPUT); // Set relay as OUTPUT
digitalWrite(relay, LOW); // By default the relay is off // HIGH is ON // LOW is OFF
// Initializing serial commmunication
Serial.begin(9600);
Sim800L.begin(9600);
while (!Sim800L.available()) {
Sim800L.println("AT");
delay(1000);
Serial.println("Connecting...");
}
Serial.println("Connected!");
Sim800L.println("AT+CMGF=1"); //Set SMS to Text Mode
delay(1000);
Sim800L.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);
Sim800L.println("AT+CMGL=\"REC UNREAD\""); // Read Unread Messages
}
void loop() {
if (Sim800L.available()) {
delay(100);
// Serial Buffer
while (Sim800L.available()) {
incomingMessage = Sim800L.read();
textMessage += incomingMessage;
}
delay(10);
Serial.println(textMessage);
textMessage.toUpperCase(); // Uppercase the Received Message
//turn RELAY ON or OFF
if (textMessage.indexOf("ON")!=1) {
digitalWrite(relay, HIGH);
}
//for test only
if (textMessage.indexOf("OFF")!=1){
digitalWrite(relay, LOW);
} //test end
delay(50);
//Delete Messages & Save Memory
if (textMessage.indexOf("OK")!=1){
Sim800L.println("AT+CMGDA=\"DEL ALL\"");
delay(1000);
}
textMessage = "";
}
}
The easier you make it to read and copy your code the more likely it is that you will get help
Please follow the advice given in the link below when posting code , use code tags and post the code here to make it easier to read and copy for examination