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

Okay, my bad. I hadn’t actually plugged in the device. Now I see ‘/dev/cu.wchusbserial1420’

From the instructions (not yours), it sounded like I would see /dev/tty.wchusbserial* without that. Also, your instructions in step 7.2 say, “Plug a microUSB cable into the NodeMCU and the other end into your computer”. Step 6 says nothing about plugging in the device but I assume in order to run the esptool command I will need it plugged in right? When I run the esptool command I get the follow error.

mrosett$ ./esptool.py --port=/dev/cu.SLAB_USBtoUART write_flash --flash_mode dio 0x00000 …/firmware/nodemcu-1.5.4.1-final-10-modules-2017-03-23-20-42-52-integer.bin
Traceback (most recent call last):
File “./esptool.py”, line 25, in
import serial
ImportError: No module named serial

@mrosett you need to use the port that your device actually shows up as. As mentioned in the readme, the port may vary depending on driver version and OS. In your case the esptool flashing command is (note I changed the port to the value you mentioned):

./esptool.py --port=/dev/cu.wchusbserial1420 write_flash --flash_mode dio 0x00000 firmware/nodemcu-1.5.4.1-final-10-modules-2017-03-23-20-42-52-integer.bin

Yes, of course it has to be plugged in. :wink:

I finally got it working! I had to do some python path hacking to get the flashing to work. From there it was smooth sailing.

Have you heard anyone using this combined with Scott alarm monitoring through smart things? My wife still wants police capabilities. The price is less than half of our current plan at$20/no or $215/year.

I haven’t used the Scout monitoring service, but it should work just fine. You may want to run your system for a couple weeks first just to test for reliability, but I don’t expect you’ll have any problems.

The only false alarms I’ve ever had were due to the mobile app presence sensing not detecting that I’m home before I opened the door. This has nothing to do with the NodeMCU project … and actually it proves that it works well because the alarm sounded as soon as I opened the door.

Do you connect both the yellow and green wires to the NodeMCU? (If so, how?) If not, do you connect one wire to the board, and the other to ground or something? I have one motion detector working, and the other doesn’t seem to register…I’ve tried various combinations without luck on the non-working.

Yes, one wire goes to the digital pin that you have configured for that device (D1 for example) and the other goes to GND. It doesn’t matter which one goes to which.

Hey nate,

Have you thought about allowing a particular input on the nodemcu to be set as a delay zone - which would not trigger its output until after a delay of X seconds - allowing people that buffer time to enter the front door and unset without triggering the alarm immediately.

I wonder also if a keypad could be wired up to a nodemcu for code disarming? Thinking about when the phone battery is flat, or for guests or cleaners.

Hi @Meirion_Williams,

Thanks for the suggestion. I don’t think that a delay is appropriate at this level. This NodeMCU project is just a very simple interface from your sensors and alarm to SmartThings. A delay for entry/exit really should be a feature of the SmartApp that triggers the alarm. This is where all the logic is.

An entry/exit delay definitely appears to be a commonly asked for feature of Smart Home Monitor. See here: Smart home monitor exit/enter delay

Also if you search these forums for “Smart Home Monitor delay” you’ll find a number of workarounds that people have been using. My position is that this project should remain just a simple device interface.

1 Like

Hi Nate, first thanks so much for all the hard work and making this project happen. Today I installed per your great instructions and everything worked perfectly except the alarm.

I can’t get the Alarm to make an I/O pin go high. I’ve tried D0 and D8. Can you explain the process that happens when ST triggers the Alarm that results in the Alarm pin going hi. I’ve tried turning on the Alarm in the ST app on the iphone but same result. There are no events listed for the Alarm device.

Also, an unrelated quick question: During the Init.lua there’s a 3 second delay to quit the app. What do I have to do to get it to quit?

Thanks so much.

Hi @mthomson51,

Sorry for the delay, I’ve been traveling.
When ST triggers the alarm, your hub will initiate a HTTP POST request to the NodeMCU device on your local LAN. If you have ESPlorer connected and open, you should see a line that indicates this in the console output. You can trigger this manually using the ST app as you’ve discovered (it works exactly the same).

If it’s not working for you, a couple things to check:

  1. Your ST Hub and NodeMCU must be on the same local LAN.
  2. In the My Devices section in the ST web IDE, click on your alarm device and verify that the Device Network Id is set to something like C0A856B6:1FA4 and in the Data section port, mac and ip are set. These should all be set automatically when you reboot the NodeMCU.
  3. In the variables.lua, ensure that deviceId, httpPort and sirenPin are all set.

Good question. Right now there’s not really an easy way to quit aside from deleting application.lua. I’m going to work on this.

I hope this helps. If you still have trouble making the alarm work, PM me with some details of your variables and logs and I’ll do my best to help.

1 Like

Thanks, here’s the device setup and it appears it hasn’t been updated with the type of data you expect.

I noticed you had some errors in your code in alarm.lua, alarmAction function. You have used “sirenPin” multiple times when you were intending to use “strobe.pin”. Easy to fix.

I have the StrobePin set to nil… don’t think that should cause my issue?

Other useful info…

One more screen shot…

Hi Nate, had to edit this posting… new users only allowed three posts!

I did use port 443 because that seems to be what I got back from the setup as I went through the instructions. Should I use something else?

Malcom, did you set the httpPort to 443? This may be the problem. The NodeMCU http server does not support SSL. I’ve been using port 8100 but any non-reserved port should work.

If I want to run multiple NodeMCU’s to support more sensors, do I need to go through the oauth process for each device? Or can they all share the same url and endpoint?

They can all share the same endpoint and credentials.

1 Like

Cant get access token - request always returns 500 Internal Server Error.

I am having trouble getting the device to connect to smart things. When it loads in ESPlorer, it reports a 403 error posting.

NodeMCU custom build by frightanic.com
branch: 1.5.4.1-final
commit: 1885a30bd99aec338479aaed77c992dfd97fa8e2
SSL: true
modules: cjson,file,gpio,http,net,node,tmr,uart,wifi,tls
build built on: 2017-06-13 14:07
powered by Lua 5.1.4 on SDK 1.5.4.1(39cb9a32)
Connecting to WiFi access point…

Waiting for IP address…
Uploading to ESP file variables.lua…Success

WiFi connection established, IP address: 192.168.1.224
You have 3 seconds to abort
Waiting…
Running application…
Listening for Front Door on pin D6
Listening for Back Door on pin D7
Listening for Motion Sensor on pin D2
Error 403 posting {“sensor_id”:“xxxxxxxx-xxxx-xxxx-xxxx-ba453a59dd0b”,“state”:1}, retrying
Error 403 posting {“sensor_id”:“xxxxxxxx-xxxx-xxxx-xxxx-ba453a59dd0b”,“state”:1}, retrying
Error 403 posting {“sensor_id”:“xxxxxxxx-xxxx-xxxx-xxxx-ba453a59dd0b”,“state”:1}, retrying
Error 403 posting {“sensor_id”:“xxxxxxxx-xxxx-xxxx-xxxx-ba453a59dd0b”,“state”:1}, retrying

Which device is it? Alarm? Smoke detectors?

I had trouble with the smoke detector being recognized, and I had to go through device creation and attaching to the smartapp a few times before it took. Even then - I’m not entirely sure this setup will allow connection to wired smoke alarms. I’ve seen no reports of users who have gotten it working (eg the device responds to smoke).

It is just the contact sensor. I am now just trying to wire three of them and I set the poll interval to 5 seconds so I can see that they are wired to the nodemcu correctly. Th tissue arises I guess when it tries to send the status to smart things. The window in ESPlorer shows that all three sensors are closed by smart things shows them all as open.

I started from scratch and reset my smart things hub, made a new account, reinstalled the smart app and the device handlers, made the new devices, etc. Still the same error.

I also re flashed the nodemcu with a blank .bin file and then reinstalled the correct one.

WiFi connection established, IP address: 192.168.1.224
You have 3 seconds to abort
Waiting…
Running application…
Listening for Front Door on pin D6
Listening for Kitchen Windows on pin D7
Listening for Foyer and Bathroom Windows on pin D2
Error 403 posting {“sensor_id”:“xxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxx”,“state”:0}, retrying
Error 403 posting {“sensor_id”:“xxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxx”,“state”:0}, retrying
Error 403 posting {“sensor_id”:“xxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxx”,“state”:0}, retrying
Error 403 posting {“sensor_id”:“xxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxx”,“state”:0}, retrying
Polling Front Door: 0
Polling Kitchen Windows: 0
Polling Foyer and Bathroom Windows: 0