PIR motion, pet friendly, ESP8266 wifi security system for ~ $35

I am in the process of putting the final touches on my home security project which contains only a commercial PIR, pet friendly, motion detector. The output is only connected to GPIO2 of the ESP8266 / ESP-1 Wi-Fi device.

The Arduino sketch code decodes a zero or one as 25 or 100 to Ubidot’s cloud. When triggered by the PIR motion detector, Ubidot’s cloud will see this change (100) and with the change can easily send an email, sms, telegraph etc. Using the Arduino adjustable millis() command and any further PIR trigger/alert will be locked out for one hour - this is to prevent excessive emails and restrictions from my ISP. The value of 50 will show on Ubidots chart when the device alarm is locked out.

Here is my sample Arduino test sketch/code:


Arduino sketch / code:
/*
GPIO used: GPIO 2 digital trigger input, GPIO 0 input - for device programming.
Note: GPIO 0 is grounded when programming the ESP8266

Program description:

On each loop scan of GPIO_2 input Boolean trigger is read and the ESP8266 sends to
Ubidots cloud server a float variable. Variable 25.0 = 0 Boolean input, 100.0 = 1 Boolean input,
50.0 = input trigger lockout which prevents multiple UN-necessary emails to be sent to the
user. This millis lockout occurs after the input trigger = 1 = high and stays locked out until the interval
millis timer of 60 minutes is reached and then resets or is unlocked.

#include "UbidotsMicroESP8266.h"
#define TOKEN  "?????????" //Your_token_here"  <---- Put here your Ubidots TOKEN
#define WIFISSID "???????" //  <----Your_WiFi_SSID
#define PASSWORD "????????" // <----Your_WiFi_Password
#define DEVICE "HS1" // <--- Your device variable string-number 1-5 max.


int tInput  = 2; // trigger input on GPIO_2
int val     = 0; // read value for trigger input
int lockout = 0; // prevents multiple email triggers
//unsigned long  interval = 20000 ; // 5 secs
unsigned long  interval = 3600000 ; // 60 minutes or 24 triggers/day
unsigned long previousMillis = 0;

Ubidots client(TOKEN);

void setup() {
  pinMode(0, INPUT);  // 
  pinMode(tInput, INPUT); // trigger input 5v=1=true 0v=0=false
  
  
  Serial.begin(115200);
  delay(10);
  client.wifiConnection(WIFISSID, PASSWORD);

}
void loop() {
  unsigned long currentMillis = millis(); // grab current time
  val = digitalRead(tInput); // read trigger input

  // check if "interval" time has passed (5000 milliseconds or 3600000 milliseconds)
  if (((unsigned long)(currentMillis - previousMillis) >= interval) && (lockout == 1)) {
    lockout = 0;
    // save the "current" time
    previousMillis = millis();
  }
  
  if (lockout == 1) {
    float value3 = 50.0;
    client.add(DEVICE, value3);
    client.sendAll(true);
  }

  if ((val == 1) && (lockout == 0)) {
    float value1 = 100.0;
    client.add(DEVICE, value1);
    client.sendAll(true);
    lockout = 1;
    previousMillis = millis();
  }
  if ((val == 0) && (lockout == 0)) {
    float value2 = 25.0;
    client.add(DEVICE, value2);
    client.sendAll(true);
  }


} // end of loop

// end of code

Any comments appreciated

Update …

Project cost estimate - shipping is not included but many times its free.

Ebay - ESP8266 ESP-01 ESP-01S Breadboard Adapter for Wifi Transceiver Module Breakout -Approximate cost - $1.15 ($USD)
Ebay - AMS1117 3.3V Power Supply Module Voltage Regulator DC-DC 4.5V-12V to 3.3V - Approximate cost - $1.49 ($USD)
Ebay - USB To ESP8266 Serial Wireless Wifi Module Developent Board Adapter 8266 - Approximate cost - $0.99 ($USD)
Ebay - Arduino ESP8266 WIFI Wireless Transceiver Module Send Receive LWIP AP+STA BG - Approximate cost - $2.86 ($USD)
Ebay - AC Converter Adapter DC 9V 1A 1000mA Power Supply Charger US plug 5.5 x 2.1mm - Approximate cost - $5.88 ($USD)
Smarthome Visonic K9-40 Slimline Pet Immune PIR Motion Detector - Approximate cost $14.63 ($USD)

Miscellaneous parts / tools

Plastic project box – for mounting PIR sensor on this enclosure with Velcro.
22/24 guage solid strand bus wire
3 10K 1/4W or 1/8W 5% metal film/carbon pullup resistors
Velcro
22 gauge hook-up wire
60/40 solder
solder iron/pencil/station
wire strippers / side cutters

Hello @ubidotsandy,

Let us to know how your project goes on!

Best regards.

Here is the schematic/block diagram of the security system …