ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect

I am attempting the second activity in the Explore IOT Kit which is “Graphing DATA in the Cloud:”

When I try to run the example in the activity, I receive this error.

***** Arduino IoT Cloud - configuration info *****
Device ID: 1f300cd1-f80c-4637-b064-d1cc485c2094
Thing ID: 77e35d80-07ac-400c-897f-bc0ca85ec02d
MQTT Broker: mqtts-sa.iot.arduino.cc:8883
WiFi.status(): 0
Current WiFi Firmware: 1.4.1
Connected to “Mto Nguvu 2.4”
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-sa.iot.arduino.cc:8883

I have updated the firmware as you can see based upon other posts in the Forum. Also opened ports 8883 incoming and outgoing in the Windows firewall. The connection to the IoT Cloud never seems to be established. Seems to connect to the wifi fine.

Code for sketch is here. Note that it never gets out of the ArduinoCloud.update() LOOP and continues to print the above error

#include "thingProperties.h"
#include <Arduino_MKRIoTCarrier.h>
MKRIoTCarrier carrier;
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(2);
  ArduinoCloud.printDebugInfo();
    //Wait to get cloud connection to init the carrier
  while(ArduinoCloud.connected() != 1){
    ArduinoCloud.update();
    delay(500);
  } 
  delay(500);
  CARRIER_CASE = false;
  carrier.begin();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  temperature = carrier.Env.readTemperature(FAHRENHEIT);
  humidity = carrier.Env.readHumidity();
  float pressure = carrier.Pressure.readPressure();
  Serial.print("Temperature = ");
  Serial.print(temperature);
  Serial.println(" °F");
  delay(1000);
}

thingProperties.h

// Code generated by Arduino IoT Cloud, DO NOT EDIT.

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


const char THING_ID[] = "77e35d80-07ac-400c-897f-bc0ca85ec02d";

const char SSID[]     = SECRET_SSID;    // Network SSID (name)
const char PASS[]     = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)


float temperature;
float humidity;

void initProperties(){

  ArduinoCloud.setThingId(THING_ID);
  ArduinoCloud.addProperty(temperature, READ, 1 * SECONDS, NULL);
  ArduinoCloud.addProperty(humidity, READ, 1 * SECONDS, NULL);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

Using the desktop Arduino IDE I was able to connect to a local browser and pass information back and forth with the Arduino's IP address. I believe that this verifies that the wifi chip is working fine. As suggested in other Forum posts I deleted the entire project and tried to start over. Now I get stuck at the setup device step. Although the device makes clicking noises in the beginning and is clearly powered up the setup fails repeatedly even after restarting the create agent and disconnecting and reconnecting the device. Thoughts from anyone would be much appreciated.

It looks like you're trying to hit the secure MQTT port (8883). Is your system set up for SSL and have you tried it over plain text on 1883?

I finally got Activity two to work with the IOT. The most plausible explanation I have is that when I updated the firmware, the device ID must have changed. To update the firmware I used the desktop IDE and a beta version of the firmware updater to get to firmware version 1.4.1. Thus the sketch I had partially created before the firmware update may not have had the correct device ID. To get the IOT connection to work I had to completely delete the project, devices and dashboards. After starting fresh everything worked this time.

I suggest the following process.

  1. Update your firmware through the Desktop IDE first. The note from the documentation (shown below) was deceiving since the firmware on my board was not updated during device connection. There are other posts in the Forums about how to update the firmware. To get to 1.4.1 I had to use a beta version of the newest desktop IDE.
    "Note: When we configure the board the first time, in order to provide users with the best performance, the cloud checks if the core version of the WiFi module of our Arduino MKR WiFi 1010 board is the last one and if needed, it updates it."
  2. Close all connections with the desktop IDE and quit out of the desktop IDE software.
  3. Delete all projects, devices and dashboards on the IOT site.
  4. Follow the step by step instructions in Activity 2. I found that I could not use my own name for my device. Each time I tried this, configuring the device failed. Using the name generator worked.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.