andrewl / motion-detector

Motion detection and Slack notification for Arduino/ESP8266

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Motion Sensor to Slack Notification

What is this?

This shows you how to hook up some low-cost hardware to periodically send a message to Slack if motion was detected recently.

Why?

We have an elderly relative who recently had a fall necessitating hospital treatment. This is a simple solution to help assure us that they're still moving around - but without being as intrusive as a camera might be.

Couldn't you buy something to do this?

I did. A D-Link or TP-Link something or other with IFTTT integration through the vendors app.

But the manufacturer withdrew support after 18 months though and now it's just more e-waste

OK, How do I build one?

Hardware

You'll need

It's a really simple build, you don't even need a breadboard or resistors.

  1. Attach the PIR sensor to the board as per the schematic below.. You just need to connect the 5v, ground and a digital pin that has no internal pull-up (so that by default if reads LOW - D0 on a Wemos D1 is a good choice).

  2. Set the delay setting on the sensor to minimum (consult your sensor's documentation - but with these sensors there's often a screw-type adjustment on them to alter delay and sensitivity.)

Schematic

Software

  1. Create a slack webhook where notifications of motion detection are to be sent

  2. Copy secrets.EXAMPLE.h to secrets.h and enter your wifi details (you can enter a primary and secondary wifi - useful for testing in one location and deploying in a second) and slack webhook url

  3. Compile and upload the sketch to your board using the Arduino IDE

Running

After powering on the device it will pause for 1 minute to enable the sensor to warm up before sending a message to the slack webhook.

It will then poll the sensor every 5 seconds to see if any motion has been sensed - if so it will light the internal LED, and make a note that motion has been detected.

After polling, if more than hour has passed since sending the last message to slack, it sends a notification to slack with information about whether motion was detected during that hour.

The output to Slack will look something like this - the number preceeding the message is the number of seconds the board has been powered on - perhaps useful for debugging when running remotely.

Slack Screenshot

About

Motion detection and Slack notification for Arduino/ESP8266

License:MIT License


Languages

Language:C++ 96.1%Language:C 3.9%