Skip to content

Raspberry Pi door monitor.

License

Notifications You must be signed in to change notification settings

PI-Portal/pi_portal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi_portal

cicd-tools

Branch Build
main pi_portal-github-workflow-push
dev pi_portal-github-workflow-push

A Raspberry PI Door Logger

  • Put a contact switch on a door and generate logs, alarms and notifications with your Raspberry PI.
  • Connect a WebCam and view snapshots and motion activated videos over Slack.
  • Add DHT11 temperature sensors and track temperature and humidity fluctuations over time.

This is a hobby solution, no warranty or guarantee of any kind is made.

Please use at your own risk.

Project Documentation

Requirements

Hardware

  1. A Raspberry Pi.
    • You'll need a Raspberry PI with Raspberry Pi OS or similar installed and reliable internet.
    • I developed and tested this project on a Pi 1Bv2 and a Pi 3.
  2. Contact switches.
    • These are available cheaply on ebay, Amazon or at your local electronics store.
    • Some examples can be found here.
  3. Temperature monitors.
    • Currently, only the DHT11 is supported, but it's trivial to add support for the DHT22.
    • Currently, only the DHT11 is supported, but it's trivial to add support for the DHT22.
    • You can find out more about these sensors here.
  4. Wiring between the switches, temperature monitors and the Raspberry Pi's GPIO connectors.
    • Find out more about the Pi's GPIO here.
    • Female jump wires make installing the connections pretty painless. I spliced them to the ends of modular cables (i.e. phone cables) for longer runs.
    • Edit the config.json file to customize your pin outs and integrations.
  5. A USB camera or webcam that's compatible with motion.
    • Many webcams are compatible and widely available.

Python

Supports Python 3.8, 3.9, 3.10 or 3.11

PAAS Accounts

  • An AWS account
  • A logz.io account
  • A Slack account, with bot app credentials

See this guide for setting up your bot on Slack.

AWS Infrastructure

You'll need to create two S3 buckets:

  • one to archive logs
  • one to archive motion detection videos

Create a set AWS cli credentials with write permissions to both of these buckets.

Use the following template to design your write access policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllPutObjectActions",
      "Effect": "Allow",
      "Action": ["s3:PutObject", "s3:PutObjectAcl", "s3:PutObjectVersionAcl"],
      "Resource": ["arn of a bucket1", "arn of a bucket2"]
    }
  ]
}

You can also configure lifecycle rules for these buckets to control data retention. (And it's definitely a good idea to ensure they are not publicly accessible!)

Logz.io Integration

This service has a generous free tier that will allow you to search your logs and create useful reports and graphs. You will need to know your accounts log token, (check the website on how to configure filebeat to find it.)

Enter your AWS credentials for the logging bucket here, to archive your logs.

PI Portal ships with a binary for filebeat that has compiled for the Raspberry PI 3. This binary is responsible for streaming your logs to logz.io.

Creating a configuration file

To get started rolling your own configuration file, here's some important resources:

  1. First it's handy to look at the sample config included in the repository.
  2. For more detail on what the options all do, there's a JSON schema documented here that can help you make the most of your config.
  3. The actual JSON schema is here and is used to do programmatic validation of your configuration.
  4. The motion configuration can be a bit overwhelming. The existing values in the sample config should get you started. You can also check out the motion and camera configuration files for a bit more information.

Installing The PI Portal Software

There are 3 primary delivery mechanisms for Pi Portal:

Please see the installation guide for further details.

Logs and Slack Bot

Once configured and installed you should be streaming your logs to logz.io, where you can create custom notifications and integrate with other services. You will also be receiving notifications on the configured Slack channel whenever a door is opened or closed.

You can also interact with the bot service on the Slack channel, try the command help to get started.