[OBSOLETE] Convert Your Wired Alarm System into a SmartThings Smart Home Monitor System for Under $25 with NodeMCU ESP8266 (2017)

Hi @KER,

All you need to do is create and upload a separate variables.lua for each of your three boards. Each NodeMCU board should have a unique set of SmartThings deviceIds that it’s monitoring, so just don’t repeat them. All the rest of the code should just be duplicated on each NodeMCU and it should just work.

In my experience, if you stick with pins D1, D2, D5, D6, D7 and D8 you should not have any problems.

1 Like

Thanks Nate. When you instructed me to upload separate variables.lua for each board, you’re referring to the process involving the Esplorer IDE—right?. Just out of curiosity, why do these NodceMCU boards come with defective digital pins?

Yes, correct. You use Esplorer to upload the lua files to the NodeMcu device. You just need to change the device IDs in your variables file when you copy the files to each board. And only ONE of your NodeMCU boards will be connected to the siren relay, so only need to configure the alarm variable on one. Everything else can be the same.

The pins are not defective, but some are wired together with other functions. For example D4 also controls the onboard LED. Others are used for some purposes at boot and it causes problems when always connected.

Is there an issue with saving Variables.lua, Variables2.lua, & Variables3.lua? I’d like to store 3 unique files in case I ever have to upload these file again in the future with Esplorer.

If you change the name of the file, you’ll also have to change the line in application.lua that references that file. I suggest storing copies separately, but just rename to variables.lua before you upload it to the device.

I’ve managed to get my test concept working now. Fantastic bit of kit this is.

I have an interesting setup that I wonder if you can comment on Nate. The External and Internal sirens appear to be connected together, which I think is a good thing.

Here is the wiring diagram

I’m hoping to keep my alarm PCB in place for power purposes only. Could I use TRG- to trigger the siren leaving the power alone? saving the need for a relay etc?

Does that wiring diagram make more sense to you than it does me?

Here is a picture of it actually in place…

TIA

I think you’re right, based on that diagram. You may be able to leave connect the TRG wire directly to the alarm output pin on the NodeMCU. It looks like your siren power is already isolated from the trigger signal. Try it and let me know.

1 Like

So after getting the below device, it looks like this requires 120VAC to function at all. So other then using resistors I do not think there are any other options. The 12VDC smoke detectors I have are only 2 wire, they were connected to the alarm panel with only 2 leads, one going to a positive power source and the negative to one of the zones. But what I noticed is there were 2 additional brown/blue leads that were connected together with a resistor in the alarm box, but these leads were not connected to the panel itself. I am hoping someone might have a better idea of how this is setup to trigger the alarm. Thanks again for all the help.

https://www.amazon.com/Electric-USI-960-Relay-Module-Alarms/dp/B002EVORYS/ref=as_li_ss_tl?ie=UTF8&qid=1492035596&sr=8-2&keywords=smoke+relay+module&linkCode=sl1&tag=heythisisnate-20&linkId=fed044cbed20df6723949832101c716c

Edit:

I found this below, I think it might work.

https://www.amazon.com/System-Sensor-EOLR-1-line-Encapsulated/dp/B001ULM8FS/ref=sr_1_fkmr0_1?ie=UTF8&qid=1493138048&sr=8-1-fkmr0&keywords=EOLR-1+Power+Supply+Supervision+Relay

https://www.systemsensor.com/en-us/Documents/EOLR-1_Manual_I56-2185.pdf

Hey @raidflex. Sorry! I didnt’ realize that that first one required 120VAC_. That’s surprising. Yes, it does sound like the second link you posted should work. Let us know how it works out.

Should my list of sensors numbers contained within my 3 Variables.lua files be consecutive across all 3 files (i.e. 1 - 19)?

When creating devices, should they be set to Published, or Self-published?

Should my list of sensors numbers contained within my 3 Variables.lua files be consecutive across all 3 files (i.e. 1 - 19)?

I think you’re referring to the index number in the sensors[1] = { } table. If so, then no, they need not all be consecutive. It actually doesn’t really matter, as these are just indexes on the internal variable, but for simplicity I would number them 1 - 6 or whatever.

When creating devices, should they be set to Published, or Self-published?

Self-published

Thanks Nate. I just finished creating all 20 of my devices and inserted the device ID’s into my 3 .lua files. I noticed the sensor-based IDs needed to be inserted between quotation marks, but the alarm’s default was nil. Should the alarm device ID also be qouted?

Yes. All string literals must be quoted.

I hate to keep bugging you with questions, but unfortunately my multiple NodeMCU project is a bit of a different environment than your tutorial. For instance, do I use the same OAuth token for each of my 3 NodeMCUs, or do I generate a unique 1 for each? You mentioned, _We’ll be going through the OAuth flow manually to capture the token which can then be saved on the NodeMCU._Which leads me to believe I may have to generate 3 tokens.

You can absolutely use the same token for each device. You only need one SmartApp, just be sure to authorize all your sensors to that SmartApp. Your credentials.lua file should be exactly the same on all three NodeMCU boards, and your apiHost and apiEndpoint will also be exactly the same on all the boards. The only differences need to be the sensors & siren configuration variables.

I’m more than happy to answer your questions, but maybe if you have more questions specific to your setup you could send me a private message instead of tacking on to this thread.

Connected TRG- to D1 of the board.

Code looks like this…

alarm = {
  deviceId = "3a3f37f2-***************",
  httpPort = 8100,
  sirenPin = 1,
  strobePin = nil
}

ESPlorer shows this…

Success: {"device_id":"3a*******","port":8100,"mac":"18:fe:*****","ip":"192.168.1.107"}
Success: {"sensor_id.............etc

When I check the Live Logging of the IDE I get this…

3a3f37f2*****  17:48:07: debug POST /3a3f37f2-2*****/off HTTP/1.1 
Accept: */* 
User-Agent: Linux UPnP/1.0 SmartThings 
HOST: null:null 

3a*****  17:48:04: debug POST /3******9d/both HTTP/1.1 
Accept: */* 
User-Agent: Linux UPnP/1.0 SmartThings 
HOST: null:null 

In terms of the actual alarm, it doesnt go off. :frowning:

Do I need a GND wire of some sort?
I think this is more a wiring issue than a software one? any clues?

Thanks in advance.

@Vyker It looks suspicious to me that the HOST: null:null is there in the request. This should be an ip-address and port instead of null. This leads be to think that maybe your host/port is not getting set correctly. Could you send me a screenshot of the device info page for your alarm? The URL would be something like:

https://graph-na02-useast1.api.smartthings.com/device/show/3a3f37f2-2**** (replace the last part with your full DeviceID)

In the Data section of that screen you should see the internal ip address, port, and MAC address. Is it there? You can send the screenshot in a private message if you want.

Hey , Nate Thanks for this a wonderful project, but I have stucked and bugging me with the “HTTP client: connection timeout” error every time update the status plus the NodeMCU rebooting quit often.
My NodeMCU detail is branch: 1.5.4.1-final, SSL: true
I connected my sensor to the GPIO pin 1,2,3, 6 and 7
I did re flashed the firmware without any different.
I hope you can shed a light for this. Thanks

You’re right there is no data in the Data section.

Clearly I’ve done something wrong?

Sorry if this is taking too much of your time, I appreciate your help.