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

I am receiving a 500 Internal Server Error when doing the post for oauth for the smart app. I have saved the code and also published it can you provide some insight as to what the issue could be Nat?

The code only works once. If youā€™ve made a mistake, you need to repeat the OAuth step to get a new code, then redo the POST with a new code.

Thanks I got it to work !!! BTW I have ordered the board and canā€™t wait to continue to the next steps. This looks like something I will be able to use. I need to find an alarm to add to the system.

Also question if I add more contact type devices or added handlers what steps need to be done again to support the new devices?

Also on another note when I did the Authorization I got back two set of urls for the came location the base_urls are the same the URLā€™s are not the same and the URiā€™s are not the same

I used the first set of values is this ok or is there a problem?

If you add more devices, first you need to create the devices (like in Step 3 of my README), but you donā€™t need to go through the OAuth flow again. Just open the mobile app, go to Automation > Smart Apps > Cloud Sensor and select the new devices there.

Iā€™m not sure what you mean by two sets of URLs. Can you show me an example or screenshot?

Thanks Nat!

When I did the get authorization I got and array of two items back element 0 and 1

[
{
ā€œoauthClientā€: {
ā€œclientIdā€: ā€œ0cdf1bc0-XXXXXXXXXXXX-380786344cedā€
},
ā€œlocationā€: {
ā€œidā€: ā€œ53a527ae-XXXXXXXXXXXX-ce9a1e4f1b85ā€,
ā€œnameā€: ā€œHomeā€
},
ā€œuriā€: ā€œhttps://graph-XXXXXXXXXX.api.smartthings.com:443/api/smartapps/installations/XXXXXXXXXXXXXXXXX-8660-544e20151cf4ā€,
ā€œbase_urlā€: ā€œhttps://graph-XXXXXXXXX.api.smartthings.com:443ā€,
ā€œurlā€: ā€œ/api/smartapps/installations/XXXXXXXXXXXXXXXX-8660-544e20151cf4ā€
},
{
ā€œoauthClientā€: {
ā€œclientIdā€: ā€œ0cdf1bc0-XXXXXXXXXXXXX-380786344cedā€
},
ā€œlocationā€: {
ā€œidā€: ā€œ53a527ae-XXXXXXXXXXXXX-ce9a1e4f1b85ā€,
ā€œnameā€: ā€œHomeā€
},
ā€œuriā€: ā€œhttps://graph-XXXXXXXXXX.api.smartthings.com:443/api/smartapps/installations/XXXXXXXXXXXXXXXX-9de0ff1f06faā€,
ā€œbase_urlā€: ā€œhttps://graph-XXXXXXXXXXX.api.smartthings.com:443ā€,
ā€œurlā€: ā€œ/api/smartapps/installations/XXXXXXXXXXXXXXXXX-9de0ff1f06faā€
}
],

Hi all, great write up! Im running into an issue it seems a few folks have managed to work around. My alarm panel is located in a hallway closet and there is no outlet located nearby. Iā€™m guessing Iā€™ll need to somehow connect my nodeMCU to the battery backupā€¦How has everyone accomplished this?

Or is there a way to power it from the alarm board?

@smiller29 I havenā€™t seen this before, but I assume you should be able to use either URL.

@Chris13 Yes, usually you can draw power from the alarm panel. This is easier with the ā€œLoLin version board + baseā€ because it accepts 12V DC power directly. Which type of NodeMCU do you have?

I have the NodeMCU HiLetgo Lua with wifi.
I can return it and get another one if thats easier.

Do you happen to have a link to the LoLin version and board?

@Chris13 You should be able to power the HiLetgo version with the alarm panel, too. You just need to make sure that the voltage is right. Most alarm panels output 12V DC, do you have a multimeter that you can use to check? Then, check the back of your NodeMCU board for the VIN rating. I have a couple and one says 5V - 12V, but another one says 10V max. I think it should be fine if itā€™s a few volts over. All you need to do is connect the 12V aux out (+) from your alarm panel to the VIN pin, and the (-) to the GND next to VIN.

