Back in late 2016, I started working on a hobby project with the goal to monitor and automate things at šŸ . I started with a Raspberry Pi and a reed switch.

Over the years, I have expanded the project to include multiple door sensors, garage remote control, light control, security system, notification, system health monitoring. Iā€™m listing the hardware and software components used in my project and will provide architecture and design overview of the entire system.


TABLE OF CONTENTS:

  1. Hardware
  2. Software
  3. Architecture
  4. Wiring Drawing
  5. Screen Captures

HARDWARE:


SOFTWARE:


ARCHITECTURE:

Architecture
šŸ”

MasterRaspberryPi:

This pi is hosting the main web application(war) on a tomcat server. This is the central system(brain) to which all the peripheral devices such as sensors, remotes etc send status information (via other locally located raspberry pis). The web application makes the decision based on the input it receives from the devices. For example - if the main door is opened and the current time is 23:00 and the home is armed, then the siren needs to start and send notifications to users. This also provides a simple UI which lists all controls for the output devices (lights, sirens, garage remote). There are configuration pages available that allow end users to arm/dis-arm home, select time slots, intelligent control etc. There are some advanced configurations that also allow the user to set the IP address of other raspberry pis.
šŸ”


RpiS2GlassDoorSensor:

This is a running a java application (jar) which monitors the state of the reed switches installed on doors. Iā€™m also using the reed switches to check on the position of the door knob. Whenever there is any state change the application will relay the state to a cloud hosted rabbitmq (cloudamqp). The action to be executed on the state change is handled by MasterRaspberryPi. Iā€™m using this library for interacting with the GPIO pins on the raspberry pi - Pi4j
šŸ”


RpiS3ShutterGarageSiren & RpiS4HallSirenGarageRemote:

Similar to the RpiS2GlassDoorSensor this is running a java application (jar) that monitors the reed switch. This application has an additional functionality which is to control the siren. The MasterRaspberryPi communicates with these applications to control the state of the siren. The communication between MasterRaspberryPi and reed switches, siren is done via rabbitmq (cloudamqp). RpiS4HallSirenGarageRemote also has Garage remote control wired up which is again controlled via the rabbitmq.
šŸ”


cloudamqp:

The communication between the MasterRaspberryPi and other peripheral applications is done over rabbitMq. Iā€™m using the cloud hosted solution - cloudamqp.
šŸ”


telegram:

I have developed a telegram bot that is running on MasterRaspberryPi. The bot is listening for commands from authenticated end users. These users use the telegram app to send the commands. Based on the command received, my code will perform the necessary steps. Telegram bot is also used as notification system to provide up to date notifications. For example - whenever any door is opened/closed, siren started etc.
šŸ”


Prometheus:

Iā€™m running a local instance of prometheus on one of the raspberry pi. All the individual java applications(including tomcat instance) are instrumented with Prometheus JMX exporter (-javaagent) which publishes all the JMX related metrics to their respective localhost on a specific port. The prometheus is configured to scrape for JMX metrics from all the 5 raspberry pis. Prometheus is configured to publish the metrics collected to a cloud instance of Grafana (the free tier is sufficient for my purpose).
šŸ”


Grafana:

I have configured a dashboard which gives an overview of the health of the entire system. Iā€™m tracking the heap usage, thread counts, temperature, errors (using loki), up time for each of the applications in my system. I have also configured alerts (to be sent to my telegram app) when there is any deviation from the baseline such as - application is down, heap usage or thread count is growing etc.
šŸ”


otel with Grafana Tempo:

Iā€™m running the otel collector on the MasterRaspberryPi. The tomcat web application is instrumented with otel javaagent and the traces are collected by the otel collector. The collected metrics are published to Grafana Tempo.
šŸ”


WIRING DRAWING:

Below are the wiring drawings to connect raspberry pi GPIO to siren, reed switch and garage opener Wiring drawing
šŸ”


SCREEN CAPTURES:

Webapplication UI:

Login page of the web application Dashboard
Main page Dashboard
Configuration page Dashboard
Internal configuration page Dashboard
šŸ”


Grafana:

Dashboard showing various widgets for monitoring (including otel traces from MasterRaspberryPi) Dashboard Heap usage and temperature monitoring Heap usage, temperature
šŸ”


Telegram Notification:

Telegram notifications about door sensors
Telegram app notification
Telegram message to send command signals
Telegram app status and control
šŸ”