Run AWS IOT core MQTT sample on EK‐RA8M1 - renesas/zephyr GitHub Wiki
Hardware connection
Remove jumper J61 to enable Ethernet B
Jumper | Configurations |
---|---|
J61 | Open |
AWS IoT Core setup
-
To run this sample, you need to create an account on Amazon Web Services: https://aws.amazon.com/
-
Once your account is created, sign in to AWS console as root user: https://aws.amazon.com/
- After signing in to AWS console, in the search bar, search for "IoT core" and open it
- 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
-
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.
-
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)
-
Build and Flash application to board.
cd ~/zephyrproject/zephyr
west build -b ek_ra8m1 -p always samples/net/cloud/aws_iot_mqtt/
west flash
-
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: