Connect wired alarm system sensors to SmartThings with a NodeMCU ESP8266 [deprecated]

@CoffeyInOrlando I don’t think the @ or ! characters would be the problem. The error message indicates its on line 1. It looks like possibly your editor converted the double quotes surrounding the strings into “smart quotes” aka curly quotes. While these look cute for humans, they’re not so good for computer programs.

Try disabling smart quotes in your editor, or use a more coding-friendly editor like Sublime text.

1 Like

hey whats up Nate,

hope all is well, just want to pick your brain again. is it possible to
utilize the smoke detectors and siren that is integrated in my security
panel (see attached screenshot of wiring diagram). Would be cool if i can
add the smoke alarms and siren. Was thinking the smoke alarm would act
similar to contact and siren would need like an on and off function to
trip.

thanks again for all your help.

@Raymond_Lopez I added support for a wired smoke detector as you asked! Could you test it for me since I don’t have any such smoke detectors at my house?

The updated code is here: https://github.com/heythisisnate/nodemcu-smartthings-sensors/tree/smoke-detector-device-type

You’ll need to add the new DeviceHander to SmartThings and also update the SmartApp code. Then, create the Smoke Detector device and choose the Device Type “NodeMCU Connected Smoke Detector”. After you’ve updated the SmartApp code and re-published, go into your SmartThings app, go to Automation -> SmartApps -> Cloud Sensor and you should be able to select the Smoke Detector(s) that you just added as devices to monitor.

The Lua code on the NodeMCU does not need to change. Just add the new Smoke Detector device to the list in the variables.lua file, and it should just work.

Please let me know if this works out. If so, I’ll merge it into master and update the documentation.

Nate,

I will definitely test the smoke alarm once I get passed the contact and motion sensors. While I was trying to hook up the nodemcu to the alarm panel I noticed all my ground on the alarm panel have 2k ohm resistors but the zone wires do not.

I ran a cable to the d2 pin on the nodemcu to zone 1 on the alarm panel. This is the front door wired sensor, I then ran a cable from the ground on the panel to the ground on the nodemcu. I do not see anything working. Am I missing something here?

You can remove the resistors. They’re not needed.
You want to disconnect the wires from the alarm panel and just connect each pair of wires from each sensor directly to the digital pin & ground on the NodeMcu. We’re bypassing the alarm panel completely.

thanks Nate that worked. its functioning perfectly now. is there anyway to
leverage both the nodemcu and the alarm panel? I would like the alarm panel
still be aware of sensors open and close. anyway doing that?

It may be possible, but probably not easily. The reason why this works and is so simple is because the sensor circuits make a single closed loop. If you’re trying to connect it to two different loops, that makes it significantly more complicated and I’m not even sure how you would do so. Unfortunately it’s out of scope of this project.

In my opinion, those alarm panel systems are last century’s technology and there’s not much value in keeping it functioning. Personally, I eventually plan on ripping out the alarm panel from the wall in my house and replacing it with a tablet touchscreen with SmartThings running on it.

Got it, no worries. This is still far better .
Nate you the man!

I’ll test the smoke alarm by this weekend

Does anyone know if it’s possible to still use the wired alarm and the sensors also connected to both the alarm and the board?

For example let’s just say I alligator clamp onto the wires either before or after the resistor while they are still connected to the alarm panel. Will this cause any issues with sensors registering with either the board or alarm panel?

The alarm is primary, I will not deactivate it. But I have every door and window wired to it, and it’d be nice to monitor those sensors without using something like alarmserver and an EVL4.

@cozdabuch Unfortunately that will not work. This is the same thing that Raymond asked above. The sensors work by making a simple closed circuit and when connected to your alarm panel or the NodeMCU ESP8266 board, it closes the loop. If you alligator clamp more wires to connect the NodeMCU board while it’s still connected to the alarm panel, then you’ll have both the alarm panel and the NodeMCU sending current over that loop, and the sensors will not work. You may also risk shorting out your alarm panel or the NodeMCU.

The goal of this project was to be able to connect wired contact and motion sensors to SmartThings instead of your alarm panel. If you want to keep your alarm panel functional, then unfortunately this project is not for you.

FYI - You may be able to get this work as a parallel system, as other have been able to do so previously. Please note that this was using an Arduino at 5V. The ESP8266 is only 3.3V. You may need a level shifter to protect the inputs on the ESP8266.

See the discussion regarding this exact same topic in my original ST_Anything Arduino/ThingShield discussion below:

Oh cool, thanks for this @ogiewon. I think this is where my lack of electrical knowledge is limiting me. So @cozdabuch @Raymond_Lopez … it sounds like it may be possible to connect the NodeMCU and alarm panel in parallel. Let us know if you get it to work!

@ogiewon do you know which level shifter to use for the ESP8266 ?

Most of my work has been with 5volt Arduinos. I too am just getting started with the ESP8266s.

Here is a level shifter which seems to fit the requirements.

Or, you could simply use two resistors of specific values to create a voltage divider. Just use reasonably high resistor values.

https://learn.sparkfun.com/tutorials/voltage-dividers/all?print=1

Also, you will probably need to stop using the Internal Pull-up resistor for inputs wired in parallel with the existing alarm system, as the voltage will be either high or low depending on the state of the magnetic reed switch.

You have a very nice integration with an existing security system but I was wonder if you have any ideas
that I could still use my existing alarm system and only need SmartThings to inform me that the alarm has
been triggered when I’m away.

I was thinking if somehow using the +12V output switch that goes to the siren as a trigger or
the outputs for piezo dynamic sirens but I wouldn’t know how I can achieve that electrically…

Any information is appreciated… thank you…

Hi Nate. Firstly, thanks for the great work!

I’ve been trying to get your solution up and running. I’m almost there, but am stuck on the following:

When I activate a pin on the 8266 chip, I get the error message “Error 500 posting … , retrying” via the console on the 8266 chip.

Looking at the debug information on smartthings I get “error java.lang.NullPointerException: Cannot execute null+null @ line 50”.

I see some others had this problem and did the Reauth, but I’ve already tried that a few times and also read more on the link you refer to with Smartthings, but to no avail.

Any ideas where I can find my problem. Is it definitely Auth?

I’m in the Netherlands and working off the UK hub. Not sure if this could be a problem, but thought it was worth mentioning.

Thanks!

Alan, it sounds like you haven’t selected any devices for the SmartApp to monitor. If you’ve already done the OAuth flow, you don’t need to do it again. Just opened the SmartThings mobile app, go to Automation > Smart Apps > Cloud Sensor. Then select at least one device to monitor from the devices that you set up earlier with my Device Handlers from this project.

Thanks Nate! It was not entirely the problem, but you set me off in the right direction. I actually had both Device Handlers setup in ST, but only one of types had associated devices. I added a fake device to so that I had a contact sensor, and voila! Thanks! It’s working now… now for some further testing…

@heythisisnate Just wondering if you have had anytime to look at the issues with the newer flash? I’m trying to incorporate an OLED. But the flash doesn’t have the correct modules. Only flash files I can find or create are newer flash files which I haven’t been able to get working. Wondering if you have an older flash with the correct modules or an idea of why HTTP keeps timing out with 2.0. I’m just learning Lua myself, haven’t been able to pinpoint the issue.

There is a bug in the new NodeMcu firmware. See this related issue: https://github.com/nodemcu/nodemcu-firmware/issues/1707

I did spend some time trying to debug it but it does seem to be a bug in the firmware C code, which is a bit beyond my expertise. I have not done any firmware development before so I haven’t been able to pinpoint the problem. You can build your own firmware build with the packages you need against the older firmware version pretty easily using the NodeMCU Docker build project. There’s a discussion of this in the linked issue.