Logging detection data

With any system, it's useful to be able to log data when something happens. We can do this with our detectors too by writing to a log file every time a detector in a zone is triggered. This way, you can keep a log of every time someone enters a room, which you can review at a later date even if the system isn't armed. You can also keep a log of when the system is armed and disarmed.

Here's a simple script that shows you how to do this whenever an event happens on our zones connected to the GPIO inputs:

#!/bin/bash #set up the I2C expansion port sudo i2cset –y 1 0x20 0x00 0xFF #reset status CURR_STATE="0x00" LAST_STATE="0x00" #path to the log file LOG_FILE="/etc/pi-alarm/zones.log" # loop forever while true do # read the gpio ...

Get Raspberry Pi: Amazing Projects from Scratch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.