Failure connecting ESP8266 to cayenne via mqtt

Hey, i didn’t find another topic that solves my problem, so I opened this one. If anyone can refer to a topic that fixes the problem please let me know.

I’m trying to connect a board called NodeMCU Lua Amica Module V2 ESP8266 ESP-12E to the cayenne dashboard. In a later state of my project I want to send some data to the dashboard, but right know I just want to make sure that the connection is working. Therefore I am using the example that comes with Cayenne-MQTT-ESP8266 library.

At the moment it looks like this:

It is exactly the same like in the example, I only updated the WiFi name, password etc…
I am able to compile the code and load it to the ESP8266 board without any errors, but then the Cayenne dashboard doesn’t find the device and I don’t know why…?

Searching for the error I already checked if the board is able to connect to the Wifi. I opened a WiFi Hotspot and saw that board was consistently connected. I also successfully checked if the board can handle any other code. The builtin LED was a sign that it does :smiley: so the error has to be somewhere else.
In terms of troubleshooting I also reflashed the firmware running on the ESP 8266.

There are several other options to connect an ESP board to cayenne via WiFi and I tried a lot but somehow I don’t get it done.

Currently I’m using PlatformIO IDE, but i also uploaded the code using Arduino IDE and it’s the same problem there.

I would be really happy if anybody had another idea how to fix this. :slight_smile:

@joschuagosda welcome to cayenne community. upload this code using arduino ide and fill all the details(ssid, password, MQTT username password and client id). then open your serial monitor and check whether it connect or there is an error.

// 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[] = "ssid";
char wifiPassword[] = "wifiPassword";

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "MQTT_USERNAME";
char password[] = "MQTT_PASSWORD";
char clientID[] = "CLIENT_ID";

unsigned long lastMillis = 0;

void setup() {
	Cayenne.begin(username, password, clientID, ssid, wifiPassword);

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(0, lastMillis);
		//Some examples of other functions you can use to send data.
		//Cayenne.celsiusWrite(1, 22.0);
		//Cayenne.luxWrite(2, 700);
		//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);

Thanks for the advice and the fast answer.
First of all I could fix the problem and I do see a device now in Cayenne :slight_smile:

I figured out that the my main wifi access point is not properly, there after uploading the code I don’t see any reaction, the program can be built and be uploaded but there is no information when I open the serial monitor.

So I tried to connect to a hotspot hosted via my phone and there i got some success. It’s still not working fine but I got the following message in the serial monitor:

Another try showed when I’m connecting the phone to the internet via LTE and not over Wifi it’s working and I see a device in Cayenne :smiley:

The error has be somewhere in the accesspoint settings.

Thank you very much!! :grinning:

1 Like

I saw a very similar post here a little while back and ended up that his router was case sensitive on the access point name where his phone hot spot was not. Worth a check to see. If that’s not it check that you are on WPA2 security and that you have wireless B, G, or N enabled. If you are in AC only mode your ESP will not connect.

1 Like