Home Assistant Alarm Monitor
THIS IS CURRENTLY BEING UPDATED & COMPLETED
This is a board that interfaces to my alarm panel to obtain Alarm PIR motion status (ir motion detected and in passive mode). It runs in parallel to the alarm and just senses the current state of each PIR. The board has a mounted Raspberry Pi 3B+ which communicates via MQTT with Home Assistant to provide the Alarm PIR Status instantaneously. The board is designed to monitor 20 zones via MQTT and also has two relays to arm and disarm the Alarm via MQTT - all from Home Assistant.
Please note - this is partly an instructable - everything that I have done here is out there, and I've written this document in a way that it is effectively my project notebook to myself on the board, so that when I return to this project along the process, it documented.
Also it may possibly be useful for others. I'll publish the Gerber files when the final version is complete.
Warning: I am a total NOOB with HA/MQTT/CIRCUIT DESIGN!
Supplies
To be documented:
Parts needed for Sensing Interface Circuit.
Parts needed for Relay Circuit.
Parts needed for Voltage Step down circuit.
Parts need for voltage divider.
Project Background
I started looking at connecting my alarm to Home Assistant and HomeKit to get the inputs from the PIR and alarm status onto my phone and Home Assistant. I was not looking to replace my alarm as my home insurance requires me to have it professionally monitored (and the savings in insurance premiums is greater than the cost of monitoring). So ultimately, all I wanted to do was sense the PIR states, and report it in to Home Assistant along with be able to turn off an off the alarm via Home Assistant - both the night time mode and all of house alarm mode
I have a GE/Tecom Challenger v8 with 16 zones which I am comfortable with. It is a rock solid system that was installed 18 years ago and has not missed a beat. My intention was to also have a couple of relays so that I can remotely arm the system (I have two zones - one all of house and one night-time zone which only arms the unoccupied areas). Furthermore, I might add a few PIR zones in future (for which I have an alarm expansion card) and may need more than 16 zones.
This document is about the Project Board and does not talk about the Challenger Alarm system given its so old and probably of no use to anyone.
Other Available Options for My Requirements
My easiest option out there was the Konnected.io system which my many people use and like, – and which would have been economical enough in its original version 1 based on the NodeMCU – although I would have needed 6 boards in total plus two relay boards. It would have required me to maintain 3 Konnected.io Cards/NodeMCU's along with 3 Interface cards and two relay boards (ie eight boards). To me this was cumbersome! Konnected is a great system, especially if I had only six or 12 zones zones.
I just wanted a single board.
Furthermore, at the time, Konnected only had a WIFI system based on the nodeMCU, and I really wanted an ethernet connected system for reliability.
Note: I started this project before the Konnected Pro came out in November 2020 and before the Konnected Alarm Panel Interface Module v2.1. Notwithstanding, I think I still would not have gone with the Konnected Pro unit for me as it is still only has 12 zones plus the two interface boards and I would have needed two systems and still didn't have some the features that I wanted to ultimately add.
As mentioned above, Konnected is a great system from everything I have read.
Doing Some Research
I looked online and found a few resources to leverage off and decided to build my own board for my own purposes.
A little disclosure here, the last time I actually did anything with electronics like this was over 35 years ago. For some reason I thought I would etch a PCB again like the old days – after some surfing I found out about the new world of small run PCB fabricators and I thought – this is a project to build during Covid-19 Lockdown – it encouraged me to grow the scope a little too!
Voltage of the GPIO on the Board
Firstly, I needed to decide on what Voltage the Board GPIO's would be on a high/low basis.
- A Pi GPIO max voltage for the GPIO is 3.3V.
- An Arduino max voltage for the GPIO is 5V.
- A NodeMCU max voltage for the GPIO is 3.3V.
- A BeagleBone max voltage for the GPIO is 3.3V or 1.8V depending on the depending on the VDDSHVx voltage, which powers the I/O cell.
Given I was likely going to use a Pi, I decided on 3.3V but also wanted to have an option to operate at 5V just in case I want to use an arduino. So I decided to incorporate a voltage divider that will provide an option of either 5V or 3.3 volts.
Design Aims Determined by My Research
I wanted the project board to:
- sense all PIR zones and be able to indicate by GPIO output if activated or not.
- activate and deactivate my existing alarm via relays activated by GPIO inputs and connected to my alarm zones.
- Have power supplied by the existing alarm that would also convert to 5VDC or 3.3VDC.
- Communicate with Home assistant via MQTT
- Integrate into Apple HomeKit relatively easily (should be easy if I connect to HA).
Design Components of the Board
The Board would be made up of the following components:
1 - THE PARALLEL SENSING INTERFACE
- The main sensing interface that would sit across the PIR + (positive) terminals and monitor the voltage in a passive (clear) state as well as an activated (motion detected) state. It only reads what the PIR is doing and does not affect it. The power for the parallel sensing interface voltage comparator chip (The LM339) will come from the alarm itself. It is a robust chip that can safely take up to 36VDC.
2 - A VOLTAGE CONVERTER TO POWER THE LEDs
- a 5VDC power converter that would create the DC power to provide the power for the LED and provide power to the pull up resistors to to provide a 3.3V High GPIO output if for Pi or 5V for Arduino.
3 - A VOLTAGE CONVERTER TO POWER THE LEDs and provide the GPIO High Low voltage
- given that I want to use the board for both Arduino and Pi - I need a voltage divider and selector to run at either 3.3V or 5V for the GPIO High voltage. I will use a two resistor voltage divider to get 3.3V from 5V.
4 - RELAY CIRCUITS TO TURN ON/OFF THE ZONES
- The relay circuits would activate and deactivate the zones to my alarm.
- I needed two to run off the Pi GPIOs
5 - A SINGLE BOARD COMPUTER TO MONITOR THE OUTPUT AND PROCESS THE MQTT TO HOME ASSISTANT
- Given I decided that I communicate via MQTT, I thought it would be best to have the single board computer close by.
- I didn't like the idea of the computer being away from the the board so I wanted a mount on the actual board that would enable it to form part of the board.
The Parallel Sensing Interface Design
My acknowledgement goes to the instructable “Alarm PIR to WiFi Project” by chimeranzl (https://www.instructables.com/Alarm-PIR-Movement-to-Home-Automation/) which form the basis of the parallel interface sensing circuit.
Using “Alarm PIR to WiFi Project” circuit, I connected to my alarm. All went well, but I decided to modify the design of the circuit and added an NPN transistors and LED into the design so that an LED will actually activate on the board (ie turn the LED on) when the PIR is activated (ie in a motion detected state). (This is opposite to how I understand that the Konnected.io system works. I just thought it would be more intuiative to have an LED on when motion was detected out in a room.) The schematic above uses one TI LM339 Chip which has 4 on board voltage comparators.
Each TI LM339 circuit is replicated five times to give the board 20 zones.
Theoretically I could have used a two resister voltage divider for the VRef of the PIR, but i decided to use trimmer pots to give me the flexibility to use this board for other sensing requirements. Therefore, I added 20 trimmer pots simply so that I can use the boards for other voltage sniffing projects I want to do later (eg for my pool chemistry).
Voltage Step Down Element
Another part of the design is the Voltage converter that creates 5VDC from the alarm power feed (mine is 15V). I've used a conventional circuit with a linear converter using the LM7805. Initially it appeared that it was getting too hot on the finished Board, but after adding a small heat sink and testing it in operation for a week, it appears a little hot but fine. I may redesign it for the Beta version of the Board with a DC-DC buck - but I will see how the 5V linear converter works.
Voltage Divider to Reduce 5V GPIO Output to 3.3V
I decided to add a voltage divider to reduce the 5V being generated down to 3.3V I’ve done this with through-hole resistors in order to allow me to replace the resistors with others easily just in case I need a different voltage for the GPIO - eg for some BeagleBone uses. Also I added a Jumper J9 which bypasses the voltage divider in order to use the native 5V for the GPIO (for arduino use)
A pretty standard circuit with some mods. See for example https://randomnerdtutorials.com/how-to-level-shift-5v-to-3-3v/
Relay Schematic
Again, the schematic diagram of the Relay Circuit is pretty much what is out there. I copied it from a generic relay board I had lying around. I am pretty sure they're all similar out there.
A good intro for this can be found here:
https://www.pcbway.com/project/shareproject/2_Channel_5v_Relay_module_For_Arduino.html
and here:
https://components101.com/switches/5v-single-channel-relay-module-pinout-features-applications-working-datasheet
The Single Board Computer (SBC) Choice
I decided to use a Raspberry Pi 3B+ for a couple of reasons:
- I am comfortable with a Pi
- It has lots of GPIO’s that I can take advantage of.
- Its very flexible
Of course there is no reason why an Arduino, NodeMCU, BeagleBone etc couldn't be used as well to communicate - its just that I am just proficient enough on a Pi before wanting to learn another board. But for my purposes I decided a Pi 3B+ was best.
Also, by the time I finished the Board design, I decided to add a few ground terminals and AUX Power terminals that essentially allow the board and Pi to act as a stand alone alarm system – this may well be another later project - not sure at this stage. The Aux Power can be used to power the PIRs while the Ground Headers obviously ground the PIR.
AVAILABLE GPIOs on a Raspberry Pi 3B+
I chose 20 zones because I know that the Pi has around 22 odd available GPIO's and that would cover my initial needs of at least 16 zones. The available GPIOs on the Pi exclude GPIO2 (SDA) and GPIO3(SCL) as the pull up resisters are fixed and i2C needs to be disabled to use them. Given I wanted to possibly look at using i2C in my future Beta board, I treat these as not usable. Also I am assuming the GPIO14 (TXD) and GPIO15(RXD) are not usable unless you want to disable serial communications. Again, I might have a need for this later, so I am assuming they are not usable. Of course GPIO0 and GPIO1 are for advanced use only and not usable. Thus leaving exactly 22 GPIOs that can be used. This was enough for 20 monitored zones and 2 relays.
MQTT-IO Was Used As the Communication Method
I decided to use the MQTT-IO Project by Flyte found at this website http://mqtt-io.app/ and on github at https://github.com/flyte/mqtt-io
I will in due course post a separate instructable on the MQTT-IO installation process. (PROVIDE LINK to MQTT-IO instructable here)
But for the current puposes the relevant Yaml file was configured like this
#Board01 Alpha
mqtt:
host: MQTT Broker IP addresss
port: 1883
user: "************"
password: "****************"
topic_prefix: alarm
#This exposes home-assistant discovery to make it easier for Home Assistant to see the published topics
ha_discovery:
enabled: yes
gpio_modules:
- name: rpi
module: raspberrypi
#Digital Outputs List
#This is where the relay triggers are
#Hash "#" the Relays you will NOT use otherwise they will appear in Home Assistant
digital_outputs:
#GPIO8 is an output connected to Relay 1
#mqtt topic published is alarm/output/relay01
- name: relay01
module: rpi
pin: 8
#GPIO7 is an output connected to Relay 2
#mqtt topic published is alarm/output/relay02
- name: relay02
module: rpi
pin: 7
#Digital Inputs List
#This is where the PIR's are
#Hash "#" the PIR zones you will NOT use otherwise they will appear as in a "motion detected" state
#mqtt topic published is alarm/input/pir01
digital_inputs:
#Zone 1 is connected to Pi Pin 15 (GPIO 22) is an input connected to the Front Door PIR
#mqtt topic published is alarm/input/pir01
- name: pir01
module: rpi
pin: 22
on_payload: "Motion Detected"
off_payload: "Clear"
pullup: yes
pulldown: no
#Zone 2 is connected to Pi Pin 13 (BCM 27) is an input connected to the Lounge PIR
#mqtt topic published is alarm/input/pir02
- name: pir02
module: rpi
pin: 27
on_payload: "Motion Detected"
off_payload: "Clear"
pullup: yes
pulldown: no
See the attached file for the complete Yaml file in text format.
the mapping of each Zone PIR to the Pi PIN is printed on the board.
Downloads
Pi Header Added
- I added a Pi header to allow the Pi to connect with a short 40pin flat cable to keep the board appearance clean. Therefore I can use a flat cable or connect the DuPont cables directly to the pins. There is a photo of each above.
- I’ve also broken out the unused Raspberry Pi Pins that are not used for GPIO detection of the zones and to activate the relays into a long J2 – just in case they have a use (especially RX TX and SDA SCL) and I want to connect onto them.
- I have also added J4 to J8 which allows me to pick up single GPIO signals just in case I decide to use an Arduino, NodeMCU, BeagleBone etc to trial (just in case the Pi is a bad idea). It also allows me to connect the logic analyser onto the board to see how it’s working.
Production of Board
Went to production with the Alpha version. Total cost was about $15USD per board including all the smd parts I was able to get JLCPCB to directly mount (I got 5 made as I intended to work on them). Solder on parts added another $9USD per board (including shipping).
I will add Gerber Files, BOM's etc in due course once i receive the updated Board without the errors I made on the initial Alpha Board.
Installation
Installation is relatively easy.
- A wire for each positive PIR wire is connected at the top.
- An aux power feed from the alarm connects to the 9-24DC In Terminal. If you decide to use an external power supply, you must GROUND the alarm to this Board.
- A 5VDC external supply is connected to the 5V external power terminal. (Bridge J3 to External)
- Mount the Pi and connect power to it.
- GPIOs connect to each Pi Pin as per "Mapping of Zones"
- Connect the Pi to J1. If you decide not to use J1 then you must GROUND the Pi to this Board using one of the GND pins.
- Turn each Potentiometer fully anti clockwise - then turn it slowly clockwise until respective LED goes off. What this will do is set the VRef of the PIR in motion not detected mode.
- Assuming MQTT-IO is installed and working - turn on your pi and connect to Home Assistant.
Mistakes Made
I made two mistakes on the Alpha Board.
The PCB design error which I had to manually fix. (see above photo.) this was a PCB design error not picked up.
Future Upgrades / Improvements
Some improvements I am looking to execute in Version 2 of the ALPHA version of the Board:
- Repair the resistor error.
Some specification improvements I am looking to execute in BETA version of the Board:
- a 5VDC DC-DC power buck.
- on-board native i2C Integration so additonal boards can be added without the need for more Rasberry Pi’s.
- investigate the use of the Board as a stand alone Alarm. Including use of end of line resistors.
Magnetic Feet to Hold the Board to My Steel Alarm Box
I made my own magnetic offsets by assembling:
- 10mm x 3mm neodymium ring countersunk head magnets. I'll get 13mm magnets next time just for extra strength. Although the 10mm are acceptable for this size board.
- M2.5mm brass female female offsets (15mm high)
- M2.5mm (x 6mm recommended) pan head screws for the top
- M2.5mm (x 6mm recommended) countersunk screws for the bottom
I also made a nylon set that work as well to avoid any magnet issues - even hough brass is not magnetic - I just thought they may be worth testing.
Testing and How It Runs
Here is the Board in operation while in testing mode without using the 40oin Ribbon Pi Vable. As the light goes on, the GPIO state goes high and is then reported to home assistant via MQTT and then onto HomeKit. It is quite seamless and there is a lag of approx 1/2 a second from the PIR being activated and showing up on my iphone. And a short video of my phone looking at the HomeKit app while walking from my study into the hall and into the lounge room.