Hi friends plz i have problem with my relay i cant get any output from my arduino

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

  while (!Sim800L.available()) {
  Sim800L.println("AT+CMGF=1");  //Set SMS to Text Mode
  Sim800L.println("AT+CNMI=1,2,0,0,0");  //Procedure to handle newly arrived messages(command name in text: new message indications to TE)
  Sim800L.println("AT+CMGL=\"REC UNREAD\""); // Read Unread Messages

void loop() {

  if (Sim800L.available()) {

    // Serial Buffer
    while (Sim800L.available()) {
      incomingMessage = Sim800L.read();
      textMessage += incomingMessage;


    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


    //Delete Messages & Save Memory
    if (textMessage.indexOf("OK")!=1){
      Sim800L.println("AT+CMGDA=\"DEL ALL\"");


    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

i do it

Thank you. See how much easier it is to deal with when in code tags

im very bad in code tags I am a beginner

What do you see printed for the received message?

i see this message in serial monitor

23:00:15.655 -> Connecting...
23:00:15.655 -> Connected!
23:00:17.825 -> AT

23:00:17.825 -> OK
23:00:17.825 -> AT+CMGF=1

23:00:17.860 -> ERROR
23:00:17.860 -> AT+CNMI=1,2,0,0,0

23:00:17.860 -> ERROR
23:00:17.895 -> AT+CMGL=
23:00:19.015 -> AT+CMGDA="DEL ALL"

23:00:19.015 -> ERROR
23:00:19.050 -> 
23:00:20.205 -> AT+CMGDA="DEL ALL"

23:00:20.205 -> ERROR
23:00:20.205 -> 
23:00:21.360 -> AT+CMGDA="DEL ALL"

23:00:21.395 -> ERROR
23:00:21.395 -> 
23:00:22.550 -> AT+CMGDA="DEL ALL"

23:00:22.585 -> ERROR
23:00:22.585 -> 
23:00:23.740 -> AT+CMGDA="DEL ALL"

23:00:23.775 -> ERROR
23:00:23.775 -> 
23:00:24.930 -> AT+CMGDA="DEL ALL"

The ERROR response the AT commands does not look good.

This is a very good tutorial to follow. Pay attention to the use of updateSerial() called with each command to see what is going on.


This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.