You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+77-51
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,53 @@
1
1
# SmartThings Connected Wired Security System using a NodeMCU ESP8266
2
2
3
-
This project will help you connect SmartThings to wired contact sensors (for doors and windows) and motion sensors that you may already have pre-wired in your home from a built-in home security system. There are three components to the project:
3
+
This project will help you connect wired contact sensors and motion sensors from an old wired home alarm system (such as
4
+
Honeywell, ADT, Interlogix, etc) to Samsung SmartThings. Convert your old wired alarm system into an internet connected
5
+
Smart Alarm!
6
+
7
+
We use an inexpensive NodeMCU ESP82660 wifi enabled development board to connect our wired alarm system sensors to the
8
+
SmartThings.
9
+
10
+
There are three components to the project:
4
11
5
12
1. a SmartThings Device Handler for contact sensors and motion sensors
6
-
2. a SmartThings SmartApp that receives HTTP POST messages
13
+
2. a SmartThings SmartApp that interfaces with the Wifi-connected device in your home
7
14
3. Lua code for the NodeMCU device that connects your wired system to the cloud
8
15
16
+
## Update June 17 2017
17
+
#### Release 1.6: Easy OAuth and Pre-Loaded Kits Available for Pre-order!
18
+
19
+
**Easy OAuth:** Many people who contacted me for help were having trouble with the OAuth flow. In the latest [1.6 release](https://github.com/heythisisnate/nodemcu-smartthings/releases/tag/1.6)
20
+
this is now much simpler! You no longer have to manually do the OAuth step. Just open your browser, copy and paste your OAuth
21
+
Client ID and Secret when prompted, and the application handles the rest.
22
+
23
+
**Pre-loaded Kits for Sale!** I'm working hard to make it as easy as possible for anyone to connect their wired alarm system
24
+
to SmartThings, so I've decided to begin selling all-inclusive DIY kits with this software pre-loaded! With one of my DIY kits,
25
+
there's no flashing or code to modify. Simply wire your sensors and alarm following the online instructions and open up
26
+
your web browser to configure.
27
+
28
+
### [Now Accepting Pre-orders](https://nodemcu-smartthings.com/collections/wired-alarm-system-smartthings-connection-kits-and-accessories) for first shipment in August 2017
#### [Wired Alarm System Add-on DIY Kit](https://nodemcu-smartthings.com/collections/wired-alarm-system-smartthings-connection-kits-and-accessories/products/wired-alarm-system-add-on-kit)
42
+
* For connecting up to 6 sensors (no siren)
43
+
* Software is pre-loaded! Just wire it up and configure with your web browser.
44
+
* Includes NodeMCU board, NodeMCU base and jumper wires
45
+
* Includes email support to help you get up and running
46
+
***Pre-order now** for first shipment in August 2017
47
+
48
+
#### [Donate to this Project!](https://nodemcu-smartthings.com/products/donate-to-this-project)
49
+
* If you've loved this open-source project, donate any amount to support it!
50
+
9
51
### Background
10
52
11
53
The house I live in was built in the early 90s and came with a built-in home security system. I'm not interested in using the outdated alarm system panel, but I wanted to connect the contact sensors in my doors and the motion sensor in my house to SmartThings. I learned about the NodeMCU ESP8266, a small, cheap, programmable development board that has WiFi built in. I set out to connect my door and motion sensors to the NodeMCU and program it to update SmartThings every time a change is detected.
@@ -29,24 +71,37 @@ _Update 2:_ One user reported that he had success with [this board](https://www.
29
71
30
72
## Updates
31
73
32
-
##### v1.5 / 2017-04-07
74
+
### v1.6 / 2017-06-17
75
+
76
+
_Feature:_ Easy OAuth. The application handles the OAuth flow automatically now. Just point your browser
77
+
to `http://<your-device-ip>:8100/oauth`. See the updated README for details.
78
+
79
+
_Feature:_ Authorize multiple alarms with the SmartApp.
80
+
81
+
_Bug Fix:_ Strobe output did not work due to copy/paste bug.
82
+
83
+
_Bug Fix:_ Fix error in SmartApp when you only have motion sensors authorized.
84
+
85
+
**IMPORTANT: Read the [1.6 upgrade notes](https://github.com/heythisisnate/nodemcu-smartthings-sensors/releases/tag/1.6) if you're upgrading from an earlier version.**
86
+
87
+
### v1.5 / 2017-04-07
33
88
_Feature:_ Connect a wired siren and/or strobe. Integrates seamlessly with the Smart Home Monitor app.
34
89
35
-
**IMPORTANT: Read the [upgrade notes](https://github.com/heythisisnate/nodemcu-smartthings-sensors/releases/tag/1.5) if you're upgrading from an earlier version.**
90
+
**IMPORTANT: Read the [1.5 upgrade notes](https://github.com/heythisisnate/nodemcu-smartthings-sensors/releases/tag/1.5) if you're upgrading from an earlier version.**
36
91
37
-
#####v1.3 / 2017-03-29
92
+
### v1.3 / 2017-03-29
38
93
39
94
_Feature:_ Blink the onboard LED on successful communication with SmartThings. To enable set `blink_led = true` in
40
95
`variables.lua`
41
96
42
97
_Feature:_**Reliable polling**. Configure by setting `poll_interval` in `variables.lua` to a number to indicate the number
43
98
of seconds between polling for sensors that may have gotten out of sync.
44
99
45
-
#####v1.2 / 2017-03-06
100
+
### v1.2 / 2017-03-06
46
101
47
102
_Feature:_ Reports the status of each sensor upon startup.
48
103
49
-
#####v1.1 / 2017-02-18
104
+
### v1.1 / 2017-02-18
50
105
51
106
_Feature:_ Support for wired smoke detectors.
52
107
@@ -103,46 +158,7 @@ The SmartApp receives data from your NodeMCU device, and updates the status of y
103
158
1. Make note of the OAuth Client ID and Client Secret, you'll need these later.
104
159
1. Click Publish -> For Me
105
160
106
-
### 5. Generate an OAuth token
107
-
108
-
The OAuth token is used to sign HTTP requests from the NodeMCU to the SmartApp you just created. [SmartThings has documentation of this process here.](http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/authorization.html). We'll be going through the OAuth flow manually to capture the token which can then be saved on the NodeMCU.
109
-
110
-
1. Copy and paste the below web address into your browser and replace `YOUR-SMARTAPP-CLIENT-ID` with the OAuth Client ID from the SmartApp created eariler.
1. Once you click Authorize, you'll be redirect to http://localhost:3000/auth which will error. That's ok! It wasn't supposed to work. All you need is the code out of the URL parameter:
121
-
122
-

123
-
124
-
1. Now that you've got the code, it's time to make a POST request to get the access token. For this I like to use [Advanced REST Client Chrome app](https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-US). You can use any tool that can create a POST request with form parameters. Just fill in [the fields](http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/authorization.html#get-access-token) as shown:
125
-
126
-

127
-
128
-
1. Click Send, and with any luck, you'll get a successful response back that contains your access token:
129
-
130
-

131
-
132
-
Copy this access token into the `credentials.lua` file.
133
-
134
-
1. Finally, get your SmartApp endpoint by doing a GET request to `https://graph.api.smartthings.com/api/smartapps/endpoints`, signing the request with an `Authorization` header and your token:
135
-
136
-

137
-
138
-
1. Click send and make note of the url data returned:
139
-
140
-

141
-
142
-
Copy the `base_url` field from here into the `apiHost` variable in the variables file
143
-
Copy the `url` field into the `apiEndpoint` variable in the variables file
144
-
145
-
### 6. Flash the NodeMCU Lua firmware
161
+
### 5. Flash the NodeMCU Lua firmware
146
162
147
163
#### Drivers
148
164
@@ -182,12 +198,23 @@ good [documentation here](https://nodemcu.readthedocs.io/en/master/en/flash/) in
182
198
183
199

184
200
185
-
1. Once connected, it's time to upload the code. Click Open in Esplorer and open each of the lua files on your computer and click "Save to ESP". Alternatively, you can use the Upload button to upload them all at once. [This documentation](http://esp8266.ru/download/esp8266-doc/Getting%20Started%20with%20the%20ESPlorer%20IDE%20-%20Rui%20Santos.pdf) was also very helpful in learning how to interact with the device using Esplorer.
186
-
1. After all the code is uploaded, click the Reset button to restart the device. It should boot up, connect to your WiFi and output a message for each configured sensor, like this:
201
+
1. Once connected, it's time to upload the code. Click the Upload button in ESplorer and navigate to the `lua` directory. Highlight all the `lua` and `html` files and click Open to upload them to the device:
202
+
203
+

204
+
205
+
1. After all the code is uploaded, toggle the RTS button on then off to restart the device. It should boot up, connect to your WiFi and output a link to begin the OAuth flow.
206
+
1. Copy and paste the OAuth link URL into your web browser and begin the OAuth flow. You'll need the OAuth Client ID and Secret from the SmartApp.
207
+
1. After you enter the Client ID and Secret, you'll see a page like this allowing you to authorize the devices you set up earlier:
1. Authorize all the NodeMCU connected devices. When prompted, reboot the device by toggling the RTS button in ESPlorer on and off.
212
+
213
+
1. Now your device should be working. You will see a debug message on boot for each configured sensor, like this:
187
214
188
215

189
216
190
-
1.Now let's test it out! The first sensor in this example is configured on pin 6 (labled D6). Take a wire and connect one end to pin D6 and the other end to the ground (GND). This completes the circuit, setting the pin low or 0, indicating that the contact sensor is closed. Hopefully it worked and you should see a success message in the Esplorer terminal, and when you open your SmartThings app you should see that the door is closed. Now remove the wire and watch it set to open.
217
+
1.Let's test it out! The first sensor in this example is configured on pin 6 (labled D6). Take a wire and connect one end to pin D6 and the other end to the ground (GND). This completes the circuit, setting the pin low or 0, indicating that the contact sensor is closed. Hopefully it worked and you should see a success message in the Esplorer terminal, and when you open your SmartThings app you should see that the door is closed. Now remove the wire and watch it set to open.
191
218
1._Note about the pins:_ I found that some of the pins don't work very well when normally _low_. It took a lot of trial and error to figure out that pins D1, D2, D6 and D7 worked reliabliy for me. I had problems with D3, D9 and D10. Your mileage may vary.
192
219
193
220
### 7. Connect your switches at the alarm panel
@@ -211,7 +238,6 @@ signal from the ESP8266 board. These instructions are written for the relay link
211
238
1. Make sure the black (-) wire of the siren/strobe is connected to the ground (-) on the alarm panel.
212
239
1. Connect the COM on the relay to the 12V aux power out (+) on the alarm panel with a jumper wire.
213
240
214
-
215
241
## Problems or Questions
216
242
217
243
Please [open an issue](https://github.com/heythisisnate/nodemcu-smartthings-sensors/issues) if you run into problems or have feature requests. You can also [join the discussion on SmartThings community](https://community.smartthings.com/t/connect-wired-alarm-system-sensors-to-smartthings-with-a-nodemcu-esp8266/76010)
0 commit comments