ESP32 won't connect to cayenne

Hi,
I downloaded the cayenne esp32 library off github and my esp32 is running other code fine. I ran the sample wifi code to ensure it was connecting to the internet, all fine.
I selected the sparkfun esp8266 thing on the my devices part, then in the code I changed the username password and client ID to match the cayenne website, and typed in my wifi details, when I uploaded the code there are no errors looks like it is working, but then on the cayenne webite it is waiting for board to connect. The board never connects, so I don’t know what to do next. Please help ASAP.

add #define CAYENNE_DEBUG in your code and check serial monitor for any error.

I done this, there is nothing printing to my serial monitor and it is at the correct baud-rate.

can you share the link of the device you are using.

https://learn.sparkfun.com/tutorials/esp32-thing-hookup-guide/introduction

Thank you for your help!

have you installed the ESP32 Board Package arduino-esp32/README.md at master ¡ espressif/arduino-esp32 ¡ GitHub ??

Yes there are all installed, board is working fine apart from not being able to connect to cayenne.

#include <WiFi.h>
 
const char* ssid = "yourNetworkName";
const char* password =  "yourNetworkPass";
 
void setup() {
 
  Serial.begin(115200);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi..");
  }
 
  Serial.println("Connected to the WiFi network");
 
}
 
void loop() {
 
}

this is the code i used to connect my wifi connection. Everything was ok. Then below is the code i used to send to cayenne. Please anyone help!

// This example shows how to connect to Cayenne using an ESP32 and send/receive sample data.
// Make sure you install the ESP32 Board Package and select the correct ESP32 board before compiling.
// To install the ESP32 Board Package follow the instructions here: https://github.com/espressif/arduino-esp32/blob/master/README.md#installation-instructions.

#define CAYENNE_DEBUG 
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP32.h>

// WiFi network info.
char ssid[] = "";
char wifiPassword[] = "";

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

unsigned long lastMillis = 0;

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

void loop() {
	Cayenne.loop();

}

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
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());
	// 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_IN_DEFAULT()
{
	CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
	//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}

/*
This example shows how to connect to Cayenne using an ESP32 and send/receive sample data.

The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.

Steps:

  1. If you have not already installed the ESP32 Board Package install it using the instructions here: arduino-esp32/README.md at master ¡ espressif/arduino-esp32 ¡ GitHub.
  2. Select your ESP32 board from the Tools menu.
  3. Set the Cayenne authentication info to match the authentication info from the Dashboard.
  4. Set the network name and password.
  5. Compile and upload the sketch.
  6. A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.
    */

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP32.h>

// WiFi network info.
char ssid = “vodafone-3C65”;
char wifiPassword = “xxxxxxx”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “6xxxxxx”;
char password = “4cxxxxxxx”;
char clientID = “2xxxxxxx”;

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

void loop() {
Cayenne.loop();
}

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
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());
// 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_IN_DEFAULT()
{
CAYENNE_LOG(“Channel %u, value %s”, request.channel, getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”);
getValue.setError(“Error message”); // uncomment this line
}

I have added getValue.setError(“Error message”); and got the error [532] WiFi not present.
Ran it a few times and the error message is intermittent?

any ideas??

hey got it working,

for anyone with the same issue this is the code i got to work.

/*
This example shows how to connect to Cayenne using an ESP32 and send/receive sample data.

The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.

Steps:
1. If you have not already installed the ESP32 Board Package install it using the instructions here: https://github.com/espressif/arduino-esp32/blob/master/README.md#installation-instructions.
2. Select your ESP32 board from the Tools menu.
3. Set the Cayenne authentication info to match the authentication info from the Dashboard.
4. Set the network name and password.
5. Compile and upload the sketch.
6. A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.
*/

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#define EspSerial Serial
#include <CayenneMQTTESP32.h>
#include <WiFi.h>

// WiFi network info.
const char* ssid = "xxxxxxxxxxxxxxx";
const char* password =  "xxxxxxxxxxxxxxx";

char ssidc[] = "vxxxxxxxxxxxxxxx";
char passwordc[] =  "xxxxxxxxxxxxxxx";

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


void setup() {
	Serial.begin(115200);
 WiFi.begin(ssid, password);
 while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi..");
  }
 
  Serial.println("Connected to the WiFi network");
	Cayenne.begin(username, wifipassword, clientID, ssidc, passwordc);

}

void loop() {
	Cayenne.loop();
}

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
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());
	// 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_IN_DEFAULT()
{
	CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
	//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
getValue.setError("Error message");
//getValue.setError();
}
2 Likes

Thank you!!!

I thought I was going crazy. Your solution helped get the Adafruit HUZZAH32 Feather to run the sample!

Hopefully Cayenne update the library or sample code so it works first time out the box.

1 Like

I am using the same code but can’t upload the code to esp32. Compiling is ok but uploading fails showing some errors. I have use Blynk with esp32 and its work fantastic but Cayenne IOT platform doesn’t. I am trying to connect with Cyenne my devices but fails again again. I have done so many install, unnstall library, arduino IDE, esp32 board addition etc but fail to work with Cayenne IOT mydevices.com.

follow the instruction from here Cayenne-MQTT-Arduino/ESP32.ino at master ¡ myDevicesIoT/Cayenne-MQTT-Arduino ¡ GitHub and if you can share what error you are facing we can help you out.

Thanks shramik.

[526] WiFi not present error in cayenne MQTT esp32 board (After uploading)

Collegiate, exist status 1 error during uploading. (During uploading);

can you share the code you are using.

Sorry for late reply. It is now working. There was wifi credentials problem for cayenne.begin(). SSID/cSSID; password/cpassword.

1 Like

Hi I have an error to connect with cayenne
I use esp32 and I installed the library when I upload the code there is error :
'esp_wp2_config_t ’ was not declared in this scope
Plz any help !!

can you share the entire error from the serial monitor and also the code you are using.