ESP8266 how to change SSID, PASS and AUTH token from Access Point

Hello Community.
I would like to make some questions and i hope to get an answer. I need to find a way to check the WiFi status and the connection between my ESP8266 and cayenne Server. Also after 3 failed attemts to connect i would like the ESP8266 to become an Access Point in order the user can connect and add the new SSID, password and cayenne’s authentication.

I’ve reead many posts in Cayenne Community buti found no answers. I have added a bluetooth device in order to store to ESP8266 EEPROM new ssid, password and cayenne’s authentication but i want to remove the extra hardware.
Also I’ve encountered a problem. After reading cayenne’s authentication from the EEPROM my programm stucks in cayenne.begin. If i add the cayenne’s authentication manually as a constant string my programm works like a charm.

Best regards, Kostas.

are you using MQTT or the original cayenne client?

1 Like

I’m using MQTT but i’m thinking to go back to original cayenne client because i still can’t figure out how to use the actuators with MQTT.

You can use these functions to tell whether or not cayenne is connected. These are called when it connects and when it disconnects. You can run your code in there. As far as switching your ESP setup to become a station is quite a bit more tricky & I don’t know of a way to do this.

	prevTime = millis();
	digitalWrite(BUILTIN_LED, 0);

	prevTime = millis();
	digitalWrite(BUILTIN_LED, 1);

What can’t you get about the actuators? Post your code so we can see the problem maybe

1 Like

Here is my code:

//I wrote the defines and the include below without adding (# and <> symbols because
//in the browser was a problem in posting
define CAYENNE_PRINT Serial
include CayenneMQTTESP8266.h

// WiFi network info.
char ssid = “CYTAD253”;
char wifiPassword = “************”;

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

unsigned long lastMillis = 0;
unsigned long lastMillis2 = 0;
byte ledstate=1;

void setup() {
Serial.println(“Device Started!!”);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);

void loop() {
if (millis()-lastMillis2 > 5000){
lastMillis2= millis();
ledstate= ledstate^1;
Cayenne.virtualWrite(V1, ledstate);
//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);
// }

//Default function for processing actuator commands from the Cayenne Dashboard.
//You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %s”,, getValue.getId(), getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”);

I have used a gause it seems to work, but my device most times is offline. When i use a Value actuator my device works and it’s only. But i would like to use the “State” widget but i can’t find which widgets i can use with MQTT and which ones with Cayenne original client. If you could let me know where to look for those answers it would be helpful.

Best Regards, Kostas.

p.s. “I would like to make a Virtual state Led” but i can’t figure how to accomplice it with MQTT yet :confused:

A virtual state led to say if its online or offline or what do you mean?

As far as using a actualor, this is the code you need to get the actuator to control a function. Replace the “1” with whatever virtual channel your using. You don’t need the “V” in there. Then on the dashboard, add a custom widget button and set it to channel 1.

    	actuator = getValue.asInt();

Below is a example of how I can trigger the esp to restart using a button on the dashboard. You press the button calling the function cayenne_in(1), the button lights up indicating its pressed on the dashboard, then the function tests if the button is really pressed or not (ie. 1 for pressed, 0 for not), if it is pressed then it virtualwrites the button you pushed back to “off” or “0” on the dashboard, then a delay to make sure the command goes thru, then the chip restarts.

	restartChip = getValue.asInt();

	if (restartChip == 1)
		Cayenne.virtualWrite(1, 0, "digital_sensor", "d");

it probably doesn’t need the “if” function in there but I like to be sure before it really reboots.


Thank you vapor83,
I’m sorry for confusing you. I got confused myself also and replied for an other post of mine.
As for ESP8266 and multiple SSID, PASS and TOKEN this project solves the problem. I’m going to make some tests tonight.
As for the “Virtual LED” i would like to add a “2 state widget” in the dashboard and sent data (0/1) to it from my ESP. I just want to turn ON/OFF a “Virtual LED” from my ESP8266 when something occurs without a having a physical connected LED in ESP’s io’s.
By the way the information that you’ve provided have cleared some of my questions.
Thank you again, Kostas.


You can add a digital 2 state widget and set the channel to a available one. Then use a virtualwrite to control it. Should work good. Let me know how it goes!

Cayenne.virtualWrite(1, value, "digital_sensor", "d");

1 Like

It is working like a charm !!
Thank you a lot my friend.