Cayenne.begin locking the startup

Gentlemen,
I’m very new to the world of IoT and programming, I’m starting to use this amazing platform, but I’m having difficulties with my project.
I’m setting up a web server on a D1 wemos and I’m wanting to put the wifi network settings (this already works) and the cayenne settings (Username, Password and ClientId) on a page, the problem is that every time I put in my code Cayenne.begin the ESP simply lock in the initialization. I’m just passing these three parameters, I know the CayenneMQTTESP8266.h library controls the Wifi but that’s making out the part in my Sketch. I have already tried using another library like CayenneMQTTEthernet.h and it also happens the same. I saw some users reporting this same problem here in the forum like this ESP8266 cayenne.begin() don't give the control back - #5 by dforco, but I could not understand the solution (I apologize for my lack of knowledge). Note: In this project I read sensors and ESP can not be stopped even without being connected to the router so I am doing my own Wifi manager (I stopped using tzapu WiFiManager because of this). can anybody help me?

Can you post the code you are using?

Thanks for the response.
The code is too big, I’ll post a part of it. Note that the libraries I used from Cayenne are commented out.

//code
#include <FS.h>
#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <SimpleTimer.h>
#include <DNSServer.h>
#include <ArduinoOTA.h>
#include <ArduinoJson.h>
#include <WiFiUdp.h>
#include <TimeLib.h>




//#include <CayenneMQTTEthernet.h>
//#include <CayenneArduinoMQTTClient.h>
//#include <CayenneUtils/CayenneDefines.h>
//#include <CayenneMQTTClient.h>
//#include <CayenneMQTTESP8266.h> //Inicialização das Bibliotecas Cayenne


ESP8266WebServer webserver(80);

//--------------------------------------------------------------------------------Configuração dos Pinos--------------------------------------------------------------------------------//
#define CONFIG_WIFI 0 //Botão para configuração dos parâmetos Wi-fi
#define STS_LED 2 //Led de Status de modo em AP




//--------------------------------------------------------------------------------Variaveis do NTP e UDP--------------------------------------------------------------------------------//


IPAddress timeServerIP; //variavel para armazenar o IP do Servidor de NTP
bool atualiza_ntp = false; //Atualiza o servidor NTP quando atualizar as configurações do webserver
WiFiUDP EthernetUdp;  //Cria um objeto "UDP".
const int timeZone = -3;     // TimeZona para Brasil
unsigned int localPort = 8888;  // Porta UDP para conexão
int lastday = -1; //Vairavel auxiliar para sincronizar tempo todo dia
long aux_ntp = millis(); //variavel auxiliar de autalização NTP
//Variaveis do Relógio
int hora, minuto, segundo, dia, mes, ano;



//-------------------------------------------------------------------------------Variaveis do Servidor Web------------------------------------------------------------------------------//

bool autenticado = false; //retorna se já foi autenticado o usuario e senha do webserver
bool lock = false; //Controla o bloqueio de acesso web do ESP
String anchars = "abcdefghijklmnopqrstuvwxyz0123456789", username = "admin", loginPassword = "admin"; //Anchars, usuario e senha de acesso web
unsigned long logincld = millis(), reqmillis = millis(), tempign = millis(); //Os doi primeiros temporizadores são para bloqueio e o ultimo para inatividade
uint8_t i, trycount = 0; //i é o indice, trycount é o contador de erro de tentativa ao acesso ao web server
String sessioncookie; //Buffer do Cokie
String msg; //este é o nosso buffer que vamos adicionar à página de login html quando os cabeçalhos estão errados ou o dispositivo está bloqueado

//---------------------------------------------------------------------------------Variaveis do Sistema---------------------------------------------------------------------------------//

SimpleTimer simpletimer;//Define objeto do SimpleTimer

const char* versao_firmware = "1.0"; //Indica a versão de Firmware do Sistema (variavel importante para ter o controle de atualização do programa)

int ADDR_EEPROM = 128; //Armazena o modo de operação do ESP, Se = 1 Modo Station e diferente disso modo SoftAP
int statusModeAP = 0;

//Variaveis Provisória do Cayenne
char username2[45] = "";
char password2[45] = "";
char clientID2[45] = "";

long aux_mode_AP_STA = millis(), tempo_mode_AP_STA = 180000; //Variavel auxiliar para temporizar o modo AP_STA e tempo máximo para sair deste modo


//Configuração do botão
int tempo_botao = 5000; //Tempo que o botão deve permanecer pressionado para entrar no modo de configuação Wifi
long aux_botao_timer; //Variavel auxiliar do botão
bool aux_botao = false; //Variavel de controle do botão
long tempo_default = 20000; //Tempo para entrar em modo default
long tempo_pressionado = 0; //Tempo em que o botão ficou pressionado
long tempo_botao_reset = 0; //Reseta os cantadores de tempo do botão

//Configuração do Led de Status em erro de conexão (modo STA)
int tempo_led_on = 70;
int tempo_led_off = 10000;
long aux_led_on = 0;
long aux_led_off = 0;
//Configuração do Led de Status em modo AP
int tempo_led_AP = 1000;
long aux_led_AP = 0;




//-------------------------------------------------------------------------------Inclusão da Paginas HTML------------------------------------------------------------------------------//

#include "Dados.h"
#include "Page_Login.h"
#include "Page_Aplicacao.h"
#include "Page_Rede.h"
#include "Page_Mqtt.h"
#include "Page_Sistema.h"
#include "Page_Script.js.h"


/*****************************************************************************************************************************************************************************************/
//--------------------------------------------------------------------------Configuação do MODO AP----------------------------------------------------------------------------------------
/*****************************************************************************************************************************************************************************************/

void modeAP()
{
  Serial.println();
  Serial.println("Iniciando em modo AP ... ");
  IPAddress ip(192, 168, 0, 1);
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(ip, ip, IPAddress(255, 255, 255, 0));
  WiFi.softAP(nome);
  boolean result = WiFi.softAP(nome);
  if (result == true)
  {
    Serial.println("Lendo");
  }
  else
  {
    Serial.println("Falha!");
  }
}

/*****************************************************************************************************************************************************************************************/
//--------------------------------------------------------------------------Configuação do MODO STA---------------------------------------------------------------------------------------
/*****************************************************************************************************************************************************************************************/

void modeSTA()
{
  Serial.println();
  Serial.print("iniciando o modo STA ... ");

  //Configuração de IP Fixo caso o DHCP esteje Desabilitado
  if (!dhcp)
  {
    WiFi.config(IPAddress(ip0, ip1, ip2, ip3),  IPAddress(gtw0, gtw1, gtw2, gtw3), IPAddress(sub0, sub1, sub2, sub3));
  }

  //Caso a senha do wifi seja null significa que é uma rede aberta
  if (password != "")
  {
    WiFi.begin(ssid, password);
  }
  else
  {
    WiFi.begin(ssid);
  }


  WiFi.mode(WIFI_STA);
}

/*****************************************************************************************************************************************************************************************/
//-------------------------------------------------------------------------Configuação do MODO AP_STA-------------------------------------------------------------------------------------
/*****************************************************************************************************************************************************************************************/

void modeAP_STA()
{
  Serial.println();
  Serial.print("iniciando o modo AP e STA ... ");

  IPAddress ip(192, 168, 0, 1);
  WiFi.softAPConfig(ip, ip, IPAddress(255, 255, 255, 0));
  WiFi.softAP(nome);
  //Configuração de IP Fixo caso o DHCP esteje Desabilitado
  if (!dhcp)
  {
    WiFi.config(IPAddress(ip0, ip1, ip2, ip3),  IPAddress(gtw0, gtw1, gtw2, gtw3), IPAddress(sub0, sub1, sub2, sub3));
  }

  //Caso a senha do wifi seja null significa que é uma rede aberta
  if (password != "")
  {
    WiFi.begin(ssid, password);
  }
  else
  {
    WiFi.begin(ssid);
  }


  WiFi.mode(WIFI_AP_STA);
}




/*****************************************************************************************************************************************************************************************/
//-----------------------------------------------------------------------------Loop Configuação-------------------------------------------------------------------------------------------
/*****************************************************************************************************************************************************************************************/
void setup()
{
  Serial.begin(115200); //Inicia a comunicação Serial

  pinMode(CONFIG_WIFI, INPUT);
  pinMode(STS_LED, OUTPUT);

  //Carrega_dados();
  if (!SPIFFS.begin()) {
    Serial.println("Falha ao montar arquivo de sistema");
    return;
  }

  if (SPIFFS.exists("/data.json")) {
    Serial.println("Ok Arquivo ja existe!");
  }
  else
  {
    Serial.println("Arquivo de configuracao nao encontrado!");
  }

  if (!loadConfig()) {
    Serial.println("Falha ao carregar arquivo de configuracao");
  } else {
    Serial.println("Configuracoes carregada");
  }


  EEPROM.begin(4096); //Inicia toda a EEPROM.
  EEPROM.get(ADDR_EEPROM, statusModeAP); //Retorna em que modo o ESP está

  if (statusModeAP != 0 && statusModeAP != 1 && statusModeAP != 2) //Garante que o valor esteja entre 0, 1 e 2, pois em memória "virgem" pode vim valor diferente destes
  {
    statusModeAP = 0; //Seta modo Ap na condição acima
    EEPROM.put(ADDR_EEPROM, statusModeAP);
  }

  Serial.print("Modo de operacao: ");
  Serial.println(statusModeAP);
  EEPROM.commit();
  EEPROM.end();

  simpletimer.setInterval(2000L, menssagens);
  EthernetUdp.begin(localPort); //Inicializa a UDP
  setSyncProvider(getNtpTime); //Chama a Sincronização do Relógio


  //Ler da EEPROM o Modo compara para iniciar no modo AP ou STA
  if (statusModeAP == 0 )
  {
    modeAP();
  }
  else if (statusModeAP == 1)
  {
    modeSTA();
  }
  else
  {
    modeAP_STA();
  }

  gencookie(); //Gerar um novo Cokie no start do Esp

  ArduinoOTA.begin();

  webserver.on("/", handleRoot); //Carrega a pagina de aplicação
  webserver.on("/login", handleLogin);
  webserver.on("/refresh", refresh);
  webserver.on("/logoff", logoff);
  webserver.on("/aplicacao", Aplicacao);
  webserver.on("/rede", Rede);
  webserver.on("/mqtt", Mqtt);
  webserver.on("/sistema", Sistema);
  webserver.on("/save_rede", Save_Rede);
  webserver.on("/save_mqtt", Save_Mqtt);
  webserver.on("/save_ntp", Save_Ntp);
  webserver.on("/save_sistema", Save_Sistema);
  webserver.on("/modo_operacao", Modo_Operacao);
  webserver.on("/restaura_sistema", Restaura_Sistema);
  // webserver.on("/erase", Erase);
  webserver.on( "/rede/connectionstate", send_connection_state_values_html );
  webserver.on( "/rede/values", send_network_configuration_values_html );
  webserver.on( "/mqtt/values", send_mqtt_values_html );
  webserver.on( "/sistema/values", send_sistema_values_html );
  webserver.on( "/sistema/value/ntp", send_ntp_values_html );
  webserver.on ( "/microajax.js", []() {
    Serial.println("microajax.js");
    webserver.send ( 200, "text/plain", PAGE_microajax_js );
  } );

  const char * headerkeys[] = {"User-Agent", "Cookie"} ;
  size_t headerkeyssize = sizeof(headerkeys) / sizeof(char*);
  webserver.collectHeaders(headerkeys, headerkeyssize ); //Essas 3 linhas informam esp para coletar User-Agent e Cookie no cabeçalho http quando o pedido é feito

  webserver.begin();
  //Cayenne.begin(mqtt_username, mqtt_password, mqtt_clientID); //Inicializa o serviço Cayenne
  //Cayenne.begin(username2, password2, clientID2);

  /*
    webserver.on ( "/Login", []() { Serial.println("Universal Sensor - Login.html"); webserver.send ( 200, "text/html", PAGE_AdminLogin );   }  );
    webserver.on ( "/Principal", []() { Serial.println("Universal Sensor - Principal.html"); webserver.send ( 200, "text/html", PAGE_Principal );   }  );
    webserver.onNotFound ( []() { Serial.println("Page Not Found"); webserver.send ( 400, "text/html", "Page not Found" );   }  );
    webserver.begin();
  */



}

/*****************************************************************************************************************************************************************************************/
//----------------------------------------------------------------------Pisca Led erro de conexão em STA----------------------------------------------------------------------------------
/*****************************************************************************************************************************************************************************************/
void PiscaLedSTA()
{

  if (digitalRead(STS_LED) == LOW) //Se led estiver ligado
  {
    if (millis() - aux_led_on >= tempo_led_on)
    {
      digitalWrite(STS_LED, HIGH);
    }
  }
  else
  {
    aux_led_on = millis();
  }

  if (digitalRead(STS_LED) == HIGH) //Se led estiver desligado
  {
    if (millis() - aux_led_off >= tempo_led_off)
    {
      digitalWrite(STS_LED, LOW);
    }
  }
  else
  {
    aux_led_off = millis();
  }

}

/*****************************************************************************************************************************************************************************************/
//--------------------------------------------------------------------------Pisca Led em Modo AP------------------------------------------------------------------------------------------
/*****************************************************************************************************************************************************************************************/
void PiscaLedAP()
{

  if (millis() - aux_led_AP >= tempo_led_AP)
  {
    digitalWrite(STS_LED, !digitalRead(STS_LED));
    aux_led_AP = millis();
  }

}


/*****************************************************************************************************************************************************************************************/
//----------------------------------------------------------------------Loop principal do programa----------------------------------------------------------------------------------------
/*****************************************************************************************************************************************************************************************/
void loop()
{

  LerBotao(); //Leitura do botão de configuração de Wifi
  InfoConexao(); //Depuração da conexão
  simpletimer.run();

  //Configuração do comportamento do LED
  if (statusModeAP == 0 && tempo_pressionado <= tempo_default) //Pisca em Modo AP
  {
    PiscaLedAP();
  }
  else if (statusModeAP == 1 || statusModeAP == 2 && tempo_pressionado <= tempo_default) //Pisca em Modo STA caso não tenha conectado com o roteador
  {
    if (WiFi.status() != WL_CONNECTED)
    {
      PiscaLedSTA();
    }
    else
    {
      digitalWrite(STS_LED, HIGH); //Desliga o LED (Lógica Inversa)
    }
  }
  else
  {
    digitalWrite(STS_LED, LOW); //Led Aceso para indicar restauração de fábrica
  }

  if (statusModeAP == 2)
  {
    if (millis() - aux_mode_AP_STA >= tempo_mode_AP_STA && WiFi.softAPgetStationNum() == 0)
    {
      statusModeAP = 1;
      EEPROM.begin(4096); //Inicia toda a EEPROM.
      EEPROM.put(ADDR_EEPROM, statusModeAP); //Retorna em que modo o ESP está
      EEPROM.commit();
      EEPROM.end();
      WiFi.mode(WIFI_STA);
      delay(1000);
      ESP.restart();
    }
  }

  if (ntp_update  > 0 )
  {
    if (millis() - aux_ntp >= ntp_update * 60000)
    {
      // Serial.print("Tempo de atualização ntp: ");
      // Serial.println(millis() - aux_ntp);
      setSyncProvider(getNtpTime);
      aux_ntp = millis();
    }
  }

  if ( atualiza_ntp == true) //Verifica se a data hora está desatualizada e então o atualiza ou quando atualizar as configurações no webserver
  {
    setSyncProvider(getNtpTime); //Chama a Sincronização do Relógio
    send_ntp_values_html();
    //lastday = day();
    atualiza_ntp = false;
  }

  //Carrega as variaves do Relógio
  hora = hour();
  minuto = minute();
  segundo = second();
  dia = day();
  mes = month();
  ano = year();

  //Termina a configuração
  webserver.handleClient();
  ArduinoOTA.handle();
  control_access(); //Contola o acesso ao web Server (erro se multiplas tentativas de login, etc...)
  //Cayenne.loop();


}

Continues…

Is your code working now? There were actually some MQTT server problems at the time which would have caused some issues for you.