Wemso D1 Mini / ESP8266 + PIR HC SR501 reliable wifi motion sensor

I wanted to build a cheap and reliable motion sensor for a long time to connect to my homeassistant as all the motion sensors available in the market are either zwave based, or does not work with homeassistant or they were very expensive. So I built a mqtt based motion sensor with Wemos D1 Mini and PIR SR501 motion sensor which works flawlessly on wifi.

What is this repository for?
This repo is for poeple looking to bulid a rapid prototype of a wifi based motion sensor with esp8266 (Wemos D1 Mini in my case) + PIR SR 501 sensor + mqtt + homeassistant
I hacked this code by looking at some examples and some basic knowledge of Aurduino, dont expect a great code, but it works. Feel free to raise pull requests to enhance it further.
Once you put this code on the Wemos D1 Mini, you will be able to flash it over the wifi itself so that you dont have to take out the sensor again and again to update it. I have taken the sample code of basic OTA and implemented it.
Ver 0.1

How do I get set up?
Hardware requirements: Wemos D1 Mini/ Node MCU / any esp8266 based board HC-SR501 PIR Module
Software requirements Arduino IDE Running homeassistant instance Running mqtt server
Dependencies Board Manager for the Wemos D1 Mini: http://arduino.esp8266.com/stable/package_esp8266com_index.json Pubsub Arduino Library

TODO
Web based configuration for easy use.

https://bitbucket.org/vishix/esp8266_motionsensor/overview

2 Likes

UPDATE: I have added MQTT autodiscovery for Homeassistant to the repo.

hey what would be cool if you could add some humidity and temperature to you little setup!

that would make it the best total package!

I ordered some stuff already and definately going to test your setup!

its only 2/3 bucks more to also have temp and humidity so I might need to expand on all this. or go with easy esp.

Espeasy supports a pir and your temperature sensor. No need to program the arduino yourself:

https://www.letscontrolit.com/wiki/index.php/Devices

This is cool - I’ve been working on something similar, although I’m using an ESP-01 module instead of the Wemos: