Skip to content

Commit 8ff079d

Browse files
committed
Release 1.2
1 parent 958d2bc commit 8ff079d

File tree

16 files changed

+607
-362
lines changed

16 files changed

+607
-362
lines changed

README.md

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# DSC Keybus Interface
2-
This library directly interfaces Arduino and esp8266 microcontrollers to [DSC PowerSeries](http://www.dsc.com/dsc-security-products/g/PowerSeries/4) security systems for integration with home automation, notifications on alarm events, and usage as a virtual keypad. This enables homes and offices with existing DSC security systems (of which millions have been installed over the decades) to connect with modern devices and software, while retaining the features and reliability of a hardwired system.
2+
This library directly interfaces Arduino and esp8266 microcontrollers to [DSC PowerSeries](http://www.dsc.com/dsc-security-products/g/PowerSeries/4) security systems for integration with home automation, notifications on alarm events, and usage as a virtual keypad. This enables homes and offices with existing DSC security systems (of which millions have been installed over the decades) to connect with modern devices and software, while retaining the features and reliability of a hardwired system for under $5USD in components.
33

44
The built-in examples can be used as-is or as a base to adapt to other uses:
55
* Home automation: [Home Assistant](https://www.home-assistant.io), [Apple HomeKit & Siri](https://www.apple.com/ios/home/), [Athom Homey](https://www.athom.com/en/)
6-
* Notifications: [PushBullet](https://www.pushbullet.com), [Twilio](https://www.twilio.com), MQTT, E-mail
6+
* Notifications: [PushBullet](https://www.pushbullet.com), [Twilio SMS](https://www.twilio.com), MQTT, E-mail
77
* Virtual keypad: Web interface, [Blynk](https://www.blynk.cc) mobile app
88

99
## Screenshots
@@ -31,42 +31,47 @@ While there has been excellent [discussion about the DSC Keybus protocol](https:
3131
* Read-only - unable to control the Keybus to act as a virtual keypad.
3232
* No implementations to do useful work with the data.
3333

34-
Poking around with a logic analyzer and oscilloscope revealed that the errors capturing the Keybus data were timing issues. Updating the existing projects to fix this turned out to be more troublesome than starting from scratch, so this project was born. After resolving the data errors, decoding the data required capturing the Keybus binary data as the security system handled various events and reverse engineering the protocol.
35-
36-
At this point, this interface resolves all of the earlier issues (and goes beyond my initial goal of simply seeing if the alarm is triggered).
34+
Poking around with a logic analyzer and oscilloscope revealed that the errors capturing the Keybus data were timing issues. Updating the existing projects to fix this turned out to be more troublesome than starting from scratch, so this project was born. After resolving the data errors, it was possible to reverse engineer the protocol by capturing the Keybus binary data as the security system handled various events. At this point, this interface resolves all of the earlier issues (and goes beyond my initial goal of simply seeing if the alarm is triggered).
3735

3836
## Features
39-
* Monitor the alarm state of all partitions: alarm triggered, armed/disarmed, entry/exit delay, fire triggered
37+
* Monitor the alarm state of all partitions: alarm triggered, armed/disarmed, entry/exit delay, fire triggered, keypad panic keys
4038
* Monitor the state of all zones: zones open/closed, zones in alarm
39+
* Monitor the system status: trouble, AC power, battery
4140
* Virtual keypad: Send keys to the panel for any partition
4241
* Direct Keybus interface: does not require the [DSC IT-100 serial interface](https://www.dsc.com/alarm-security-products/IT-100%20-%20PowerSeries%20Integration%20Module/22).
4342
* Supported security systems: [DSC PowerSeries](https://www.dsc.com/?n=enduser&o=identify)
44-
- Verified panels: PC585, PC1555MX, PC5005, PC5015, PC1616, PC1808, PC1832, PC1864.
43+
- Verified panels: PC585, PC1555MX, PC1565, PC5005, PC5015, PC1616, PC1808, PC1832, PC1864.
4544
- All PowerSeries series are supported, please [post an issue](https://github.com/taligentx/dscKeybusInterface/issues) if you have a different panel (PC5020, etc) and have tested the interface to update this list.
4645
- Rebranded DSC PowerSeries (such as some ADT systems) should also work with this interface.
47-
* Unsupported security systems:
48-
- DSC Classic ([PC1500, etc](https://www.dsc.com/?n=enduser&o=identify)): Uses a different data protocol, though support is theoretically possible.
49-
- DSC Neo: Uses a higher speed encrypted data protocol (Corbus) that is not possible to support.
50-
- Honeywell, Ademco, and other brands (that are not rebranded DSC systems) use totally different protocols and are not supported.
5146
* Supported microcontrollers:
52-
- Arduino: Uno, Mega, Leonardo, Mini, Micro, Nano, Pro, Pro Mini (ATmega328P, ATmega2560, and ATmega32U4-based boards at 16Mhz)
53-
- esp8266: NodeMCU, Wemos D1 Mini, ESP12, etc - these work with the Arduino framework, have integrated WiFi, and feature much better performance/memory at only $3USD shipped.
47+
- [Arduino](https://www.arduino.cc/en/Main/Products): Uno, Mega, Leonardo, Mini, Micro, Nano, Pro, Pro Mini (ATmega328P, ATmega2560, and ATmega32U4-based boards at 16Mhz)
48+
- esp8266: NodeMCU v2 or v3, Wemos D1 Mini, etc.
49+
* Includes [Arduino framework support](https://github.com/esp8266/Arduino), integrated WiFi, and improved specs at only $3USD shipped.
50+
* NodeMCU modules are a good choice as they can be powered directly from the DSC panel, the Wemos D1 Mini requires an additional 5v voltage regulator to handle the 12v+ DSC panel power.
5451
* Designed for reliable data decoding and performance:
5552
- Pin change and timer interrupts for accurate data capture timing
5653
- Data buffering: helps prevent lost Keybus data if the sketch is busy
57-
- Extensive data decoding: reverse engineered the majority of Keybus data as seen in the [DSC IT-100 Data Interface developer's guide](https://cms.dsc.com/download.php?t=1&id=16238) and documented in [`src/dscKeybusPrintData.cpp`](https://github.com/taligentx/dscKeybusInterface/blob/master/src/dscKeybusPrintData.cpp).
54+
- Extensive data decoding: the majority of Keybus data as seen in the [DSC IT-100 Data Interface developer's guide](https://cms.dsc.com/download.php?t=1&id=16238) has been reverse engineered and documented in [`src/dscKeybusPrintData.cpp`](https://github.com/taligentx/dscKeybusInterface/blob/master/src/dscKeybusPrintData.cpp).
5855
- Non-blocking code: Allows sketches to run as quickly as possible without using `delay` or `delayMicroseconds`
56+
* Unsupported security systems:
57+
- DSC Classic series ([PC1500, etc](https://www.dsc.com/?n=enduser&o=identify)) use a different data protocol, though support is possible.
58+
- DSC Neo series use a higher speed encrypted data protocol (Corbus) that is not possible to support.
59+
- Honeywell, Ademco, and other brands (that are not rebranded DSC systems) use different protocols and are not supported.
5960
* Potential future features (pending [sufficient interest](https://github.com/taligentx/dscKeybusInterface/issues)):
6061
- Virtual zone expander: Add new zones to the DSC panel emulated by the microcontroller based on GPIO pin states or software-based states. Requires decoding the DSC PC5108 zone expander data.
61-
- Installer code unlocking: Requires brute force checking all possible codes and a workaround if keypad lockout is enabled (possibly automatically power-cycling the panel to skip the lockout time).
62+
- Installer code unlocking: Requires brute force checking all possible codes and a workaround if keypad lockout is enabled (possibly automatically power-cycling the panel with a relay to skip the lockout time).
6263
- ESP32 microcontroller support: At minimum, requires changing the timer interrupts.
6364
- DSC Classic series support: This protocol is [already decoded](https://github.com/dougkpowers/pc1550-interface), use with this library would require major changes.
6465

6566
## Release notes
6667
* 1.2
6768
- New: Virtual keypad web interface example, thanks to [Elektrik1](https://github.com/Elektrik1) for this contribution!
69+
- As of esp8266 Arduino Core 2.5.1, you may need to [manually update the esp8266FS plugin](https://github.com/esp8266/arduino-esp8266fs-plugin) for SPIFFS upload.
70+
- New: Support esp8266 CPU running at 160MHz - this helps sketches using TLS through BearSSL
6871
- Updated: HomeAssistant-MQTT example includes availability status, thanks to [bjrolfe](https://github.com/bjrolfe) for this contribution!
69-
- Updated: List of tested DSC panels: PC585, PC5005, PC1808
72+
- Updated: List of tested DSC panels: PC585, PC1565, PC5005, PC1808
73+
- Updated: esp8266 power wiring diagrams
74+
- Updated: esp8266 module list
7075
* 1.1
7176
- New: Zones 33-64 tamper and fault decoding
7277
- New: Push notification example using [Twilio](https://www.twilio.com), thanks to [ColingNG](https://github.com/ColinNg) for this contribution!
@@ -138,6 +143,12 @@ The included examples demonstrate how to use the library and can be used as-is o
138143

139144
* **Email** (esp8266-only): Demonstrates how to send an email when the status has changed. Email is sent using SMTPS (port 465) with SSL for encryption - this is necessary on the ESP8266 until STARTTLS can be supported. For example, this will work with Gmail after changing the account settings to [allow less secure apps](https://support.google.com/accounts/answer/6010255).
140145

146+
This can be used to send SMS messages if the number's service provider has an [email to SMS gateway](https://en.wikipedia.org/wiki/SMS_gateway#Email_clients) - examples for the US:
147+
* T-mobile: [email protected]
148+
* Verizon: [email protected]
149+
150+
151+
141152
* **VirtualKeypad-Blynk** (esp8266-only): Provides a virtual keypad interface for the free [Blynk](https://www.blynk.cc) app on iOS and Android. Scan one of the following QR codes from within the Blynk app for an example keypad layout:
142153
- [Virtual keypad with 16 zones](https://user-images.githubusercontent.com/12835671/42364287-41ca6662-80c0-11e8-85e7-d579b542568d.png)
143154
- [Virtual keypad with 32 zones](https://user-images.githubusercontent.com/12835671/42364293-4512b720-80c0-11e8-87bd-153c4e857b4e.png)
@@ -153,7 +164,13 @@ The included examples demonstrate how to use the library and can be used as-is o
153164
## Wiring
154165

155166
```
156-
DSC Aux(-) --- Arduino/esp8266 ground
167+
DSC Aux(+) ---+--- Arduino Vin pin
168+
|
169+
+--- esp8266 NodeMCU Vin pin
170+
|
171+
+--- 5v voltage regulator --- esp8266 Wemos D1 Mini 5v pin
172+
173+
DSC Aux(-) --- Arduino/esp8266 Ground
157174
158175
+--- dscClockPin (Arduino Uno: 2,3 / esp8266: D1,D2,D8)
159176
DSC Yellow --- 15k ohm resistor ---|
@@ -167,23 +184,17 @@ Virtual keypad (optional):
167184
DSC Green ---- NPN collector --\
168185
|-- NPN base --- 1k ohm resistor --- dscWritePin (Arduino Uno: 2-12 / esp8266: D1,D2,D8)
169186
Ground --- NPN emitter --/
170-
171-
Power (when disconnected from USB):
172-
DSC Aux(+) ---+--- Arduino Vin pin
173-
|
174-
+--- 5v voltage regulator --- esp8266 development board 5v pin (NodeMCU, Wemos)
175-
|
176-
+--- 3.3v voltage regulator --- esp8266 bare module VCC pin (ESP-12, etc)
177187
```
178188

179189
## Wiring Notes
180190
* The DSC Keybus operates at ~12.6v, a pair of resistors per data line will bring this down to an appropriate voltage for both Arduino and esp8266.
181-
* Arduino: connect the DSC Yellow (Clock) line to a [hardware interrupt pin](https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/) - for the Uno, these are pins 2 and 3. The DSC Green (Data) line can be connected to the remaining digital pins 2-12.
191+
* Arduino: connect the DSC Yellow (Clock) line to a [hardware interrupt pin](https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/) - for the Uno, these are pins 2 and 3. The DSC Green (Data) line can be connected to any of the remaining digital pins 2-12.
182192
* esp8266: connect the DSC lines to GPIO pins that are normally low to avoid putting spurious data on the Keybus: D1 (GPIO5), D2 (GPIO4) and D8 (GPIO15).
183193
* Virtual keypad uses an NPN transistor and a resistor to write to the Keybus. Most small signal NPN transistors should be suitable, for example:
184194
* 2N3904
185195
* BC547, BC548, BC549
186196
* That random NPN at the bottom of your parts bin (my choice)
197+
* Connections should be soldered, breadboards can cause issues.
187198

188199
## Virtual keypad
189200
This allows a sketch to send keys to the DSC panel to emulate the physical DSC keypads and enables full control of the panel from the sketch or other software.

examples/Arduino/HomeAssistant-MQTT/HomeAssistant-MQTT.ino

Lines changed: 79 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,83 @@
11
/*
2-
* HomeAssistant-MQTT 1.0 (Arduino)
2+
* HomeAssistant-MQTT 1.0 (Arduino with Ethernet)
33
*
44
* Processes the security system status and allows for control using Home Assistant via MQTT.
55
*
66
* Home Assistant: https://www.home-assistant.io
77
* Mosquitto MQTT broker: https://mosquitto.org
88
*
9+
* Usage:
10+
* 1. Set the security system access code to permit disarming through Home Assistant.
11+
* 2. Set the MQTT server address in the sketch.
12+
* 3. Copy the example configuration to Home Assistant's configuration.yaml and customize.
13+
* 4. Upload the sketch.
14+
* 5. Restart Home Assistant.
15+
*
16+
* Example Home Assistant configuration.yaml:
17+
18+
# https://www.home-assistant.io/components/mqtt/
19+
mqtt:
20+
broker: URL or IP address
21+
client_id: homeAssistant
22+
23+
# https://www.home-assistant.io/components/alarm_control_panel.mqtt/
24+
alarm_control_panel:
25+
- platform: mqtt
26+
name: "Security System Partition 1"
27+
state_topic: "dsc/Get/Partition1"
28+
availability_topic: "dsc/Status"
29+
command_topic: "dsc/Set"
30+
payload_disarm: "1D"
31+
payload_arm_home: "1S"
32+
payload_arm_away: "1A"
33+
- platform: mqtt
34+
name: "Security System Partition 2"
35+
state_topic: "dsc/Get/Partition2"
36+
availability_topic: "dsc/Status"
37+
command_topic: "dsc/Set"
38+
payload_disarm: "2D"
39+
payload_arm_home: "2S"
40+
payload_arm_away: "2A"
41+
42+
# https://www.home-assistant.io/components/binary_sensor/
43+
binary_sensor:
44+
- platform: mqtt
45+
name: "Security Trouble"
46+
state_topic: "dsc/Get/Trouble"
47+
device_class: "problem"
48+
payload_on: "1"
49+
payload_off: "0"
50+
- platform: mqtt
51+
name: "Smoke Alarm 1"
52+
state_topic: "dsc/Get/Fire1"
53+
device_class: "smoke"
54+
payload_on: "1"
55+
payload_off: "0"
56+
- platform: mqtt
57+
name: "Smoke Alarm 2"
58+
state_topic: "dsc/Get/Fire2"
59+
device_class: "smoke"
60+
payload_on: "1"
61+
payload_off: "0"
62+
- platform: mqtt
63+
name: "Zone 1"
64+
state_topic: "dsc/Get/Zone1"
65+
device_class: "door"
66+
payload_on: "1"
67+
payload_off: "0"
68+
- platform: mqtt
69+
name: "Zone 2"
70+
state_topic: "dsc/Get/Zone2"
71+
device_class: "window"
72+
payload_on: "1"
73+
payload_off: "0"
74+
- platform: mqtt
75+
name: "Zone 3"
76+
state_topic: "dsc/Get/Zone3"
77+
device_class: "motion"
78+
payload_on: "1"
79+
payload_off: "0"
80+
981
* The commands to set the alarm state are setup in Home Assistant with the partition number (1-8) as a prefix to the command:
1082
* Partition 1 disarm: "1D"
1183
* Partition 2 arm stay: "2S"
@@ -33,73 +105,10 @@
33105
* Fire alarm: "1"
34106
* Fire alarm restored: "0"
35107
*
36-
* Example Home Assistant configuration.yaml:
37-
38-
# https://www.home-assistant.io/components/mqtt/
39-
mqtt:
40-
broker: URL or IP address
41-
client_id: homeAssistant
42-
43-
# https://www.home-assistant.io/components/alarm_control_panel.mqtt/
44-
alarm_control_panel:
45-
- platform: mqtt
46-
name: "Security System Partition 1"
47-
state_topic: "dsc/Get/Partition1"
48-
availability_topic: "dsc/Status"
49-
command_topic: "dsc/Set"
50-
payload_disarm: "1D"
51-
payload_arm_home: "1S"
52-
payload_arm_away: "1A"
53-
- platform: mqtt
54-
name: "Security System Partition 2"
55-
state_topic: "dsc/Get/Partition2"
56-
availability_topic: "dsc/Status"
57-
command_topic: "dsc/Set"
58-
payload_disarm: "2D"
59-
payload_arm_home: "2S"
60-
payload_arm_away: "2A"
61-
62-
# https://www.home-assistant.io/components/binary_sensor/
63-
binary_sensor:
64-
- platform: mqtt
65-
name: "Security Trouble"
66-
state_topic: "dsc/Get/Trouble"
67-
device_class: "problem"
68-
payload_on: "1"
69-
payload_off: "0"
70-
- platform: mqtt
71-
name: "Smoke Alarm 1"
72-
state_topic: "dsc/Get/Fire1"
73-
device_class: "smoke"
74-
payload_on: "1"
75-
payload_off: "0"
76-
- platform: mqtt
77-
name: "Smoke Alarm 2"
78-
state_topic: "dsc/Get/Fire2"
79-
device_class: "smoke"
80-
payload_on: "1"
81-
payload_off: "0"
82-
- platform: mqtt
83-
name: "Zone 1"
84-
state_topic: "dsc/Get/Zone1"
85-
device_class: "door"
86-
payload_on: "1"
87-
payload_off: "0"
88-
- platform: mqtt
89-
name: "Zone 2"
90-
state_topic: "dsc/Get/Zone2"
91-
device_class: "window"
92-
payload_on: "1"
93-
payload_off: "0"
94-
- platform: mqtt
95-
name: "Zone 3"
96-
state_topic: "dsc/Get/Zone3"
97-
device_class: "motion"
98-
payload_on: "1"
99-
payload_off: "0"
100-
101108
* Wiring:
102-
* DSC Aux(-) --- Arduino ground
109+
* DSC Aux(+) --- Arduino Vin pin
110+
*
111+
* DSC Aux(-) --- Arduino Ground
103112
*
104113
* +--- dscClockPin (Arduino Uno: 2,3)
105114
* DSC Yellow --- 15k ohm resistor ---|
@@ -114,9 +123,6 @@
114123
* |-- NPN base --- 1k ohm resistor --- dscWritePin (Arduino Uno: 2-12)
115124
* Ground --- NPN emitter --/
116125
*
117-
* Power (when disconnected from USB):
118-
* DSC Aux(+) --- Arduino Vin pin
119-
*
120126
* Virtual keypad uses an NPN transistor to pull the data line low - most small signal NPN transistors should
121127
* be suitable, for example:
122128
* -- 2N3904
@@ -133,14 +139,15 @@
133139
#include <PubSubClient.h>
134140
#include <dscKeybusInterface.h>
135141

142+
// Settings
136143
byte mac[] = { 0xAA, 0x61, 0x0A, 0x00, 0x00, 0x01 }; // Set a MAC address unique to the local network
137-
138144
const char* accessCode = ""; // An access code is required to disarm/night arm and may be required to arm based on panel configuration.
139-
140145
const char* mqttServer = ""; // MQTT server domain name or IP address
141146
const int mqttPort = 1883; // MQTT server port
142147
const char* mqttUsername = ""; // Optional, leave blank if not required
143148
const char* mqttPassword = ""; // Optional, leave blank if not required
149+
150+
// MQTT topics - match to Home Assistant's configuration.yaml
144151
const char* mqttClientName = "dscKeybusInterface";
145152
const char* mqttPartitionTopic = "dsc/Get/Partition"; // Sends armed and alarm status per partition: dsc/Get/Partition1 ... dsc/Get/Partition8
146153
const char* mqttZoneTopic = "dsc/Get/Zone"; // Sends zone status per zone: dsc/Get/Zone1 ... dsc/Get/Zone64

0 commit comments

Comments
 (0)