Kailaash Jeevan J
Published © GPL3+

IoT Based Alarm System

Its an IoT based Security System developed using ESP8266 NodeMCU Module.

IntermediateWork in progress2 hours1,114
IoT Based Alarm System

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
Buzzer
Buzzer
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Linear Regulator (7805)
Linear Regulator (7805)
×1
9V battery (generic)
9V battery (generic)
×1
9V Battery Clip
9V Battery Clip
×1
5 mm LED: Red
5 mm LED: Red
×1
Capacitor 47 µF
Capacitor 47 µF
×1
Limit Switch, Rod Lever
Limit Switch, Rod Lever
×1

Software apps and online services

Arduino IDE
Arduino IDE
SMS Messaging API
Twilio SMS Messaging API

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Custom parts and enclosures

Box

This is the STL File for the box.

Top Cap

This is the STL File for the cap

Schematics

Circuit DIagram

Code

Node Server Code

JavaScript
This is the code for the node server to which the NodeMCU will be communicating via the Internet.
For this, you must have an account in Twilio for the API messaging services.
const express=require('express');
const app=express()
const sid="Account_SID"
const ath="Auth_Token"
app.use(express.urlencoded()); //Parse URL-encoded bodies
app.use(express.json())// Json parser
const client = require('twilio')(sid, ath, {
    lazyLoading: true
});

app.get("/stolen",(req,res)=>{
    res.send(200)
    console.log("STOLEN!")
    sendMsg()
})



app.listen(3000,()=>{
    console.log("Running successfully on 3000");
})


function sendMsg()
{
    client.messages.create({
        body:"YOUR BIKE IS STOLEN:::::\n --------- \n TERSBYTE TECHNOLOGIES",
        to:"to_number",
        from:"from_number (Twilio Registered Number)"
    })
    .then(message=>{
        console.log("SUCCESSFUL")
    })
    .catch(err=>console.log(err))
}

NodeMCU code.

Arduino
This is the code which must be uploaded to the NodeMCU.
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>


//Buzzer Pin
int buzzerPin=5;
//Sensor Input Pin
int SensorPin=4;

//Wifi Details
const char *ssid="WiFi-SSID";
const char *pass="WiFi-Password";

//Port Details
String serverName = "http://(Server IP):3000/stolen";



void setup() {
  //Starting Serial Communication
  Serial.begin(115200);
  //Assigning the Pins
  pinMode(buzzerPin,OUTPUT);  
  pinMode(SensorPin,INPUT);
  pinMode(LED_BUILTIN, OUTPUT);  
  //Sequence Work
  Serial.println("Initializing Device...");
  Serial.println("Trying to connect wifi ");Serial.print(ssid);
  WiFi.begin(ssid, pass); 
   

}

void beep()
{
    Serial.println("The button is being pressed");
    digitalWrite(buzzerPin, HIGH); // turn on
    delay(1000);
    digitalWrite(buzzerPin, LOW);
    delay(1000);
}

void loop() {
  
  int pinStatus=digitalRead(SensorPin);
  if(WiFi.status() != WL_CONNECTED)
      {
        digitalWrite(LED_BUILTIN,HIGH);
 //         WiFi.begin(ssid, pass); 

      }
  else
  
      digitalWrite(LED_BUILTIN,LOW);
  
  if(pinStatus)
  {
    if(WiFi.status()==WL_CONNECTED)
    {      WiFiClient client;
           HTTPClient http;
       http.begin(client, serverName.c_str());
       int response=http.GET();
      
      }
      for(int i=0;i<20;i++)
      {
        beep();
      }
  }

}

Credits

Kailaash Jeevan J
1 project • 2 followers
Crazy Technologist. Full Stack, Electronics and DevOps Engineer. Also a start-up.

Comments