Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Remote-Controlled Relay Switching with SIM800L and IR Receiver

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Remote-Controlled Relay Switching with SIM800L and IR Receiver

Circuit Documentation

Summary

The circuit in question is designed to control a series of relays, interface with an IR receiver, and communicate via a SIM800L GSM module. It is powered by a 12V battery, which is also connected to a solar panel and a battery charger for energy sustainability. The circuit includes a step-down converter to provide the necessary 5V power to some of the components. User interaction is facilitated through pushbuttons and an IR receiver, allowing for manual control and remote control, respectively. The Arduino UNO serves as the central microcontroller, managing the inputs from the IR receiver and pushbuttons, controlling the relays, and communicating with the SIM800L module for call and SMS handling.

Component List

Wiring Details

Arduino UNO

Relay 4 Channel 5V

SIM800L

VS1838B IR Receiver

Pushbuttons

Water Pump

12V Battery (Mini)

Solar Panel

12V to 5V Step Down Power Converter

7-Segment Panel Voltmeter

Bulbs

Documented Code

/*
 * ******************************************************************
 * Created By: Tauseef Ahmad
 * Created On: September 25, 2021
 * Tutorial Link: https://youtu.be/uLJqNfX81C4
 * My Channel: https://www.youtube.com/channel/UCOXYfOHgu-C-UfGyDcu5sYw/
 * 
 * ******************************************************************
 * IR Remote Version 3.3.0
 * https://github.com/Arduino-IRremote/Arduino-IRremote
 * ******************************************************************
 */

#include <SoftwareSerial.h>
#include <IRremote.h>

//sender phone number with country code
const String PHONE = "ENTER_YOUR_PERSONAL_PHONE_NUMBER";

String smsStatus,senderNumber,receivedDate,msg,buff;
boolean isReply = false;
String dtmf_cmd;
boolean is_call = false;

#define rxPin 2
#define txPin 3
SoftwareSerial sim800L(rxPin,txPin); 

const byte IR_RECEIVE_PIN = 4;

#define button1_pin 5
#define button2_pin 6
#define button3_pin 7
#define button4_pin 8

#define relay1_pin 9
#define relay2_pin 10
#define relay3_pin 11
#define relay4_pin 12

boolean relay1_state = 0;
boolean relay2_state = 0;
boolean relay3_state = 0;
boolean relay4_state = 0;

void setup()
{
  pinMode(button1_pin, INPUT_PULLUP);
  pinMode(button2_pin, INPUT_PULLUP);
  pinMode(button3_pin, INPUT_PULLUP);
  pinMode(button4_pin, INPUT_PULLUP);
    
  pinMode(relay1_pin, OUTPUT);
  pinMode(relay2_pin, OUTPUT);
  pinMode(relay3_pin, OUTPUT);
  pinMode(relay4_pin, OUTPUT);

  Serial.begin(115200);
  
  Serial.println("IR Receive test");
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);

  sim800L.begin(9600);
  sim800L.print("AT+CMGF=1\r");
  delay(1000);

  sim800L.println("AT+DDET=1"); //Enable DTMF
  delay(500);

  smsStatus = "";
  senderNumber="";
  receivedDate="";
  msg="";
   
}

void loop()
{
  //****************************************
  while(sim800L.available()){
    buff = sim800L.readString();
    handle_sim800_response();
  }
  //****************************************
  while(Serial.available())  {
    sim800L.println(Serial.readString());
  }
  //****************************************

  listen_ir();

  listen_push_buttons();

}

void handle_sim800_response()
{
  Serial.println(buff);
    //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
    if(is_call == true){
      //HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
      if(int index = buff.indexOf("+DTMF:") > -1 ){
        index = buff.indexOf(":");
        dtmf_cmd = buff.substring(index+1, buff.length());
        dtmf_cmd.trim();
        Serial.println("dtmf_cmd: "+dtmf_cmd);

        if(dtmf_cmd == "1")      control_relay(1);
        else if(dtmf_cmd == "2") control_relay(2);
        else if(dtmf_cmd == "3") control_relay(3);
        else if(dtmf_cmd == "4") control_relay(4);
      }    
      //HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
      if(buff.indexOf("NO CARRIER") > -1){
        sim800L.println("ATH");
        is_call = false;
      }