The reason I say that the LoLin version is a little easier, is because the base has a built-in voltage regulator that accepts up to 24V. The product links are on my github page.

Hi NATE, well the board came today in the mail so I loaded the firmware and loaded the lua files but I am having an issue. looks like line 55 is getting into an error condition

java.lang.NullPointerException: Cannot execute null+null @ line 55

ESPlorer shows the following

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-03-23 20:41
powered by Lua 5.1.4 on SDK 1.5.4.1(39cb9a32)
Connecting to WiFi access pointā€¦

Waiting for IP addressā€¦
Waiting for IP addressā€¦
Waiting for IP addressā€¦
WiFi connection established, IP address: 10.0.1.27
You have 3 seconds to abort
Waitingā€¦
Running applicationā€¦
Listening for Front Entry Door on pin D1
Error 500 posting {ā€œsensor_idā€:ā€œd1987954-1ccc-4ab1-baaf-b1f99a48474eā€,ā€œstateā€:0}, retrying
Error 500 posting {ā€œsensor_idā€:ā€œd1987954-1ccc-4ab1-baaf-b1f99a48474eā€,ā€œstateā€:0}, retrying
Error 500 posting {ā€œsensor_idā€:ā€œd1987954-1ccc-4ab1-baaf-b1f99a48474eā€,ā€œstateā€:0}, retrying
Error 500 posting {ā€œsensor_idā€:ā€œd1987954-1ccc-4ab1-baaf-b1f99a48474eā€,ā€œstateā€:0}, retrying
Error 500 posting {ā€œsensor_idā€:ā€œd1987954-1ccc-4ab1-baaf-b1f99a48474eā€,ā€œstateā€:0}, retrying
Error 500 posting {ā€œsensor_idā€:ā€œd1987954-1ccc-4ab1-baaf-b1f99a48474eā€,ā€œstateā€:0}, retrying
Error 500 posting {ā€œsensor_idā€:ā€œd1987954-1ccc-4ab1-baaf-b1f99a48474eā€,ā€œstateā€:0}, retrying

PORT CLOSED

this is with no wires connected.

it also returns this from time to time

Polling Front Entry Door: 0

Built in regulator does sound better. Looks like 5v to 10v on my board. Iā€™ll continue with the setup!

Nate I found the issue you know I told you I got two endpoint values when I was having the issue I was using the first value in the array I changed it to the second value and everything is working great!!!

This is really a nice project and I want to thank you for sharing all your work with everyone.

Have you done any of the other projects listed here on this site? do you know a way to add a delay to the alarm being triggered if using your alarm relay?

Had an issue twice for the first time today after over a month where the door closed but SmartThings failed to register. Any suggestion to resolve this? Thanks

Any wiring diagrams for motion sensors? Iā€™ve got 4 wires going to the sensor. I canā€™t seem to get the nodemcu to sense motion

The red and black wires are for the power. Connect those to a 12v power supply or your alarm panel power output. The other two wires (yellow/green probably) connect to the NodeMCU.

So far so good. Iā€™m at step 6 ā€œFlash the NodeMCU Lua firmwareā€ but am unable to get the usb serial device driver working. The device doesnā€™t show up. Iā€™ve followed the instructions closely at http://kig.re/2014/12/31/how-to-use-arduino-nano-mini-pro-with-CH340G-on-mac-osx-yosemite.html but Iā€™m coming up short with ā€˜ls /dev/tty.wchusbserial*ā€™. Iā€™ve also gone through steps / instructions at https://github.com/adrianmihalko/ch340g-ch34g-ch34x-mac-os-x-driver/blob/master/ReadMe.pdf.

I am running Sierra 10.12.4. Iā€™ve tried this on two Macs going through the installation and reboot process multiple times now without any luck and am looking for ideas. Any ideas how to get past this point?

@mrosett It may be a bad USB cable. Do you have any other USB cables you can try? Some of them are only capable of power but not data. Try one that came with a mobile phone or digital camera so you know it is capable of carrying data.

Also, on my system the serial port shows up as /dev/cu.wchusbserial1440 so check for that too.

1 Like