loading

In this project I am using the ESP8266 WiFi module and PIR sensor motion detector to get e-mail alerts if someone enters the room while I am away. I am using GadgetKeeper Cloud Platform to bing e-mail notifications with PIR Sensor. I have choose GadgetKeeper Cloud Platform because it's FREE and easy to use. The whole project costed me around $7 and was pretty easy to build.

Step 1: Parts

1× esp8266-07

1× PIR Sensor

1x Bread Board Power Supply

1x 12V AC-DC Power Adaptor

2x 400pin Breadboard

Wires

Step 2: Prepare the Hardware

ESP8266 Wiring

PIN name | Connection

Reset | via push button to gnd

GPIO12 | PIR sensor data pin

VCC | 3V3

TXD | CP2102 TXD Pin

RXD | CP2102 RXD Pin

GPIO0 | GND

GND | GND

CP2102 Wiring

PIN name | Connection

TDX | ESP8266 TXD Pin

RXD | ESP8266 RXD Pin

GND | GND

PIR sensor

PIN name | Connection

VCC | 5V

GND | GND

OUT | ESP8266 GPIO12 Pin

NOTE: to upload code to ESP8266 first connect GPIO0 pin to ground, reset esp and then upload code. After uploading code GPIO0 can be disconnected again.

Step 4: Prepare Arduino IDE

Next, use the Board manager to install the ESP8266 package.

Step 5: Add Required Additional Arduino Libraries

The required libraries can be downloaded from following link:

Time.h

All other required libraries are available as standard libraries with the IDE.

Installing Additional Arduino Libraries guidelines can be found on official Arduino site.

Step 6: Configure GadgetKeeper

After successfully creating account on GadgetKeeper, go to console and create the "Alarm" thing first.

After successfully creating Alarm thing write down your Thing ID.

if you need detailed "point and click" UI instructions how to create thing see "Create, Read, and Write Property" on GadgetKeeper Documentation.

Step 7: Configure GadgetKeeper

Create Motion detected event for Alarm thing in GadgetKeeper Console.

  1. In the "Thing: Alarm" tab, open "Events"
  2. Click "New" to open "Create Event" dialog
  3. Set name to "Motion detected"
  4. Select "boolean" as the data type for this event
  5. Save event

if you need detailed "point and click" UI instructions how to create even see "Create Event And Trigger" on GadgetKeeper Documentation.

Step 8: Configure GadgetKeeper

Create Mail notification trigger for Alarm thing in GadgetKeeper Console.

  1. Open "Triggers" in the "Thing: Alarm" tab
  2. Click "New" to open "Create Script Trigger" dialog
  3. Set name to "Mail notification"
  4. Select "Motion detected" as the event used for the trigger
  5. Save trigger by clicking "Save"

if you need detailed "point and click" UI instructions how to create even see "Create Event And Trigger" on GadgetKeeper Documentation.

Step 9: Configure GadgetKeeper

Add script to Mail notification trigger for Alarm thing in GadgetKeeper Console.

  1. Open "Triggers" again in the "Thing: Alarm" tab
  2. Select "Mail notification"
  3. Click "Edit Script" button to open "Edit Script Trigger" dialog
  4. Insert the following script in the text area (email name may be edited):

function onEvent(event){
if(event.value == true){

smtp.send("user@gmail.com", "Motion detected!")

}

}

5. Save the trigger script by clicking "Save"

if you need detailed "point and click" UI instructions how to create even see "Create Event And Trigger" on GadgetKeeper Documentation.

Step 10: Arduino Sketch

This is the arduino sketch for this cheap homemade IoT device.

esp_pir_snesor

Information about uploading Arduino Sketch can be found here.

<p>Hi,</p><p>When I verify the sketch you provided in Step10 esp_pir_sensor I get this error :</p><p>'getNtpTime' was not declared in this scope</p><p>Please help,</p><p>Thanks</p>
I get this too. If commented out I get errors with anything having to do with the time library. I used the supplied time library. My board is a nodemcu. Any help would be appreciated.
<p>I have fixed this issue by downloading the timelib library and including it in the beginning of the sketch with #include &lt;TimeLib.h&gt;.</p>
<p>can the same procedure be applied to mb102 breadboard and its corresponding breadboard power supply?</p>
Just in case it's of use to anyone...<br><br>The 07 version doesn't have an on board antenna - it has a socket to attach one.<br><br>The 12E has an on board antenna.
<p>Hi <a href="https://www.instructables.com/member/Monsterguy" rel="nofollow">Monsterguy</a>,</p><p>I used it without antenna connected to ESP8266-07 without any problem.</p><p>Best regards.</p>
<p>It has built in ceramic antenna and connector beside it</p>

About This Instructable

17,266views

65favorites

License:

More by sibuntu:Halloween Bowl/Bag GPS Tracker ESP8266 (Standalone) weather station using Arduino IDE and GadgetKeeper Cloud Platform IoT WiFi DIY motion detector with e-mail notification using PIR sensor and ESP8266 
Add instructable to: