Car remote start using Uno, SIM800L, and 4 Relay module.

Hello,

I am new to Arduino and have taken on a big project. I am following a project from this Youtube video.

This is the code from the project.

/*

  This project will use a gsm module to recieve incoming text messages.
  Based on what the text reads, the arduino can run different sub-routines.
  In this sketch, the arduino is connected to a 8 relay board that you can
  interface with the real world such a truck to remote start.

  Circuit:
  GSM module attached to and Arduino pins 3 and 4 with tx and rx
  SIM card that can receive SMS messages
  8 relays to control various things

  created 1/21/2016
  by ZooRatedProductions

  https://www.youtube.com/user/ZooRatedProductions

  find the code: https://github.com/zoorated/Arduino-SMS-Remote-Start

  find the video of it in use: https://www.youtube.com/watch?v=JeRqLRHGuUE

  based on code by Javier Zorzano / TD & Tom Igoe

*/


// include the GSM library
#include <GSM.h>


// PIN Number for the SIM (set if sim pin code protected)
#define PINNUMBER ""


// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;

 

// Array to hold the number a SMS is retreived from
char senderNumber[20];
char outGoing[16];

// flag to make sure you can not start vehicle while it's already running
int runningflag = 0;

// variables to define pins to be set for each relay
int ignition = 12;
int starter = 11;
int parking_lights = 10;
int relay_4 = 9;



// define String variable to hold incoming message
String message;

