1. Component list
- 1× esp8266-07
- 1× PIR Sensor
- 1x Bread Board Power Supply
- 1x 12V AC-DC Power Adaptor
- 2x 400pin Breadboard
2. Overall idea
In this project we are using the ESP8266 WiFi module and PIR sensor motion detector to get e-mail alerts when motion is detected. We are using GadgetKeeper Cloud Platform to bind e-mail notifications with PIR Sensor.
3. Prepare the hardware
|Reset||via push button to gnd|
|GPIO12||PIR sensor data pin|
|TXD||CP2102 TXD Pin|
|RXD||CP2102 RXD Pin|
|TDX||ESP8266 TXD Pin|
|RXD||ESP8266 RXD Pin|
|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.
4. Configure Arduino IDE
Open File -> Preferences and end enter:
into Additional Board Manager URLs field.
Click OK and go to Sketch -> Include Library -> Manage Libraries to open Board manager
In Boards Manager search for esp8266 and install the ESP8266 package.
5. Add required additional Arduino libraries
The required libraries can be downloaded from following link:
All other required libraries are available as standard libraries with the IDE.
Installing Additional Arduino Libraries guidelines can be found on official Arduino site.
6. Configure GadgetKeeper
Create the "Alarm" thing first.
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
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):
- Save the trigger script by clicking "Save"
7. Arduino sketch
This is the arduino sketch for this cheap homemade IoT device. Every time the PIR sensor is triggered is sends data to GadgetKeeper Cloud to trigger email notification event. It can be also downloaded form github esp_pir_snesor.