esp8266 : it constantly lose connection
How to fix it?
help me
code:
#define CAYENNE_DEBUG // Uncomment to show debug messages
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "";
// Your network name and password.
char ssid[] = "";
char password[] = "";
void setup()
{
pinMode(0, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(2, OUTPUT);
Serial.begin(115200);
Cayenne.begin(token, ssid, password);
}
void loop()
{
Cayenne.run();
}
// This function will be called every time a Dashboard widget writes a value to Virtual Pin 2.
CAYENNE_IN(V0)
{
CAYENNE_LOG("Got a value: %s", getValue.asStr());
int i1 = getValue.asInt();
int i11 = map(i1,0,102300,0,1023);
Serial.print("PWM:");
Serial.println(i11);
analogWrite(0,i11);
}
CAYENNE_OUT(V1)
{
Cayenne.virtualWrite(V1,GiaTriDoAm);
}
CAYENNE_IN(V2)
{
CAYENNE_LOG("Got a value: %s", getValue.asStr());
int i = getValue.asInt();
if (i == 0)
{
digitalWrite(4, LOW);
}
else
{
digitalWrite(4, HIGH);
}
}
CAYENNE_IN(V3)
{
CAYENNE_LOG("Got a value: %s", getValue.asStr());
int i = getValue.asInt();
if (i == 0)
{
digitalWrite(5, LOW);
}
else
{
digitalWrite(5, HIGH);
}
}
CAYENNE_IN(V4)
{
CAYENNE_LOG("Got a value: %s", getValue.asStr());
int i = getValue.asInt();
if (i == 0)
{
digitalWrite(2, LOW);
}
else
{
digitalWrite(2, HIGH);
}
}
I am having similar problem using the ESP8266 boards, I think the BlynkSimple library has a bug that causes the WDT timer to reset
other iot platforms that do not use the Blynk library work OK
I hope it gets fixed when Cayenne supports the ESP8266 officially.
The Esp8266 is working for me-
I’m using an Esp12-e, and the Arduino IDE.
I put the ESP into “program” mode by
shorting GPIO 0 to ground for 20 seconds while booting.
Then you can upload your arduino code-
This code works for me-
the rest of the programming is done
from the App or the Cayenne HTML page.
//#define CAYENNE_DEBUG // Uncomment to show debug messages
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "YourToken";
// Your network name and password.
char ssid[] = "YourSSID";
char password[] = "YourPassword";
void setup()
{
Serial.begin(9600);
Cayenne.begin(token, ssid, password);
}
void loop()
{
Cayenne.run();
}
I don’t see any resets in his screen shot there. I think this may be another issue such as 2.4GHz interference (or too far from access point) or low quality WAN causing disconnects.