Door monitor

From Alnwlsn - Projects Repository
Revision as of 13:01, 5 June 2019 by Alnwlsn (talk | contribs)
Jump to navigation Jump to search

This one is an older project (2014), going back to one of the first ESP8266 boards I got my hands on. Perhaps your house is like mine, fitted with an alarm system that checks windows, doors, and motion sensors to detect break-ins or other unwanted visitors. It was here when we moved in, and I don't think was even supported by the original company anymore, not that we even had the intention of paying for a security subscription in the first place.

For all the bells and whistles the original system might offer, at the end of the day the sensors that actually run the system are made up of a bunch of switches that will either open or close when an event is detected. For example, magnetic switches on doors and windows will open when they are open, and motion detectors will either open or close for a few seconds whenever someone walks by. Conveniently, all the wires for these switches connect to the same point, which is the box that contains the original alarm controller.

Collecting the data

The first step was to remove the old controller board (as we weren't using it anymore), which leaves us with a bunch of wires. Many of these wires are switches, and the terminals can be found with a continuity tester. If a bundle has 4 wires, it's either two switches, or something that requires power, like a motion detector (or just one switch and nothing connected to the other two). The motion detectors we have use 12V DC, with the switch terminals isolated. Once power is applied, the other 2 terminals will be a switch that opens whenever the motion detectors switch. All said and done, I had about 8 or so switches that were connected to doors and motion detectors all over the house.

In these days, Arduino IDE for esp8266 did not exist, but NodeMcu Lua did. Of course, there was still the original firmware with AT commands. No matter what, the ESP01 modules I had only have serial communication, and two GPIO pins. The other system I had was an atmega328, which has only 2k of ram, so not the best for managing long strings, but, it does have about 19 pins to which I could attach all the switches. To interface the two microcontrollers together, I decided a straightforward approach would be to do monitor the switches on the atmega, and then send any changes to the esp8266, which would run Lua script to send that data to a server.

The actual data passed comes in the form of a URL requested from the server. In the address, variables are passed to a php script using http get. The php script opens the log and updates it with the latest event. This server is run on my Raspberry pi since I already have another web server to host this website.