I try to make a simple gate opener but it will not work. It is based (most parts only copy paste) on this note : Cayenne MQTT and Standalone ESP8266 ESP-01 - myDevices.
For the push button I made the same trigger as described in the note, but it doesn’t work. In the data I can see that the switch is toggling.
Also the relay connected with the NODEMCU gives no reaction.
My sketch :
//#define CAYENNE_DEBUG #define CAYENNE_PRINT Serial #include <CayenneMQTTESP8266.h>
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “xxxxxxxx”;
char password = “xxxxxxxxxxx”;
char clientID = “xxxxxxxx”;
Found it. Was a copy past problem.
I can activate the output led now and the led is going of after 1 sec ( delay 1000).
Problem is still the trigger. I need a momentory switch. For that reason I made a trigger :
'If NODEMCU relay ON then NODEMCU relay OFF"
Doesn’t work.
Second problem : I can activate the relay from PC but not from my smartphone. Smartphone is on the same LAN as the PC
CAYENNE_IN(2) {
if (getValue.asInt() == 1) { // NOTE: Channel = Virtual Pin
digitalWrite(relayPin, HIGH);
delay (1000);
digitalWrite(relayPin, LOW);
send = true;
}
else {
digitalWrite(relayPin, LOW);
}
}
CAYENNE_OUT_DEFAULT()
{
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
Cayenne.virtualWrite(0, millis());
if (send)
{
Cayenne.virtualWrite(3, 1, "digital_sensor", "d");
send = false;
}
}
this will create a two-state widget on the dashboard with channel 3. Add a trigger to this widget. if channel 3 widget = 1, then turn OFF relay button.
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “xxxxxxxxx”;
char password = “xxxxxxxxxxxxxxxxx”;
char clientID = “xxxxxxxxxxxxxx”;
CAYENNE_OUT_DEFAULT()
{
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
Cayenne.virtualWrite(0, millis());
Code is working. Each time I push the button, the Nodemcu creates a puls to activate the gate.
I have still one problem. When the app is running and my phone switches over from 4G to wifi and vise versa, the system is not working. Than I have to restart the app.
Because the distance between router and the esp is too long, I installed a wifi extender in between. The extender has the name SSID-ext.
Problem now is Cayenne can not find the esp anymore with the extender in between. Do I have to change the SSID with SSID-ext ?