---
title: "How to Connect W55RP20 to AWS IoT Using the MQTT"
url: "https://maker.wiznet.io/Grace_Koo/projects/how-to-connect-w55rp20-to-aws-iot-using-the-mqtt/"
markdown_url: "https://maker.wiznet.io/Grace_Koo/projects/how-to-connect-w55rp20-to-aws-iot-using-the-mqtt/md"
type: "WCC: WIZnet Created Content"
author: "Grace"
author_url: "https://maker.wiznet.io/Grace_Koo/"
original_author: "Grace Koo"
published: "2024-10-17"
language: "en"
tags: ["AWS IoT Core", "C/C++", "W55RP20"]
hardware: ["WIZnet W55RP20-EVB-Pico"]
likes: 0
views: 898
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# How to Connect W55RP20 to AWS IoT Using the MQTT

> This WCC includes methods for testing the W55RP20 with AWS IoT, as well as instructions for first-time users on how to use AWS IoT.

Original author: Grace Koo

## Components

- **WIZnet W55RP20-EVB-Pico** x 1 ([docs](https://wiznet.io/products/powered-by-raspberry-pi/w55rp20-evb-pico))

## Documents and links

- [WIZnet-PICO-AWS-C](https://github.com/WIZnet-ioNIC/WIZnet-PICO-AWS-C) (code)

## Article

AWS IoT (Internet of Things) is a cloud service provided by Amazon Web Services (AWS) that allows various devices and sensors to connect to the internet to collect, analyze, and manage data.

The AWS IoT platform handles data transmission between devices and servers over the internet, primarily using protocols like MQTT and HTTPS that operate over the TCP/IP stack.

The W55RP20 chip is a SiP solution that integrates WIZnet's W5500 Ethernet controller and Raspberry Pi's RP2040 microcontroller, providing networking and processing capabilities for IoT devices and smart applications. The W5500 supports a hardware TCP/IP stack, simplifying network connectivity and communication management, while the RP2040 offers fast data processing and multitasking capabilities, enabling the simultaneous handling of multiple tasks.

Execute the aws_iot_mqtt.c code from the PICO-AWS-C examples.

> https://github.com/WIZnet-ioNIC/WIZnet-PICO-AWS-C

## Hardware Requirements

- W55RP20-EVB-PICO

- Desktop or Laptop

- USB Type-C Cable

### Software Tools

- Visual Studio Code

- Serial Terminal : Tera Term

#### Setup board

Need to set up the board in the 'WIZnet-PICO-C/CMakeLists.txt' file.

Activate the 8th line in this file by setting 'set(BOARD_NAME W55RP20_EVB_PICO)'.

![](https://maker.wiznet.io/upload/ckeditor5/469704619%5F1727275748.png)

*WIZnet-PICO-AWS-C/CMakeLists.txt*

![](https://maker.wiznet.io/upload/ckeditor5/883247327%5F1729098679%2Epng)

*WIZnet-PICO-AWS-C\examples\aws_iot_mqtt\CMakeLists.txt*

*If you want to view log messages via USB serial, modify the following file as shown below.

#### Setup Network Info

Set up the desired network information.

![](https://maker.wiznet.io/upload/ckeditor5/455640412%5F1728925253%2Epng)

*WIZnet-PICO-AWS-C/examples/aws_iot_mqtt.c*

#### MQTT configuration

> If you're using AWS IoT for the first time, refer to the '☞ How to use AWS IoT console' chapter at the bottom of this WCC.

- To use MQTT, you first need to set the following values.

- MQTT_DOMAIN : The address used when the device connects to AWS IoT(broker)

- MQTT_PUB_TOPIC : Define the topic where the device will publish messages

- MQTT_SUB_TOPIC : Define the topic for the device to receive messages

- MQTT_CLIENT_ID : Define the ID to identify the device

![](https://maker.wiznet.io/upload/ckeditor5/669433538%5F1729001581%2Epng)

*WIZnet-PICO-AWS-C/examples/aws_iot_mqtt.c*

Device endpoint from AWS IoT 'MQTT test client' tab.

![](https://maker.wiznet.io/upload/ckeditor5/883246026%5F1729090675%2Epng)

*Define in 'MQTT_DOMAIN'*

- In this example, you need to download that certificate files.

( Device certificate(.crt), private key file(.key), Amazon trust service endpoint(.pem) )

If you've downloaded the certificate, input it into the 'mqtt_certificate.h' file. AWS IoT will then verify the certificate and accept the connection request.

![](https://maker.wiznet.io/upload/ckeditor5/23314006%5F1729173352%2Epng)

*Part of a device-certificate.crt file*

But you need to format the certificate files as shown in the image below. Each line should have double quotes and end with `\r\n`. Apply this format to all three files.

![](https://maker.wiznet.io/upload/ckeditor5/883246026%5F1729085349%2Epng)

*Part of mqtt_root_ca[ ] in "WIZnet-PICO-AWS-C\examples\aws_iot_mqtt\mqtt_certificate.h."*

- The QoS for MQTT subscribe or publish can be changed when using these functions. It is currently set to 0.

![](https://maker.wiznet.io/upload/ckeditor5/23314006%5F1729164259%2Epng)

*WIZnet-PICO-AWS-C\examples\aws_iot_mqtt\aws_iot_mqtt.c*

![](https://maker.wiznet.io/upload/ckeditor5/23314006%5F1729164239%2Epng)

*WIZnet-PICO-AWS-C\examples\aws_iot_mqtt\aws_iot_mqtt.c*

#### Run

The execution screen is as follows.

The connection to AWS IoT(broker) is established through the following process.

![](https://maker.wiznet.io/upload/ckeditor5/23314006%5F1729157717%2Epng)

You can subscribe/publish to a topic in the MQTT client provided by AWS IoT and verify it.

When the W55RP20-EVB-Pico publishes to a specific topic for a certain period, a message will appear as shown below.

![](https://maker.wiznet.io/upload/ckeditor5/883246026%5F1729088448%2Epng)

*AWS IoT - test/MQTT test client*

Conversely, if you publish a message to the topic subscribed by the W55RP20 in the AWS IoT MQTT client, you can confirm that the message is displayed as shown below.

![](https://maker.wiznet.io/upload/ckeditor5/883246026%5F1729088478%2Epng)

### ☞ How to use AWS IoT console

After creating an account and log in at https://aws.amazon.com/.

When you navigate to the Console as shown below, go to **All Services** > **Internet of Things** > **IoT Core**.

![](https://maker.wiznet.io/upload/ckeditor5/23314006%5F1729161287%2Epng)

- To create and register a certificate for the device, you will first create a policy.

In the left tab of IoT Core, go to **Manage** > **Security** > **Policies** and create a new policy.

![](https://maker.wiznet.io/upload/ckeditor5/669433538%5F1729013956%2Epng)

*Create a new policy*

Now, you need to add statements to the new policy. In this example, the required policy actions are `iot:Connect`, `iot:Receive`, `iot:Publish`, and `iot:Subscribe`.

![](https://maker.wiznet.io/upload/ckeditor5/23314006%5F1729162180%2Epng)

*add statements to the policy*

- Next, we will create a certificate. In the left tab, go to **Manage** > **Security** > **Certificates**, then click **Add certificates** > **Create certificate**.

![](https://maker.wiznet.io/upload/ckeditor5/883246026%5F1729074044%2Epng)

*create certificate*

We will create a certificate by AWS IoT, so configure the settings as shown in the image on the left and proceed with the creation.

When you click the **Create** button, a popup will appear to download the certificate and keys. Make sure to download the files indicated in the image. Pay attention to the key files, as they can only be downloaded at the time of certificate creation.

*( Device certificate(.crt), private key file(.key), Amazon trust service endpoint(.pem) )*

![](https://maker.wiznet.io/upload/ckeditor5/883246026%5F1729077936%2Epng)

*create certificate and download files*

- After creating the certificate, attach the policy that will be used with the certificate. Attach it as shown below.

![](https://maker.wiznet.io/upload/ckeditor5/883246026%5F1729085091%2Epng)

Once the certificate is created as shown above, you can register the certificate on the device and connect it to AWS IoT.

---

Source: https://maker.wiznet.io/Grace_Koo/projects/how-to-connect-w55rp20-to-aws-iot-using-the-mqtt/
