ESP8266, Connects with my Network, but appears OFF-Line to the cloud

I am having trouble getting the ESP8266 to go on line with the cloud.
Gone through the new device and new Thing, plus added in a couple of cloud variables.
all the rest of the code has been generated by the create tool.

After the download I can see the ESP8266 module appear on my local network, however it does. not connect to the cloud.

See the serial monitor text, below


�$l�V�$H��4h$�***** Arduino IoT Cloud - configuration info *****
Device ID: aee23758-5047-4a71-a99c-eae68afb6211
MQTT Broker: iot.arduino.cc:8884
WiFi.status(): 3
Connected to "MY NETWORK"
TimeServiceClass::sync Drift: -1723457061 RTC value: 1723457066
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to iot.arduino.cc:8884 Error: 5
TimeServiceClass::sync Drift: -1 RTC value: 1723457071
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to iot.arduino.cc:8884 Error: 5
TimeServiceClass::sync Drift: 0 RTC value: 1723457078


I have repeated the creation process a number of times, all with the same result.
I have another ESP32 set up for the IoT and connects with the same network and is reliably on line with no problems.
A little research produced a suggestion that there could be some port blocking, however the Router appears to be free of any Port blocking and specifically none on port 8884

Does anybody have any ideas?

Main program code
______________________

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/48963417-fc87-4404-acbb-5e65d9ab961a 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thingk

  float suino_3266_Humidity;
  float suino_3266_Pressure;
  float suino_3288_Temperature;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(4);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
}
  ____________________________
  ThingProperties.h
// Code generated by Arduino IoT Cloud, DO NOT EDIT.

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

const char DEVICE_LOGIN_NAME[]  = "aee23758-5047-4a71-a99c-eae68afb6211";

const char SSID[]               = SECRET_SSID;    // Network SSID (name)
const char PASS[]               = SECRET_OPTIONAL_PASS;    // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[]  = SECRET_DEVICE_KEY;    // Secret device password


float suino_3266_Humidity;
float suino_3266_Pressure;
float suino_3288_Temperature;

void initProperties(){

  ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
  ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
  ArduinoCloud.addProperty(suino_3266_Humidity, READ, 10 * SECONDS, NULL);
  ArduinoCloud.addProperty(suino_3266_Pressure, READ, 10 * SECONDS, NULL);
  ArduinoCloud.addProperty(suino_3288_Temperature, READ, 10 * SECONDS, NULL);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);



type or paste code here


Not 100% sure, but the cloud code appears to have been modified. Put that sketch away and start from scratch with the same device. If it connects, then the added code is suspect, if it doesn't, then the board is suspect.

Thankyou for your reply, sonofcy.
I tried your suggestion of creating a new un modified configuration and downloaded it, with the same result.
I forgot to add into the Original post that I have successfully programmed the ESP8266 using the Arduino IDE with serial connection multiple times both before and after attempting these things, so I am pretty sure the actual board is ok.

Sometimes it can take a long time for the board to connect.
I don't know if you have multiple boards, but if you do and the device_key and login_name don't match then that will cause a problem.
I see a wifi error of 3 but then it says connected but then MQTT fails on Error 5.
I just googled your issue and found another forum entry identical to yours. Here is the Link

I found the problem.
It seems to me that if you create a second (or third ...) device, after the initial creation ,
The Secret Device Key, populated in the "Secrets Tab" of the new THING is not updated from the original value of the first creation, even thou the program gives you a new key to save.
Because the Value is Starred out, I was just assuming that the secret device key was updated when the new device was created. apparantly it is not.
I overwrote the new key from the saved PDF into the Secrets Tab, value field, Verified and downloaded and all worked fine.

What a trap for newbees ?

thanks for your assistance,
Much aprecated
Tom

1 Like

That is roughly what I thought was happening. Arduino needs to change that behaviour, either use the new Key, or recognize the device already has a key and put up a message about that letting the user know the original key is still valid. This situation comes up quite a bit, and I bet Arduino loses users because of it.