ESP32 - Cayenne was not found- WiFi library issued

Dear All,

I am trying to connect an ESP32 board to Cayene throuhy CAYENNE_OUT function using wifi as the connection below (code below).

I constant get the “‘Cayenne’ was not declared in this scope” message and I am using a TTGO LoRa ESP32 board set as ESP32 dev board in the boards manager.

I have noticed that by trying different board types as well as Cayene MQTT libraries, I get different error messages that mainly point to WiFi library problems.

Has anyone come across the same issues?

Thank you

#include <LoRa.lyh>
//#include "SSD1306.h"

#include <Arduino.h>
//#include <CayenneArduinoDefines.h>
//#include <CayenneMQTTWiFi.h>
//#include <CayenneMQTTESP32.h>

#include <SPI.h>
//#include <WiFi.h>

//Libraries for OLED Display
#include <Wire.h>
#include <Adafruit_GFX.h>
//#include <Adafruit_SSD1306.h>

#define CAYENNE_PRINT Serial


char ssid[] = "";
char wifiPassword[]="s";

char username[] = "";
char mqtt_password[] = "";
char clientID[] = "";
//SSD1306  display(0x3c, 4, 15);
//OLED pins to ESP32 GPIOs via this connection:
// WIFI_LoRa_32 ports
// GPIO5  -- SX1278's SCK
// GPIO19 -- SX1278's MISO
// GPIO27 -- SX1278's MOSI
// GPIO18 -- SX1278's CS
// GPIO14 -- SX1278's RESET
// GPIO26 -- SX1278's IRQ(Interrupt Request)
#define SS      18
#define RST     14
#define DI0     26
#define BAND    868E6

//float data;

String data = "";
int rssi = LoRa.packetRssi();

#define BUTTON_PIN_BITMASK 0x200000000 // 2^33 in hex

RTC_DATA_ATTR int bootCount = 0;

Method to print the reason by which ESP32
has been awaken from sleep
void print_wakeup_reason(){
  esp_sleep_wakeup_cause_t wakeup_reason;

  wakeup_reason = esp_sleep_get_wakeup_cause();

    case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
    case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
    case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
    case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
    case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
    default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
void setup() {

  Cayenne.begin(username, mqtt_password, clientID, ssid, wifiPassword);

  digitalWrite(16, LOW);    // set GPIO16 low to reset OLED
  digitalWrite(16, HIGH);
//  display.init();
//  display.flipScreenVertically();
//  display.setFont(ArialMT_Plain_10);
//  display.setTextAlignment(TEXT_ALIGN_LEFT);
  while (!Serial); //if just the the basic function, must connect to a computer
  Serial.println("LoRa Receiver"); 
//  display.drawString(5,5,"LoRa Receiver"); 
//  display.display();
//  SPI.begin(5,19,27,18);
  if (!LoRa.begin(BAND)) {
   // display.drawString(5,25,"Starting LoRa failed!");
    while (1);
  Serial.println("LoRa Initial OK!");
//  display.drawString(5,25,"LoRa Initializing OK!");
//  display.display();

delay(1000); //Take some time to open up the Serial Monitor

  //Increment boot number and print it every reboot
  Serial.println("Boot number: " + String(bootCount));

  //Print the wakeup reason for ESP32
  esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,1); //1 = High, 0 = Low


  //Go to sleep now
  //Serial.println("Going to sleep now");
  //Serial.println("This will never be printed");

void loop() {

//  Cayenne.loop();

  // try to parse packet
  int packetSize = LoRa.parsePacket();

  String data = "";

  if (packetSize) {
    // received a packets
    Serial.println("Received packet. ");
    //display.drawString(20, 5, "Received packet value:  ");
    Serial.println("Received packet value:  ");
//    display.display();

    // read packet
    while (LoRa.available()) {   
      data = LoRa.readString();     
      //String data = String(;

  //  display.drawString(20,22, data);
  //  display.display();
    // print RSSI of packet
    Serial.print(" with RSSI ");
        //display.drawString(20, 45, "RSSI:  ");
               String rssi = String(LoRa.packetRssi());
        //display.drawString(70, 45, String (LoRa.packetRssi());
               //display.drawString(70, 45, String(rssi));


 //Go to sleep now
  Serial.println("Going to sleep now");
  Serial.println("This will never be printed");


// This function is called at intervals to send data to Cayenne.
  //CAYENNE_LOG("Send data for Virtual Channel %d", VIRTUAL_CHANNEL);
  // This command writes the device's uptime in seconds to the Virtual Channel.
 //Cayenne.virtualWrite(VIRTUAL_CHANNEL, data);

can you try this code and see if it works Cayenne-MQTT-Arduino/ESP32.ino at master · myDevicesIoT/Cayenne-MQTT-Arduino · GitHub


I did copy the code in the code I pasted above with no luck I am afraid. Which board type should I set

can you share a link to which board are you using.

it should work, can you share the error you are you getting for the basic sketch i shared above.

LORA_RECEIVER:223:12: error: expected constructor, destructor, or type conversion before ‘(’ token



exit status 1
‘Cayenne’ was not declared in this scope

can you try the basic code from the link i shared above. that should solve the issue. The code you are using is missing } somewhere.


Didi try it and got the following message

Multiple libraries were found for “WiFi.h”
Used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.33.0_x86__mdqgnx93n4wtt\libraries\WiFi
Not used: C:\Users\xcxxx\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\2WiFi
exit status 1
Error compiling for board ESP32 Dev Module.

you have not selected the correct board,

I have tried sevearl but I end up with the same problems in conjunction with the cayenne.loop() function.

If I do not use the cayenne code the board compiles with no issues at all.

check whether this works for you:

#include <WiFi.h>

const char* ssid     = "your-ssid";
const char* password = "your-password";

void setup()

    // We start by connecting to a WiFi network

    Serial.print("Connecting to ");

    WiFi.begin(ssid, password);

    while (WiFi.status() != WL_CONNECTED) {

    Serial.println("WiFi connected");
    Serial.println("IP address: ");

Did try it with minor changes and gor similar error messages:

ore\core.a(main.cpp.o): In function `loopTask(void*)':

C:\Users\Spiros\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\cores\esp32/main.cpp:17: undefined reference to `loop()’

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for “WiFi.h”
Used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.33.0_x86__mdqgnx93n4wtt\libraries\WiFi
Not used: C:\Users\xxxx\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\2WiFi
exit status 1
Error compiling for board ESP32 Dev Module.

can you remove all files related to “wifi.h” from your arduino library folder. Once done go to arduino ide —> preferences and add in Additional board manager url. Next go to tools —> boards → boards manger and let it add the new esp32 package. Try now and it should hopefully work.

Thank you for the ESP32 info.

We got closer to a solution but there is still a conflict with WiFi library. The message received is:

Multiple libraries were found for “WiFi.h”
Used: C:\Users\xxxx\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.33.0_x86__mdqgnx93n4wtt\libraries\WiFi
exit status 1
Error compiling for board ESP32 Dev Module.

can you join me on slack

Just did,

Sent a pm as well :slight_smile:

Iot Rookie is the name