ioNIC AWS MQTTS Client Arduino Example
The W55RP20-S2E operates as an MQTTS client, connects securely to AWS IoT Core, and publishes and subscribes to configured topics.
How to AWS MQTTS Client Example
This example explains how the Raspberry Pi Pico transmits AT commands to the W55RP20-S2E board via the UART or SPI interface to configure it in MQTTS client mode.
After the MQTTS client configuration is completed, the W55RP20-S2E establishes a TLS-secured connection to AWS IoT Core.
When a message is published to a subscribed topic in AWS IoT Core, the W55RP20-S2E receives the message and forwards it to the Raspberry Pi Pico via UART or SPI.
The Raspberry Pi Pico processes the received message, generates a publish message, and sends it to the W55RP20-S2E through UART or SPI. The W55RP20-S2E then publishes the message to the specified topic in AWS IoT Core.
Step 1: Prepare software
The following serial terminal programs are required for test, download and install from below links.
Step 2: Prepare hardware
1. Connect GPIO13 according to the selected UART/SPI mode of the W55RP20 EVB Pico, as illustrated below.
| GPIO13 Pin | Desc |
| LOW(GND) | UART mode (default) |
| HIGH(3.3V) | SPI mode |
2. Connect the Raspberry Pi Pico and the W55RP20 EVB Pico using jumper wires as shown below, depending on the selected UART/SPI mode.
If UART mode :
| Raspberry Pi Pico | W55RP20 EVB Pico |
| GPIO4 (UART_TX) | GPIO5 (UART_RX) |
| GPIO5 (UART_RX) | GPIO4 (UART_TX) |
| GND | GND |
If SPI mode :
| Raspberry Pi Pico | W55RP20 EVB Pico |
| GPIO2 (SPI_CLK) | GPIO2 (SPI_CLK) |
| GPIO3 (SPI_TX) | GPIO4 (SPI_RX) |
| GPIO4 (SPI_RX) | GPIO3 (SPI_TX) |
| GPIO5 (SPI_CS) | GPIO5 (SPI_CS) |
| GPIO26 (SPI_INT) | GPIO26 (SPI_INT) |
| GND | GND |
3. Connect the Raspberry Pi Pico to your PC (desktop or laptop) using a 5-pin Micro USB cable.
4. Connect the W55RP20 EVB Pico to your PC (desktop or laptop) using a USB Type-C cable.
Step 3: Arduino IDE Setup
Install Board Support Package
- Open Arduino IDE
- Go to File → Preferences
- Add the following to "Additional Boards Manager URLs": https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

- Go to Tools → Board → Boards Manager
- Search for "Raspberry Pi Pico" and install Raspberry Pi Pico/RP2040 by Earle F. Philhower, III
- Select Tools → Board → Raspberry Pi RP2040 Boards → Raspberry Pi Pico
Step 4: Code Examples
Each example provides a .ino file to upload to the Pico.
- SPI Communication
- UART Communication
Step 5: Setup MQTTS Client Example
AWS IoT Core
In order to connect to AWS IoT through MQTT, the development environment must be configured to use AWS IoT.
This example was tested by configuring AWS IoT Core. Please refer to the 'Create AWS IoT resources' section of document below and configure accordingly.
For more information on AWS IoT, refer to the document below.
Step 6: Upload and Test
6.1 Select Raspberry Pi Pico
- Go to Tools → Board → Raspberry Pi RP2040 Boards → Raspberry Pi Pico
- Select Tools → Port → Choose your COM port
6.2 Upload Code
- Open the desired example .ino file
- Modify IP addresses and port numbers as needed
// AWS IoT Core MQTTs config (update these)
static const char *AWS_IOT_ENDPOINT = "{your_aws_endpoint}.com";
static const char *AWS_MQTT_PORT = "8883";
static const char *MQTT_USER = "user";
static const char *MQTT_PASS = "";
static const char *MQTT_CLIENT_ID = "{your_thing}";
static const char *MQTT_KEEPALIVE = "60";
static const char *MQTT_PUB_TOPIC = "$aws/things/{your_thing}/shadow/update";
static const char *MQTT_SUB_TOPIC = "$aws/things/{your_thing}/shadow/update/accepted";
Set up the AWS IoT certificates in the 'certification.h' file located in the 'aws_mqtts/' directory using the Root CA, Client Certificate, and Private Key downloaded in the previous “Create AWS IoT resources” step.
// certifiacation.h
// rootca
#define ROOTCA \
"-----BEGIN CERTIFICATE-----\r\n"\
"...\r\n"\
"-----END CERTIFICATE-----\r\n"
// certificate crt
#define CLEINT_CERT \
"-----BEGIN CERTIFICATE-----\r\n"\
"...\r\n"\
"-----END CERTIFICATE-----\r\n"
// private key
#define PRIVATE_KEY \
"-----BEGIN RSA PRIVATE KEY-----\r\n"\
"...\r\n"\
"-----END RSA PRIVATE KEY-----\r\n"3. Click Upload button or press Ctrl+U
4. Wait for upload to complete
6.3 Open Serial Monitor

- Go to Tools → Serial Monitor
- Set baud rate to 115200
- Verify network information and connection status
Step 7: Run
1. Configure the W55RP20-S2E as an MQTTS client and set up the network using AT commands.
2. Using the AWS IoT console, subscribe to the specified topic. Then publish a test message to the another specified topic.
The published message is delivered to the W55RP20-S2E module subscribed to the topic through AWS IoT Core.


3. The W55RP20-S2E receives the message from the subscribed topic via AWS IoT Core and forwards it to the Raspberry Pi Pico through the UART interface.
The Raspberry Pi Pico prints the received message to a terminal, generates a publish message, and transmits it back to the W55RP20-S2E over UART.
4. The W55RP20-S2E publishes the response message received via UART to the configured topic in AWS IoT Core.
The published message can then be verified using the MQTT test client subscribed to the same topic.


