Silícios LabPCBWay
Published © GPL3+

Alert System for Door Security with Arduino

In this article, we'll learn how to create an Alert System Text SMS using Arduino and SIM800L Module.

IntermediateFull instructions provided1 hour3,113
Alert System for Door Security with Arduino

Things used in this project

Hardware components

PCBWay Custom PCB
PCBWay Custom PCB
×1
Wire Jumpers - UTSOURCE
×1
10kR Resistor - UTSOURCE
×1
Reed Switch Sensor - UTSOURCE
×1
Arduino UNO - UTSOURCE
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Source Code

Arduino
Alert System for Door Security with Arduino
#include <SoftwareSerial.h>

SoftwareSerial chip(10, 11);

String SeuNumero = "+xxxxxxxxxxxxx"; //

#define sensor 12

bool ValorAtual = 0, ValorAnterior = 0;

void setup()
{
  Serial.begin(9600);
  Serial.println("Inicializando Sistema...");
  delay(5000);
  chip.begin(9600);
  delay(1000);

  pinMode(sensor, INPUT); //Configura o Pino do Sensor como Entrada

  ValorAnterior = analogRead(sensor); //Captura um primeiro valor de referencia inicial para a variavel ValorAnterior
}

void loop()
{
  //Le o valor do pino do sensor
  ValorAtual = digitalRead(sensor);

  if(ValorAtual == 1 && ValorAnterior == 0)
  {
      ClosedDoor();
      ValorAnterior == 1;
  }

  if(ValorAtual == 1 && ValorAnterior == 0)
  {
      OpenedDoor;
      ValorAnterior == 0;
  }

}

void OpenedDoor() //Funcao para enviar mensagem de alerta Umidade Baixa
{
  chip.println("AT+CMGF=1");
  delay(1000);
  chip.println("AT+CMGS=\"" + SeuNumero + "\"\r");
  delay(1000);
  String SMS = "Opened Door!";
  chip.println(SMS);
  delay(100);
  chip.println((char)26);
  delay(1000);
}

void ClosedDoor()//Funcao para enviar mensagem de alerta Umidade Normal
{
  chip.println("AT+CMGF=1");
  delay(1000);
  chip.println("AT+CMGS=\"" + SeuNumero + "\"\r");
  delay(1000);
  String SMS = "Closed Door!";
  chip.println(SMS);
  delay(100);
  chip.println((char)26);
  delay(1000);
}

Credits

Silícios Lab

Silícios Lab

71 projects • 173 followers
Hello, I love program microcontrollers and works with electronic projects.
PCBWay

PCBWay

89 projects • 146 followers
We are a PCB and assembly manufacturer, As low as $5/10pcs and 24 hours delivery time. We are committed to helping creators build project.

Comments