Skip to content

Run AWS IOT core MQTT sample on EK‐RA8M1

Duy Nguyen edited this page Jul 12, 2024 · 8 revisions
  • Hardware connection

Remove jumper J61 to enable Ethernet B

Jumper Configurations
J61 Open
  • AWS IoT Core setup
  1. To run this sample, you need to create an account on Amazon Web Services: https://aws.amazon.com/

  2. Once your account is created, sign in to AWS console as root user: https://aws.amazon.com/

  1. After signing in to AWS console, in the search bar, search for "IoT core" and open it
  1. Create a thing name "zephyr_sample", add certificate and policy for it.
  • Go to "AWS IoT -> Manage -> Things -> Create things -> Create single thing"
  • Create Cerificate for IoT thing, it's recommended to use the autogenerated one from AWS.
  • Create and attach policy to certificate, when click "Create policy" a new tab will pop up at "AWS IoT -> Security -> Policies"
  • Add below permission:
Policy effect Policy actions Policy resource
Allow iot:Connect *
Allow iot:Publish *
Allow iot:Receive *
Allow iot:GetRetainedMessage *
Allow iot:ListRetainedMessage *
Allow iot:RetainPublish *
Allow iot:Subscribe *
  • After finished creating the policy go back to the old tab, choose the policy and click "Create thing"

Important: After click "Create thing" you will be asked to download the Certificates and Keys, check and download Device Cerificate, Public key and Private key.

  • Setup, Build and Verify sanmple application
  1. Copy the downloaded the certificates and keys file in step 4 to "zephyr/samples/net/cloud/aws_iot_mqtt/src/creds" and execute "zephyr/samples/net/cloud/aws_iot_mqtt/src/creds/convert_keys.py", it will help to generate the key in form of C code for the sample.

  2. Modify "CONFIG_AWS_ENDPOINT" config in "zephyr/samples/net/cloud/aws_iot_mqtt/prj.conf" to your AWS account End point (it can be check in AWS IoT -> Settings)

  1. Build and Flash application to board.

    cd ~/zephyrproject/zephyr

    west build -b ek_ra8m1 -p always samples/net/cloud/aws_iot_mqtt/

    west flash

  2. Verify result using "MQTT test client" on AWS IoT console.

  • The sample is created to Publish a message to topic "zephyr_sample/data" and Subscribe to topic "zephyr_sample/downlink". On AWS IoT console "MQTT test client" we can Subcribe to topic "zephyr_sample/data" to verify message sent from board and publish a message to topic "zephyr_sample/downlink" to send a message to the board

Result:

  • For each message MQTT test client send to top "zephyr_sample/downlink" board will response with a message to "zephyr_sample/data":
  • Log show on board console:

Home

Getting started guide

Supported MCU/MPU family

Samples and Demo Hardware Configuration Reference

RA Sample and Demo Hardware configuration
RX Sample and Demo Hardware configuration
RZ Sample and Demo Hardware configuration
Clone this wiki locally