ESP8266 NodeMCU WiFi IoT Garage Door Opener Relay with Cayenne

At the moment I have a solid state relay that doesn’t seem t work. It can only be wired one way.

I can flip it but let me ask. When you plug it up should it start beeping and then “Closing Garage!”

This is what it looks like when I hit the reset button.

rl$ܞ|⸮$⸮|⸮l⸮b|⸮⸮⸮e⸮{⸮⸮⸮b⸮⸮oN⸮dno⸮⸮⸮bp⸮⸮c$rlp⸮n⸮⸮l⸮⸮bn⸮|l⸮⸮p⸮⸮on⸮$⸮⸮l ⸮eon$or⸮ےnB⸮lr⸮⸮n#⸮$⸮{⸮⸮⸮p⸮$⸮$`⸮⸮N⸮[257] Connecting to IOT-24
[1259] Connected to WiFi
[1260] My IP: 10.80.0.143
Setup Gstate:0
[5001] Connecting to arduino.mydevices.com:8442
[10127] Connecting to arduino.mydevices.com:8442
[15262] Connecting to arduino.mydevices.com:8442
[15432] Ready (ping: 40ms).
Closing Garage!

It runs closing garage right out of the gate.

// assuming you wire your relay as normally open
if (currentValue == 0) {
digitalWrite(13, HIGH);

the “currentValue == 0” was missing the zero.

Seems to be working better now.

However I keep losing connection to it. “can not connect to remote device”. It seems like if I push the button a few times it fast it can can crashes the NodeMCU (say you want stop the garage half way). I’ll drop pings to it.

64 bytes from 10.80.0.143: icmp_seq=2253 ttl=128 time=3.399 ms
64 bytes from 10.80.0.143: icmp_seq=2254 ttl=128 time=55.547 ms
64 bytes from 10.80.0.143: icmp_seq=2255 ttl=128 time=3.321 ms
64 bytes from 10.80.0.143: icmp_seq=2256 ttl=128 time=4.433 ms
64 bytes from 10.80.0.143: icmp_seq=2257 ttl=128 time=4.132 ms
64 bytes from 10.80.0.143: icmp_seq=2258 ttl=128 time=4.169 ms
64 bytes from 10.80.0.143: icmp_seq=2259 ttl=128 time=2.809 ms
64 bytes from 10.80.0.143: icmp_seq=2260 ttl=128 time=5.173 ms
64 bytes from 10.80.0.143: icmp_seq=2261 ttl=128 time=5.586 ms
64 bytes from 10.80.0.143: icmp_seq=2262 ttl=128 time=4.781 ms
64 bytes from 10.80.0.143: icmp_seq=2263 ttl=128 time=5.329 ms
64 bytes from 10.80.0.143: icmp_seq=2264 ttl=128 time=5.262 ms
64 bytes from 10.80.0.143: icmp_seq=2265 ttl=128 time=5.957 ms
64 bytes from 10.80.0.143: icmp_seq=2266 ttl=128 time=4.602 ms
64 bytes from 10.80.0.143: icmp_seq=2267 ttl=128 time=4.770 ms
64 bytes from 10.80.0.143: icmp_seq=2268 ttl=128 time=4.077 ms
64 bytes from 10.80.0.143: icmp_seq=2269 ttl=128 time=11.236 ms
64 bytes from 10.80.0.143: icmp_seq=2270 ttl=128 time=5.490 ms
64 bytes from 10.80.0.143: icmp_seq=2271 ttl=128 time=111.644 ms
64 bytes from 10.80.0.143: icmp_seq=2272 ttl=128 time=7.908 ms
64 bytes from 10.80.0.143: icmp_seq=2273 ttl=128 time=5.324 ms
64 bytes from 10.80.0.143: icmp_seq=2274 ttl=128 time=4.548 ms
64 bytes from 10.80.0.143: icmp_seq=2275 ttl=128 time=4.567 ms
64 bytes from 10.80.0.143: icmp_seq=2276 ttl=128 time=5.147 ms
64 bytes from 10.80.0.143: icmp_seq=2277 ttl=128 time=5.687 ms
64 bytes from 10.80.0.143: icmp_seq=2278 ttl=128 time=3.697 ms
Request timeout for icmp_seq 2279
Request timeout for icmp_seq 2280
Request timeout for icmp_seq 2281
Request timeout for icmp_seq 2282
Request timeout for icmp_seq 2283
64 bytes from 10.80.0.143: icmp_seq=2284 ttl=128 time=4.665 ms
64 bytes from 10.80.0.143: icmp_seq=2285 ttl=128 time=40.323 ms
64 bytes from 10.80.0.143: icmp_seq=2286 ttl=128 time=60.140 ms
64 bytes from 10.80.0.143: icmp_seq=2287 ttl=128 time=78.830 ms
64 bytes from 10.80.0.143: icmp_seq=2288 ttl=128 time=5.536 ms
64 bytes from 10.80.0.143: icmp_seq=2289 ttl=128 time=5.254 ms
64 bytes from 10.80.0.143: icmp_seq=2290 ttl=128 time=8.315 ms
64 bytes from 10.80.0.143: icmp_seq=2291 ttl=128 time=6.947 ms
64 bytes from 10.80.0.143: icmp_seq=2292 ttl=128 time=5.245 ms
64 bytes from 10.80.0.143: icmp_seq=2293 ttl=128 time=6.152 ms

Then the pings to the NodeMCU come back but it is hit or miss if will start working again.

It has been 15 minutes and it hasn’t come back. Of course while I am filming I have to hit the button a million times. I have seen it when after a couple presses it stops responding. It must be timing, like I push the button when it is doing something else and jacks it up.

It’s possible 5V coming off the ESP8266 to power the relay might be too much of a drain and causing the ESP8266 to reboot or the USB Power Supply itself doesn’t have enough amps.

There is some talk about how to wire the relay with a 5V Power supply with a resistor and transistor here: http://www.instructables.com/id/ESP8266-WiFi-relay-switch/ or maybe someone with more electrical knowledge than me can chime in on a better way to wire this.

Yea, I have a problem, I got this error “‘Cayenne’ was not declared in this scope” Could you please help me? Here the code:

define CAYENNE_PRINT Serial // Comment this out to disable prints and save space

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = “token”;
// Your network name and password.
char ssid = “ssid”;
char password = “password”;

void setup()
{
Serial.begin(9600);
Cayenne.begin(token, ssid, password);
}

void loop()
{
Cayenne.run();
}

Do you have #include <CayenneEthernet.h> or whatever your connection method is in there somewhere?

@adam, when I include <CayenneEthernet.h> , and try to verify, I got a error too,
CayenneEthernet.h: No such file or directory, the same if I include <CayenneWifiClient.h>
I don’t know what can I do to fix it,
Thank you.

Have you installed the Cayenne library in your Arduino IDE? Click Sketch>Include Library>Manage Libraries… then search for Cayenne.

Hi,

I want to control a relay (ON OFF) with NODEMCU ESP8266 and Cayenne.

Can anyone help me ?