void setup()
{
  // configure pins to connect to relays
  pinMode(ignition, OUTPUT);
  pinMode(starter, OUTPUT);
  pinMode(parking_lights, OUTPUT);
  pinMode(relay_4, OUTPUT);


  digitalWrite(ignition, 1);
  digitalWrite(starter, 1);
  digitalWrite(parking_lights, 1);
  digitalWrite(relay_4, 1);
  

  // configure and initialise GSM connection
  Serial.println("SMS Messages Receiver");

  // connection state
  boolean notConnected = true;

  // Start GSM connection
  while (notConnected)
  {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("GSM initialized");
  Serial.println("Waiting for messages");
}

void loop()
{
  char c;

  // If there are any SMSs available()
  if (sms.available())
  {
 

    // Get remote number
    sms.remoteNumber(senderNumber, 20);
    Serial.println(senderNumber);

    // Read message bytes and print them
    while (c = sms.read())
      message += c; // build the message from the sms.read() function

    //Serial.print(c);
    Serial.println(message); // display message on serial for testing
    message.toLowerCase(); // convert to lower case to make sure the comparision works later

    Serial.println("\nEND OF MESSAGE");

  
    if (message == "start" && runningflag == 0)  //if message contains certain text, do task
    {
      Serial.println("received message to start car");

      sms.flush();  //delete message
      Serial.println("MESSAGE DELETED");

      Startup();

      for (int del = 0; del <= 250; del++) { //timer loop to run for 9 minutes, but able to check for messages every 2 seconds


        if (sms.available())
        {
          Serial.println("2Message received from:");
          message = "";
          // Get remote number
          sms.remoteNumber(senderNumber, 20);
          Serial.println(senderNumber);

          // Read message bytes and print them
          while (c = sms.read())
            message += c; // build the message from the sms.read() function
          message.toLowerCase();

          if (message == "stopengine")  //if engine is running, stop the engine
          {
            Serial.println("received message to stop engine");

            Stopengine();

            Serial.println("\nCOMPLETE");

            message = ""; //resets the SMS text to nothing to be able to read the next SMS
            break;
          }


        }

        delay(2000);

        if (del == 250) {
          Sleepmode(); //when the timer runs out, turn off truck
        }
      }

      Serial.println("\nCOMPLETE");

      message = "";
    }

    if (message == "stopengine")
    {
      Serial.println("received message to stop engine");

      Stopengine();

      Serial.println("\nCOMPLETE");

      message = "";

    }
    else {
      message = "";
    }

    // Delete message from modem memory
    sms.flush();
    Serial.println("MESSAGE DELETED");
  }

  delay(1000);

}

/* function that will start the vehicle and set flag to 1. Flash parking lights,
  turn ignition on, and start engine.
*/
void Startup()
{
  runningflag = 1;

  for (int x = 0; x <= 7; x++) {

    digitalWrite(parking_lights, 1);
    delay(200);
    digitalWrite(parking_lights, 0);
    delay(200);
  }

  delay(3000);
  digitalWrite(ignition, 0);
  delay(3000);
  digitalWrite(starter, 0);
  delay(1200);
  digitalWrite(starter, 1);
}

/* function to shut off the vehicle. Flash parking lights, turn ignition off, and set the flag to 0.
*/

void Stopengine()
{

  for (int x = 0; x <= 5; x++) {

    digitalWrite(parking_lights, 0);
    delay(500);
    digitalWrite(parking_lights, 1);
    delay(500);
  }

  delay(500);
  digitalWrite(ignition, 1);

  runningflag = 0;
}

/*function to not cause confusion while on the road. After the 9 minute timer has run out, it will
  shut off the ignition, and shut off the parking lights. If you have inserted the key and turned it to run,
  the vehicle will continue to run.
*/
void Sleepmode() {
  digitalWrite(ignition, 1);
  digitalWrite(parking_lights, 1);
}

In the opening comments, it says to connect the SIM800L to pins 3 and 4 on the Arduino, but when I upload it, i don't see anything in the Serial Monitor. Where does the code specify to use pins 3 and 4?

I do know the SIM800L is working because i ran some test send and receive code on it, and it worked. I know the relays work, as i set them low in the digitalWrite as a test, and they all switched.

When i Verify, it gives me some warnings, but it compiles and uploads.

When i send the test, nothing happens either. I am just running this on my bench, not connected to the car yet (that is a whole other ball game)

Any suggestions would be helpful.

These are the warnings that i get:

In file included from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM.h:46:0,

                 from C:\Temp\sketch_nov15a\NewStartRemoteStart\NewStartRemoteStart.ino:28:

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3ShieldV1BandManagement.h:49:1: warning: 'typedef' was ignored in this declaration

 typedef enum GSM3GSMBand {UNDEFINED, EGSM_MODE, DCS_MODE, PCS_MODE, EGSM_DCS_MODE, GSM850_PCS_MODE, GSM850_EGSM_DCS_PCS_MODE};

 ^~~~~~~

C:\Temp\sketch_nov15a\NewStartRemoteStart\NewStartRemoteStart.ino: In function 'void setup()':

C:\Temp\sketch_nov15a\NewStartRemoteStart\NewStartRemoteStart.ino:83:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

     if (gsmAccess.begin(PINNUMBER) == GSM_READY)

                                  ^

DarthPaul1138:
In the opening comments, it says to connect the SIM800L to pins 3 and 4 on the Arduino, but when I upload it, i don't see anything in the Serial Monitor. Where does the code specify to use pins 3 and 4?

The pins are hardcoded into the GSM library. The reason is this library was written for the long since retired Arduino GSM Shield:

But here's the strange thing: The GSM shield uses pins 2 and 3, not pins 3 and 4.

Another thing to note is that the GSM library was written for the Quectel M10 GSM modem, not the SIM800L you're using. I did a quick look at their AT command sets and they do seem to be compatible, but there is a possibility there are some differences.

DarthPaul1138:
I do know the SIM800L is working because i ran some test send and receive code on it, and it worked.

Did that test code also use the GSM library and did you have the SIM800L connected to pins 3 and 4?

DarthPaul1138:
These are the warnings that i get:

I'd recommend just ignoring those. I don't think they have anything to do with your problem.

I went back and looked, and i did use the SIM800L library. I am new to arduino and i did not know what library's are. So i am going through the code to update it to the sim800l library, but like i said, i am new.

Thanks for the response.