# MKR1010 to AWS Core IoT

**URL:** <https://forum.arduino.cc/t/mkr1010-to-aws-core-iot/1350676>\
**Category:** Networking, Protocols, and Devices\
**Created:** [February 5, 2025, 10:26am UTC](https://forum.arduino.cc/t/mkr1010-to-aws-core-iot/1350676 "2025-02-05T10:26:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![agrigrid](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/agrigrid/32/1131985_2.png) [@agrigrid](https://forum.arduino.cc/u/agrigrid)\
**Post date:** [February 5, 2025, 10:26am UTC](https://forum.arduino.cc/t/mkr1010-to-aws-core-iot/1350676/1 "2025-02-05T10:26:20Z")

</div>

Hi All,

I will start by apologizing. There has been similar requests before, but I just cannot find a solution that works. So sorry if this is a duplicate of previous questions. Please help.  
I followed everything in the AWS tutorial, but I only get the following:  
NB XXXX I removed my personal info.

"You're connected to the network

Attempting to MQTT broker: [XXXXX-ats.iot.ap-southeast-2.amazonaws.com](http://XXXXX-ats.iot.ap-southeast-2.amazonaws.com)  
....................................................."

Here is the code:

```arduino
#include <ArduinoBearSSL.h>
#include <ArduinoECCX08.h>
#include <ArduinoMqttClient.h>
#include <WiFiNINA.h> // change to #include <WiFi101.h> for MKR1000

#include "arduino_secrets.h"

/////// Enter your sensitive data in arduino_secrets.h
const char ssid[] = SECRET_SSID;
const char pass[] = SECRET_PASS;
const char broker[] = SECRET_BROKER;
const char* certificate = SECRET_CERTIFICATE;

WiFiClient wifiClient; // Used for the TCP socket connection
BearSSLClient sslClient(wifiClient); // Used for SSL/TLS connection, integrates with ECC508
MqttClient mqttClient(sslClient);

unsigned long lastMillis = 0;

void setup() {
  Serial.begin(115200);
  while (!Serial);

  if (!ECCX08.begin()) {
    Serial.println("No ECCX08 present!");
    while (1);
  }

  // Set a callback to get the current time
  // used to validate the servers certificate
  ArduinoBearSSL.onGetTime(getTime);

  // Set the ECCX08 slot to use for the private key
  // and the accompanying public certificate for it
  sslClient.setEccSlot(0, certificate);

  // Optional, set the client id used for MQTT,
  // each device that is connected to the broker
  // must have a unique client id. The MQTTClient will generate
  // a client id for you based on the millis() value if not set
  //
  mqttClient.setId("iotconsole-XXXXXXXX");

  // Set the message callback, this function is
  // called when the MQTTClient receives a message
  mqttClient.onMessage(onMessageReceived);
}

void loop() {
  if (WiFi.status() != WL_CONNECTED) {
    connectWiFi();
  }

  if (!mqttClient.connected()) {
    // MQTT client is disconnected, connect
    connectMQTT();
  }

  // poll for new MQTT messages and send keep alives
  mqttClient.poll();

  // publish a message roughly every 5 seconds.
  if (millis() - lastMillis > 5000) {
    lastMillis = millis();

    publishMessage();
  }
}

unsigned long getTime() {
  // get the current time from the WiFi module  
  return WiFi.getTime();
}

void connectWiFi() {
  Serial.print("Attempting to connect to SSID: ");
  Serial.print(ssid);
  Serial.print(" ");

  while (WiFi.begin(ssid, pass) != WL_CONNECTED) {
    // failed, retry
    Serial.print(".");
    delay(5000);
  }
  Serial.println();

  Serial.println("You're connected to the network");
  Serial.println();
}

void connectMQTT() {
  Serial.print("Attempting to MQTT broker: ");
  Serial.print(broker);
  Serial.println(" ");

  while (!mqttClient.connect(broker, 8883)) {
    // failed, retry
    Serial.print(".");
    delay(5000);
  }
  Serial.println();

  Serial.println("You're connected to the MQTT broker");
  Serial.println();

  // subscribe to a topic
  mqttClient.subscribe("arduino/incoming");
}

void publishMessage() {
  Serial.println("Publishing message");

  // send message, the Print interface can be used to set the message contents
  mqttClient.beginMessage("arduino/outgoing");
  mqttClient.print("hello ");
  mqttClient.print(millis());
  mqttClient.endMessage();
}

void onMessageReceived(int messageSize) {
  // we received a message, print out the topic and contents
  Serial.print("Received a message with topic '");
  Serial.print(mqttClient.messageTopic());
  Serial.print("', length ");
  Serial.print(messageSize);
  Serial.println(" bytes:");

  // use the Stream interface to print the contents
  while (mqttClient.available()) {
    Serial.print((char)mqttClient.read());
  }
  Serial.println();

  Serial.println();
}

```

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [February 5, 2025, 2:31pm UTC](https://forum.arduino.cc/t/mkr1010-to-aws-core-iot/1350676/2 "2025-02-05T14:31:40Z")

</div>

Read the pinned post re 'How to get the most from the forum'

---

<div class="post-metadata">

**Author:** ![agrigrid](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/agrigrid/32/1131985_2.png) [@agrigrid](https://forum.arduino.cc/u/agrigrid)\
**Post date:** [February 5, 2025, 10:32pm UTC](https://forum.arduino.cc/t/mkr1010-to-aws-core-iot/1350676/3 "2025-02-05T22:32:21Z")

</div>

@sonofcy Not sure what your reply is supposed to mean. I explained that although there has been similar questions asked, I have not been able to get a resolution. Not sure what you are implying I did wrong.

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [February 5, 2025, 10:52pm UTC](https://forum.arduino.cc/t/mkr1010-to-aws-core-iot/1350676/4 "2025-02-05T22:52:00Z")

</div>

It means there is information there that will get you better help.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [August 4, 2025, 10:52pm UTC](https://forum.arduino.cc/t/mkr1010-to-aws-core-iot/1350676/5 "2025-08-04T22:52:27Z")

</div>

Closed on August 4, 2025, 10:52pm UTC

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