IoT WiFi DIY Motion Detector With E-mail Notification Using PIR Sensor and ESP8266
by sibuntu in Circuits > Arduino
23523 Views, 69 Favorites, 0 Comments
IoT WiFi DIY Motion Detector With E-mail Notification Using PIR Sensor and ESP8266
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.
Parts
1× esp8266-07
1× PIR Sensor
1x Bread Board Power Supply
1x 12V AC-DC Power Adaptor
2x 400pin Breadboard
Wires
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.
Prepare Arduino IDE
Enter
http://arduino.esp8266.com/stable/package_esp8266com_index.json
into Additional Board Manager URLs field in the Arduino v1.6.4+ preferences.
Prepare Arduino IDE
Next, use the Board manager to install the ESP8266 package.
Add Required Additional Arduino Libraries
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.
Configure GadgetKeeper
Create Motion detected event for Alarm thing in GadgetKeeper Console.
- In the "Thing: Alarm" tab, open "Events"
- Click "New" to open "Create Event" dialog
- Set name to "Motion detected"
- Select "boolean" as the data type for this event
- Save event
if you need detailed "point and click" UI instructions how to create even see "Create Event And Trigger" on GadgetKeeper Documentation.
Configure GadgetKeeper
Create Mail notification trigger for Alarm thing in GadgetKeeper Console.
- Open "Triggers" in the "Thing: Alarm" tab
- Click "New" to open "Create Script Trigger" dialog
- Set name to "Mail notification"
- Select "Motion detected" as the event used for the trigger
- 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.
Configure GadgetKeeper
Add script to Mail notification trigger for Alarm thing in GadgetKeeper Console.
- Open "Triggers" again in the "Thing: Alarm" tab
- Select "Mail notification"
- Click "Edit Script" button to open "Edit Script Trigger" dialog
- 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.
Arduino Sketch
This is the arduino sketch for this cheap homemade IoT device.
Information about uploading Arduino Sketch can be found here.