Najad
Published © GPL3+

IoT Motion Sensor – ESP 01 + PIR

Internet-connected motion sensor which will give us alert on our phone when motion is detected at the place we installed the sensor.

IntermediateFull instructions provided14,452

Things used in this project

Hardware components

UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
×1
UTSOURCE ESP8266-01
×1
UTSOURCE PIR Motion Sensor
×1
SparkFun FTDI Basic Breakout - 3.3V
SparkFun FTDI Basic Breakout - 3.3V
×1

Software apps and online services

Arduino IDE
Arduino IDE
Maker service
IFTTT Maker service

Story

Read more

Schematics

Circuit

Code

Code

C/C++
// IoT motion sensor by www.diyusthad.com
// www.youtube.com/c/diyusthad
// www.hackser.io/najad

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const char* ssid = "*****"; //Your WiFI ssid
const char* password = "*****"; //Your WiFi password
boolean PIRstate ; //variable to store PIR state
boolean lastPIRstate = HIGH;
int PIR = 0; //PIR connected to GPIO 0

void setup () {

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED)
  {
    delay(1000);
  }

  pinMode(PIR, INPUT); //digitalWrite(PIR, LOW);

  pinMode(LED_BUILTIN, OUTPUT);

  delay(30000);

}

void loop()
{

  PIRstate = digitalRead(PIR);  //HIGH when motion detected, else LOW

  if (PIRstate != lastPIRstate)  //Checking if there is any motion
  {

    digitalWrite(LED_BUILTIN, LOW);
    delay(100);
    digitalWrite(LED_BUILTIN, HIGH);
    if (WiFi.status() == WL_CONNECTED)  //Check WiFi connection status
    {
      HTTPClient http;  //Declare an object of class HTTPClient

      http.begin("paste the link from ifttt");  //Specify request destination
      http.GET();   //Send the request
      http.end();   //Close connection

    }
    lastPIRstate = PIRstate;
  }

}

Credits

Najad

Najad

30 projects • 96 followers
Just crazy stuff​

Comments