Skip to content

Commit 0fc3afa

Browse files
committed
Update for 0.3 release
1 parent 9111133 commit 0fc3afa

37 files changed

+664
-234
lines changed

README.md

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
1-
_**Note**: This is a development branch for testing: partitions 2-8, zones 33-64, virtual keypad partitions 1 & 2. The library methods have changed to accommodate multiple partitions and the previous methods have been removed - see the examples sketches for usage. The new methods should not change in the future and can be considered stable (in theory!)._
2-
31
# DSC Keybus Interface
4-
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 system events, and usage as a virtual keypad. The included examples demonstrate monitoring armed/alarm/zone/fire/trouble states, integrating with Home Assistant and Apple HomeKit using MQTT, sending push notifications/email, and reading/decoding Keybus data.
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 system events, and usage as a virtual keypad. The included examples demonstrate monitoring armed/alarm/zone/fire/trouble states, integrating with Home Assistant/Apple HomeKit/Homey, sending push notifications/email, and reading/decoding Keybus data.
53

64
For example, an Arduino Uno (with an ethernet module) or the inexpensive NodeMCU and Wemos D1 Mini modules ($3USD shipped) can be used with [Homebridge](https://github.com/nfarina/homebridge) for notifications and control of the security system through the iOS Home app and Siri:
75

86
![dscHomeKit](https://user-images.githubusercontent.com/12835671/39588413-5a99099a-4ec1-11e8-9a2e-e332fa2d6379.jpg)
97

108
## Features
11-
* Tested DSC panels: PC1555MX, PC5015, PC1616, PC1832, PC1864
12-
* Partitions: 1-8, zones: 1-64
13-
* Virtual keypad: supports sending keys to the panel for partitions 1 and 2
14-
* Data buffering: helps prevent missing Keybus data when the sketch is busy
15-
* Non-blocking code: allows sketches to run as quickly as possible without using `delay` or `delayMicroseconds`.
9+
* Status tracking of armed/alarm/fire states for partitions 1-8
10+
* Status tracking of zones 1-64
11+
* Virtual keypad: Enables writing keys to the panel for partitions 1 and 2
12+
* Data buffering: Helps prevent missing Keybus data when the sketch is busy
13+
* Non-blocking code: Allows sketches to run as quickly as possible without using `delay` or `delayMicroseconds`.
14+
* Tested DSC panels: PC1555MX, PC5015, PC1616, PC1832, PC1864. All PowerSeries panels are supported, post an issue if you have a different panel (PC5020, etc) and have tested the interface to update this list.
15+
16+
## Release notes
17+
* 0.3
18+
- New: Status for partitions 2-8, zones 33-64
19+
- New: Virtual keypad support for partition 2
20+
- New: [Athom Homey](https://www.athom.com/en/) integration example sketch, contributed by [MagnusPer](https://github.com/MagnusPer)
21+
- New: PCB layouts, contributed by [sjlouw](https://github.com/sj-louw)
22+
- New: Configurable number of partitions and zones to customize memory usage: `dscPartitions` and `dscZones` in `dscKeybusInterface.h`
23+
- New: KeybusReader decoding of commands `0xE6` and `0xEB`
24+
- Changed: Split examples by platform
25+
- Changed: MQTT examples updated with username and password fields
26+
- Changed: `processRedundantData` now true by default to prevent storing repetitive data, reduces memory usage.
27+
- Note: This release changes the library methods to accomodate multiple partitions, existing sketches will need to be updated to match the new example sketches.
28+
* 0.2
29+
- New: Status for zones 9-32
30+
- New: HomeAssistant integration example sketch
31+
- New: Panel data buffering, adds `dscBufferSize` to `dscKeybusInterface.h` to allow configuration of how many panel commands are buffered to customize memory usage (uses 18 bytes of memory per command buffered).
32+
* 0.1 - Initial release
1633

1734
## Usage
1835
Download the repo and extract to the Arduino library directory or [install through the Arduino IDE](https://www.arduino.cc/en/Guide/Libraries#toc4): `Sketch > Include Library > Add .ZIP Library`. Alternatively, `git clone` the repo in the Arduino library directory to keep track of the latest changes - after the code has been tested across different panels, I'll flag the library to be added to the Arduino Library Manager for integrated updates.
@@ -24,23 +41,21 @@ Download the repo and extract to the Arduino library directory or [install throu
2441

2542
See `src/dscKeybusPrintData.cpp` for all currently known Keybus protocol commands and messages. Issues and pull requests with additions/corrections are welcome!
2643

27-
* Status: Processes and prints the security system status to a serial interface, including reading from serial for the virtual keypad. This demonstrates how to determine if the security system status has changed, what has changed, and how to take action based on those changes. Post an issue/pull request if you have a use for additional commands - for now, only a subset of all decoded commands are being tracked for status:
28-
* Armed away/stay/disarmed
29-
* Partition in alarm
30-
* Zones
44+
* Status: Processes and prints the security system status to a serial interface, including reading from serial for the virtual keypad. This demonstrates how to determine if the security system status has changed, what has changed, and how to take action based on those changes. Post an issue/pull request if you have a use for additional commands - for now, only a subset of all decoded commands are being tracked for status to limit memory usage:
45+
* Partitions armed away/stay/disarmed
46+
* Partitions in alarm
47+
* Partitions exit delay in progress
48+
* Partitions entry delay in progress
49+
* Partitions fire alarm
50+
* Zones open/closed
3151
* Zones in alarm
32-
* Exit delay in progress
33-
* Entry delay in progress
34-
* Fire
3552
* Keypad fire/auxiliary/panic alarm
3653
* Panel AC power
3754
* Panel battery
3855
* Panel trouble
3956

4057
* Status-MQTT-Homebridge: Processes the security system status and allows for control using Apple HomeKit, including the iOS Home app and Siri. This uses MQTT to interface with [Homebridge](https://github.com/nfarina/homebridge) and [homebridge-mqttthing](https://github.com/arachnetech/homebridge-mqttthing) for HomeKit integration and demonstrates using the armed and alarm states for the HomeKit securitySystem object, zone states for the contactSensor objects, and fire alarm states for the smokeSensor object.
4158

42-
Note: homebridge-mqttthing seems to have a bug for the smokeSensor object, I've fixed the bug and forked the repo until upstream is patched: [taligentx/homebridge-mqttthing](https://github.com/taligentx/homebridge-mqttthing)
43-
4459
* Status-MQTT-HomeAssistant: Processes the security system status and allows for control with [Home Assistant](https://www.home-assistant.io) via MQTT. This uses the armed and alarm states for the HomeAssistant [Alarm Control Panel](https://www.home-assistant.io/components/alarm_control_panel.mqtt) component, as well as fire alarm and zone states for the [Binary Sensor](https://www.home-assistant.io/components/binary_sensor.mqtt) component.
4560

4661
* Status-Homey: Processes the security system status and allows for control using [Athom Homey](https://www.athom.com/en/) and the [Homeyduino](https://github.com/athombv/homey-arduino-library/) library, including armed, alarm, fire, and zone states.
@@ -103,7 +118,7 @@ Keys are sent to partition 1 by default and can be changed to a different partit
103118
Examples:
104119
* Switch to partition 2 and send keys: `/2` + `1234`
105120
* Switch back to partition 1: `/1`
106-
* Set directly in sketch: `dsc.writePartition = 1`
121+
* Set directly in sketch: `dsc.writePartition = 1;`
107122

108123
## DSC Configuration
109124
Panel options affecting this interface, configured by `*8 + installer code`:
@@ -112,8 +127,13 @@ Panel options affecting this interface, configured by `*8 + installer code`:
112127
This section also sets the delay in reporting AC power failure to 30 minutes by default and can be set to 000 for no delay.
113128

114129
## Notes
115-
* Memory usage can be reduced by lowering the number of partitions and zones specified in `src/dscKeybusInterface.h`. By default, Arduino monitors up to 4 partitions/32 zones and esp8266 monitors up to 8 partitions/64 zones.
116-
* Support for the esp32 and other platforms depends on adjusting the code to use their platform-specific timers. In addition to hardware interrupts to capture the DSC clock, this library uses platform-specific timer interrupts to capture the DSC data line in a non-blocking way 250us after the clock changes (without using `delayMicroseconds()`). This is necessary because the clock and data are asynchronous - I observed keypad data delayed up to 160us after the clock falls.
130+
* Memory usage can be adjusted based on the number of partitions, zones, and data buffer size specified in `src/dscKeybusInterface.h`. Default settings:
131+
* Arduino: up to 4 partitions, 32 zones, 10 buffered commands
132+
* esp8266: up to 8 partitions, 64 zones, 50 buffered commands
133+
134+
* PCB layouts are available in `extras/PCB Layouts` - thanks to [sjlouw](https://github.com/sj-louw) for contributing these designs!
135+
136+
* Support for the esp32 and other platforms depends on adjusting the code to use their platform-specific timers. In addition to hardware interrupts to capture the DSC clock, this library uses platform-specific timer interrupts to capture the DSC data line in a non-blocking way 250us after the clock changes (without using `delayMicroseconds()`). This is necessary because the clock and data are asynchronous - I've observed keypad data delayed up to 160us after the clock falls.
117137

118138
## References
119139
[AVR Freaks - DSC Keybus Protocol](https://www.avrfreaks.net/forum/dsc-keybus-protocol): An excellent discussion on how data is sent on the Keybus.

examples/Arduino/KeybusReader/KeybusReader.ino

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
/*
2-
* DSC Keybus Reader (Arduino, esp8266)
2+
* DSC Keybus Reader (Arduino)
33
*
44
* Decodes and prints data from the Keybus to a serial interface, including reading from serial for the virtual
55
* keypad. This is primarily to help decode the Keybus protocol - see the Status examples to put the interface
66
* to productive use.
77
*
88
* Wiring:
9-
* DSC Aux(-) --- Arduino/esp8266 ground
9+
* DSC Aux(-) --- Arduino ground
1010
*
11-
* +--- dscClockPin (Arduino Uno: 2,3 / esp8266: D1,D2,D8)
11+
* +--- dscClockPin (Arduino Uno: 2,3)
1212
* DSC Yellow --- 15k ohm resistor ---|
1313
* +--- 10k ohm resistor --- Ground
1414
*
15-
* +--- dscReadPin (Arduino Uno: 2-12 / esp8266: D1,D2,D8)
15+
* +--- dscReadPin (Arduino Uno: 2-12)
1616
* DSC Green ---- 15k ohm resistor ---|
1717
* +--- 10k ohm resistor --- Ground
1818
*
1919
* Virtual keypad (optional):
2020
* DSC Green ---- NPN collector --\
21-
* |-- NPN base --- 1k ohm resistor --- dscWritePin (Arduino Uno: 2-12 / esp8266: D1,D2,D8)
21+
* |-- NPN base --- 1k ohm resistor --- dscWritePin (Arduino Uno: 2-12)
2222
* Ground --- NPN emitter --/
2323
*
2424
* Power (when disconnected from USB):
25-
* DSC Aux(+) ---+--- Arduino Vin pin
26-
* |
27-
* +--- 5v voltage regulator --- esp8266 development board 5v pin (NodeMCU, Wemos)
28-
* |
29-
* +--- 3.3v voltage regulator --- esp8266 bare module VCC pin (ESP-12, etc)
25+
* DSC Aux(+) --- Arduino Vin pin
3026
*
3127
* Virtual keypad uses an NPN transistor to pull the data line low - most small signal NPN transistors should
3228
* be suitable, for example:
@@ -43,9 +39,9 @@
4339

4440
// Configures the Keybus interface with the specified pins - dscWritePin is optional, leaving it out disables the
4541
// virtual keypad.
46-
#define dscClockPin 3 // Arduino Uno: 2,3 esp8266: D1, D2, D8 (GPIO 5, 4, 15)
47-
#define dscReadPin 4 // Arduino Uno: 2-12 esp8266: D1, D2, D8 (GPIO 5, 4, 15)
48-
#define dscWritePin 5 // Arduino Uno: 2-12 esp8266: D1, D2, D8 (GPIO 5, 4, 15)
42+
#define dscClockPin 3 // Arduino Uno hardware interrupt pin: 2,3
43+
#define dscReadPin 5 // Arduino Uno: 2-12
44+
#define dscWritePin 6 // Arduino Uno: 2-12
4945
dscKeybusInterface dsc(dscClockPin, dscReadPin, dscWritePin);
5046

5147

0 commit comments

Comments
 (0)