Open source security and auto-light device with an ESP8266 module.
The ESP8266 uses a PIR sensor to detect movements in the front yard (or any area that you want to surveil). During the night a 220V light is switched on with a relay if a movement is detected. This lights up the front yard automatically when you come home late or leave the house early.
The environment light level is measured by a LDR connected to the analog input of the ESP8266.
The light bulb is switched on by activating a relay over a GPIO port. After an detection the light stays on for at least 2 minutes after an detection. If a new movement is detected within these 2 minutes, the timer is retriggered to keep the light on for another 2 minutes.
Additional an alarm function can be activated. If the alarm is active, the ESP8266 issues 3 types of alarm messages:
- an alarm sound through a loudspeaker attached to the ESP8266
- an UDP broadcast alarm message is send over the local WiFi network to any listening device on the same network.
- an alarm message is send over Google Cloud Messaging (aka GCM) to Android devices outside the local WiFi network (to alarm you even you are not at home)
The alarm sound played from the ESP8266 is a simple sound played through a GPIO port using just a transistor for amplifying. The sound level is limited and should just chase away the intruder.The system can be extended of course by attaching a siren instead and switch the siren on/off by another relay controlled by an GPIO port.
An UDP broadcast message is a message send over the local lan without a specific receiver address. Instead an IP address range is used to enable all devices that have an IP address within this range to receive the message.
The UDP broadcast alarm message can be received by devices connected to the local WiFi network to initiate an Intruder alert to the people in the house. In the source code is a sample Python script that can run on e.g. a RaspberryPi and play an alarm sound. I wrote as well an Android application that receives that broadcast message and plays an alarm sound on the Android device.
GCM messaging is used to send messages to any registered Android device that is connected to the internet. The ESP8266 sends the message to the GCM servers, which then forward this message to the addressed Android devices. Any internet connection is sufficient to receive these messages. This way the alert will be send to your phone even if you are not at home. I wrote an article about how GCM works with an ESP8266 module on my website: http://desire.giesecke.tk/esp8266-googl ... al-server/
The attached source code includes:
The ESP8266 source codes (for Arduino IDE) to connect the PIR (Passive Infrared Receiver), switch on/off a relay and play a simple alarm sound through an attached loudspeaker without using an amplifier. It includes as well a simple web server to configure the application, store the GCM IDs of registered Android devices, send an UDP broadcast message over the local WiFi and send a GCM message to the GCM servers.
A simple Python script that can run e.g. on a Raspberry Pi to play an alarm sound inside the house if an intruder approaches the house.
The Android source codes include the complete application with all necessary methods to request status messages from the ESP8266 web server, receive UDP broadcast messages. It includes as well the registration of the device for the GCM messaging service and storage of the device ID on the ESP8266 module.
I tried to keep the hardware and mechanics as simple as possible. No 3D printer is used for any of the parts. For the housing of the electronics and the PIR sensor I used cheap food storage containers, the power supply is provided by a cheap 5V USB charger module. Mounting parts are made of leftover materials laying around in my workspace. The PIR sensor is mounted to the electronics housing with a simple alu bracket that can be rotated and easily bended to point the sensor to the direction you want to surveille.
For the auto-light/security module:
1x ESP8266 module e.g. Adafruit HUZZAH ESP8266 (ESP-12) module - https://www.adafruit.com/products/2471)
1x PIR sensor e.g. Adafruit PIR (motion) sensor - https://www.adafruit.com/products/189
1x 220V/10A relay e.g. dfRobot Relay Modular V3.1 (10A/220V max) - http://www.dfrobot.com/index.php?route= ... mBYpXYrJpg
1x push button
1x loud speaker (I took one from an old telephone with hands free function)
1x 100uF electrolytic capacitor
1x 100nF ceramic capacitor
1x LDR resistor
1x NPN transistor e.g. S9014)
1x 1kΩ Resistor
1x 10kΩ Resistor
1x 56kΩ Resistor
1x 100kΩ Resistor
2x 470kΩ Resistor
1x USB 5V charger (if you use a 5V compliant ESP module like the Adafruit HUZZAH, otherwise you need an additional 3.3V power supply)
1x light bulb (I used an LED bulb)
some electric mounting materials like wires, connectors, light bulb socket, ...
food containers (or any housing of your choice) for the electronics and the PIR sensor.
For the user control input either
Web browser (Firefox, Chrome, ...)
For playing an alarm to inform about an intruder either
a computer/minicomputer that is on 24h, I use my Raspberry Pi media center device for it
Live realtime stock market prediction website. https://www.stocksignalslive.com my latest creation. Uses AI and machine learning.
New site featuring ESP8266 and ESP32 projects. tutorials, and news.
ESP8266.com Founder and Administrator
The Mind Factory (get more from your 3D printer)
Home of the ESP8266, ESP8285, and ESP32 microcontrollers....