ESP8266 Offline on Cayenne - OnLine in Serial monitor

i’m using ESP-01 with Arduino IDE
i’m on Cayenne WEB & ANDROID dashboard

Offline is often found on Cayenne but I have not seen a topic on ESP8266 yet.

Problem :
Very often, my project is marked as offline on the cayenne dashboard.
On the serial monitor of my card ESP-01 everything tells me that the connection is OK.
With Arduino Dashboard, I can turn on or off the led but all other data (temperature, states, operating hours) are not updated. I closed/opened Chrome, Cayenne Web , refresh … always Offline.
I’m sur if i reset My ESP-01, it will going Online again , but Why debug serial monitor say "Connection ok"and why after some times it’s marked Offline ?

My guess here is that this could be a server side issue on our end, however if you don’t mind sharing, I’d be interested to see the code to make sure nothing jumps out at me that could be causing connectivity issues.

Hi @rsiegel, sory for late reply, cause holidays :stuck_out_tongue_winking_eye:
this is the last code used :

/* Cayenne chanels :

0: button →
1: read gpio0 ←
2: temps de fonctionnement ←
3: temperature ←
4: luminausite ←
5: proximite ←
// This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
// Make sure you install the ESP8266 Board Package via the Arduino IDE Board Manager and select the correct ESP8266 board before compiling.

#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid = “xxxx”;
char wifiPassword = “xxxx”;
//char ssid = “xxx”;
//char wifiPassword = “xxxx”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “xxxx”;
char password = “xxx”;
char clientID = “xxx”;

// Time
unsigned long lastMillis = 0;

// Led state
#define LED_PIN 2 //LED sur GPIO2
int current ;//connaitre l’etat de la LED et Tx a cayenne

// cayenne Rx
int cmdLed; // le flag recu par cayenne du Button ch0
// This flag is used so the sync only happens on the first connection.
bool isFirstConnect = true;

// temperature
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 0 //lire DS18b20 sur GPIO0 MODIF:ONE_WIRE_BUS D1
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float temp;

//= SETUP =
void setup() {
Serial.println(“\n++ Demarrage de Cayenne ++”);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);

// LED

// temperature

} // FIN de setup

//= LOOP =
void loop() {

//Publish data every 10 seconds (10000 milliseconds). Change this value to publish at a different interval.
if (millis() - lastMillis > 10000) {
lastMillis = millis();

//Write data to Cayenne here. This example just sends the current uptime in milliseconds.

Cayenne.virtualWrite(2, lastMillis / 60000);
Serial.print(“\nTemps de fonctionnement(min):”); Serial.println(lastMillis / 60000);

//Some examples of other functions you can use to send data.
// temperature 18B20
float temperature = getTemperature();
Serial.print("\nTx → "); Serial.println(temperature);
Cayenne.celsiusWrite(3, temperature); // Tx cayenne en Float ok !

Cayenne.luxWrite(4, 700);
Cayenne.virtualWrite(5, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
} //FIN de tempo 10s

} //FIN de loop

//====================== AUTRES FONCTIONS ==================================

CAYENNE_IN(0) // Rx de la part de cayenne sur canal0 ET retour a cayenne ch0 Etat Gpio
cmdLed = getValue.asInt();
digitalWrite(LED_PIN, cmdLed); // Allume ou Eteint la Led GPIO2
Serial.print(“\nGet Commande led :”); Serial.println(cmdLed);
// grab the current state of the LED.
if (digitalRead(LED_PIN) == LOW)
current = 0;
current = 1;

Serial.print(“Tx Etat Led → “);
Cayenne.virtualWrite(1, current, “digital_sensor”, “d”); //Tx a cayenne etat led widget STATE
float getTemperature() {
do {
temp = DS18B20.getTempCByIndex(0);
//delay(100); //MODIF : timer de mesure Temp (100)
} while (temp == 85.0 || temp == (-127.0));
return temp;
// This function will run every time the Cayenne connection is established.
CAYENNE_LOG(“Connection established”);
Serial.println(”++ Connecte a Cayenne ! ++”);
isFirstConnect = false;

I have essentially what sounds like the same problem. I have an Adafruit Feather ESP8266. Over the past few weeks it seems as though its always offline in the dashboard. However, a few scheduled events still run (most of the time, sometimes not).

I have the the same problem but I tried some ways to tackle this. And to a certain extent, it might help.
First, I observed that although my smartphone or notebook shows full signal strength of wifi, putting your ESP device as close as possible to the router helped me somehow.
But most importantly, changing the frequency of sending data to Cayenne also helped to keep device online, So,
if (millis() - lastMillis > 10000) {
try to set this time to 1000 instead of 10000. Or 500. I am just suggesting, not sure if it will help you, but worth trying.

For you, if i was often “Ofline”, it’s because the data are send too slow ?
Every 10 seconds is not fast enough?

Yes, when I tried with 10 seconds it was showing offline. But with 1 second, there was no problem. As I said, just give it a try and see.

@samarchri @Tim_G_Tech @nicathesenov

Hi guys,

As I know you’re aware, we have an issue where devices will mistakenly appear offline. We’ve been aware of the issue for over 2 weeks now. Unfortunately, our team has not had time to look into the issue yet, but it is our highest priority to fix.

Our developers are currently ‘heads down’ working on a project that will enable us to keep giving Cayenne away for free. We are currently in the process adding more people to our growing team to make sure that we have the bandwidth to fix these issues immediately when they come up, instead of taking weeks to resolve.

So, I’m sorry we haven’t been able to fix this yet, but hang in there, and rest assured that in the future this issue and others like it will be resolved in a timely manner.

@nicathesenov thank you for sharing your workaround that may help!


1 Like

@bestes My pleasure :slight_smile: . I understand it is not easy to keep Cayenne up and solve all people’s problems in short time. It will probably take months to develop Cayenne to nearly flawless level. I respect what you do.
It is just hard waiting for bugs to be resolved when the deadline for ESP IoT contest is approaching. Everyone wants to be the best, winner and that’s what drives them(and me) crazy :smiley:
On the other hand, you eliminated the need for tester as this contest encouraged people around the world to submit bugs to community, Hats off :smiley: :smiley:

hi @nicathesenov, @bestes , i test every seconds and … It’s worse !
i publish data every 30sec and it’s realy better : i never be OffLine since i change to 30s.
I’m lucky ? Improvement of the server part of Cayenne ? :crossed_fingers:

Maybe it works differently for everyone :smiley:

My experience of this is that using the Cayenne-basic example code which sends messages to Cayenne containing the number of milliseconds since start up works very well. I’ve had it running for over a month without any issues. However, when I wrote my own code which sends messages at different intervals it was frequently if not always being shown as offline even though the data was usually coming through.

I re-wrote my code around this example:
Cayenne-MQTT-ESP/ESP8266.ino at master · myDevicesIoT/Cayenne-MQTT-ESP · GitHub so that my data is sent once every 10 seconds this seems to work much better. There seems to be some timing issue with the offline/online state reporting. I’m not sure whether longer or shorter intervals work better.

Thank you for letting us know @paul2 ! I did not consider it could be related to timing, and your observations will help our devs when they start to look into issue. Keep you updated on its resolution too.



@samarchri @nicathesenov @paul2 @Tim_G_Tech I try to keep the ‘Bug Broadcast’ topic updated with the bugs that are being worked on and dates for their release…feel free to follow the topic and be alerted when I update it.

1 Like

Thanks Benny!

I actually figured out what my problem was. Everything in my case on Cayenne’s end is fine. I am using an Adafruit Feather HUZZAH Esp8266 with one of their relay feathers attached to the top. I was doing some troubleshooting and while the was nothing connected to the relay it never seemed to loose connection. As soon at I connected a light/120V AC to the relay, the connection dropped. The relay is right over top the antenna on the board. I think there is a magnetic field generated by the 120v through the relay interfering with the 2.4Ghz radio. So it seems like more of a design flaw.

I have two photons and an rpi connected and have had no problems.


1 Like

Interesting discovery @Tim_G_Tech I would assume they probably expect people to use the relays for lower voltage applications.

On Adafruit’s website they mention the capabilities of the relay and switching radios, tv’s, small appliances etc. That might be what the relay is rated for but I wonder if they took into consideration the effects of having the relay right on top of the antenna?

Since re-routing the wiring its been working fine.

1 Like

@samarchri @paul2 @nicathesenov @Tim_G_Tech

Today we pushed a fix for the MQTT device online/offline issues that you each had mentioned here. When you have a moment, we’d love to get your feedback on whether this resolved the issue for you (are MQTT devices you expect to be online correctly showing in Cayenne as online, and are you no longer seeing any situations where the device shows “offline” even though its widgets are still updating with live data)

1 Like

So far so good for me as far as it showing up offline. Seems to be online all the time now. :ok_hand:

Just still have the issue with the schedule not working but I know you guys are working on that separately.

i reset my device this morning (lost data since 7:00 pm in France perhaps when you pushed fixes), and for now , on Web dasboard it’s ok !
on Android Dashboard i got difficult to get online and if it’s working : “server Error” displayed

Data are updated correctly.

It’s not lost, I keep testing :man_mechanic: