Search

DIY: IoT WiFi Motion Sensor with Email alerts

Updated: 5 days ago



In this blog we present how to build battery powered Wi-Fi PIR motion sensor with email notifications for less than £20. The device constantly monitors if there is any movement. Every time a movement is detected the device sends a notification to your email. It connects to the internet over Wi-Fi network by using Things On Edge Cricket ® Wi-Fi module, so you do not require any extra IoT HUB.


The instructions comprise with the following steps:

  • Explaining project using Fritzing schematics

  • Assembly

  • Setting-up IFTTT and email service

  • Configuring IoT module

  • Connecting IoT module to the internet


This blog is also supported with a full video which includes all instructions


Before you start, please make sure you have the following components:

  1. Cricket Wi-Fi module (https://www.thingsonedge.com/)

  2. HC-SR501 Human Body Sensor

  3. MP1584EN DC-DC Buck Converter

  4. 9V battery

  5. 3x Female/Female Jumper Wires


If you are ready let's get started!


Assembly

We use the PIR sensor module (HC-SR501), which is easily accessible from Amazon and other online shops. The module detects motions and sets the OUT pin HI for selected duration (explained in more details further in the blog). This wakes up the IOT module and sends the email notification over IFTTT.


The PIR module operating voltage is 4.5-20V and we have chosen a 9V battery to power-up this sensor. However we also want to use the IOT Cricket Wi-Fi module which operates between 1V and 3.5V. We cannot connect this battery directly to the IOT module. We need to add a step down regulator DC-DC to lower down the voltage otherwise we damage the board.



We choose the MP1584EN step-down module which output voltage can be adjusted between 0.9V and 20V. We have to make sure the output voltage is set correctly to avoid damage. The module has a potentiometer to regulate the output voltage. This should be adjusted for 3.3V using a multimeter.




The motion sensor also has 2x potentiometers to regulate sensitivity and duration of the output signal. The cricket module wakes-up by providing a high signal on WAKE_UP pin, then it sends the notification to the cloud/IFTTT and powers itself down to wait for another wake_up signal. The entire process takes approx. 5 seconds. The duration for the motion sensor can be adjusted between 3s and 1 minute. We need to set this to minimum to avoid multiple notifications on a single movement detection. The potentiometer should be turned to maxim anticlockwise. This sets the output signal to last approx 3 seconds.





Follow the schematics below to connect all components together, it can be done using breadboard but eventually this will be turned into a standalone product with 3D printed enclosure.





After assembly the circuits should work as expected, any movements detected should wake-up the Cricket board, this is indicated by LED blinking.


Setting-up IFTTT and email service

Steps to follow:

  • Go to: https://ifttt.com/

  • Login or register

  • Click Create from User / Account menu (top right corner)

  • Click + to create new source event

  • Select Webhooks service

  • Click Continue

  • Click Receive a web request (on the left hand side)

  • Create event name e.g. pir_sensor

  • The source event should be set-up now, click + after Then event

  • Search email service

  • Change subject and body of the email accordingly

  • Click Finish


Nearly done, we need to get a HTTP address to which we can post events from the IoT module.

Search for Webhooks service and click on the document in the right up corner.



Next copy web links under"Make a POST or GET web request to:"you will need it later.


We have successfully assembled the device!


Before we start using the device it needs to be configured in Developer Portal. Please go to the next section.


Connect to Wi-Fi network

In a few steps you will connect your device to the internet over your Wi-Fi network. All you need to do is to activate Cricket's private Wi-Fi hotspot and then open a private web page to pass your Wi-Fi network credentials. Please follow the steps below:

  • Press and hold a button on the module for 5 seconds until the LED is constantly lit.

  • Once the LED is constantly lit Cricket opened a private Wi-Fi hot spot. Connect from either a laptop or smartphone to the hot spot with the following credentials: SSID: toe_device No password is required

  • Once connected, open a private web page: http://192.168.4.1/index.html NOTE:make sure LED is still ON! If is OFF repeat the steps from the beginning


  • Now you can pass your Wi-Fi network credentials and click CONNECT. If you passed correct SSID and Password then after few seconds the device should report it is online and the LED will be OFF.




Configure your device

Cricket is entirely configured OTA (Over The Air). For our Wi-Fi Motion Sensor device we want to configure Cricket to send HTTP Post Requests to the IFTTT / Webhooks when it wakes up on IO1: WAKE_UP pin. The IOT Cricket module wakes up when IO1 receives a high signal from the PIR sensor module.


Set the following configuration:

  • RTC: OFF

  • IO2: OFF

  • IO3: OFF

  • Battery monitor: OFF

  • Force updates on - IO1 Wake Up: On

  • Force updates on - RTC Wake Up: OFF

  • Post Events: see below

Copy / paste the link we copied from Webhooks in io1_wakeup and leave data empty.

Just two more steps:

  • replace https to http

  • replace event to pir_sensor

The link should look similar to the one shown below:


http://maker.ifttt.com/trigger/pir_sensor/with/key/hfNIx8SKn_xxxxxxxxxxxxxxxxxxxxxx_YW3xx5yFw5MGD

More information on how to configure Cricket you can find in the IOT Developer Guide


Make a case for the device

If you have an access to 3D printer you can download stl files from our GitHUB and print the case. The device will get a really nice look as shown below.




Testing the device

It is straight forward. Just move around in front of the sensor and you will get email notification.


Feedback

Thank you for taking your time! If you enjoyed building this IOT PIR sensor we would really appreciate if you could spread the word among your peers. If you have any feedback or suggestions how to improve and make it easier for other developers please let us know.


Many thanks & Enjoy!


About

Things On Edge Cricket ® Wi-Fi module allows developers to connect their electronic devices to smartphones or other internet services literally in minutes. What's more you can do it without programming and coding a single line of code.

1,732 views
logo.png

Registered in United Kingdom No. 11445097

Things On Edge Ltd

Cambridge, UK

CB25 9LT

Copyright © 2018 Things On Edge Limited

All rights reserved

  • LinkedIn - White Circle
  • White Facebook Icon
  • White Twitter Icon
  • White YouTube Icon