element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Internet of Things
  • Technologies
  • More
Internet of Things
Blog Arduino MKR WAN 1310 via The Things Network to AWS IoT MQTT
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Internet of Things to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 13 Jan 2024 12:06 PM Date Created
  • Views 1071 views
  • Likes 6 likes
  • Comments 1 comment
  • mqtt
  • aws
  • ttn
  • the_things_network
  • iot
  • aws_iot
  • arduino
Related
Recommended

Arduino MKR WAN 1310 via The Things Network to AWS IoT MQTT

Jan Cumps
Jan Cumps
13 Jan 2024
Arduino MKR WAN 1310 via The Things Network to AWS IoT MQTT

I connected an Arduino MKR WAN 1310 to Amazon Web Services (AWS IoT). Then tested if the Arduino can publish uplinks to AWS, and can receive AWS topics as downlinks. This post is my log of the activity.

image
image source: me

Read this post first:  Arduino MKR WAN 1310 on The Things Network (TTN) . This posts starts at the point where the Arduino is working with The Things Network (TTN). 

The Example setup

An Arduino MKR WAN 1310 is registered and tested on TTN ( Arduino MKR WAN 1310 on The Things Network (TTN) ). 
TTN to AWS integration is enabled.
Data that the Arduino uplinks via LoRaWan, arrive on an AWS IoT MQTT topic.
Data that's published to a topic on that Aws IoT MQTT service, arrives on the Arduino as a downlink.

image
image source: me

AWS IoT MQTT is the usual integration entry to AWS IoT. From that point on, you can use other AWS services (database, dashboards and analytics, mail, alerts, ...).
If you need inspiration for what to do with the data, check Manage Arduino MKR WIFI 1010 Battery Life in the Cloud - AWS, Graphs and Alerts .

image
image source: when I connected an Arduino MKR 1010 (wifi) to directly to AWS

Assumptions:

  • you have your Arduino MKR WAN 1310 integrated with TTN
  • you have an AWS account and know how to navigate the AWS IoT console.

Steps:

  • enable integration of your TTN Thing with AWS IoT
  • test uplink to AWS IoT MQTT and
  • test downlink from AWS IoT MQTT

We don't have to change the Arduino code or modify existing TTN setup. The integration is an extension, not a modification.

Enable TTN to AWS integration

I followed the Integrating TTN and AWS: TTN AWS Deployment guide. It's very clear.
I can't explain it better than they do. Follow their steps. A few things to note:

  • Create the required Application API ID from the TTN console, with the application open:
    image
    The application ID (named jancumps-01 in my case) will be the Application ID on the integration template that we 'll use in one of the next steps.

  • When creating the application API ID, you get a pop-up with the key. Copy this because you will not be able to retrieve this later. It's secret, store it safely.
    When we integrate with AWS, this will have to be entered in the template as Application API Key.

  • When you are ready to open the template, take care to select the correct TTN (Sandbox) and AWS (your AWS area) settings. You can find the AWS info when you open the console in your browser. For me, it's Oregon, US WEST 2. 
    image
    Don't just take over my settings :) - this has to be correct for you.

  • Now you're ready to activate the integration:
    image

  • Keep all defaults. Find a sensible name (I called it TtnAwsIot) . The two fields below have to be filled with the IDs you saved while creating the key in TTN.
    image

When you filled in all required data, and left all defaults, submit the template. The integration setup will be executed on AWS. You don't need to do any manual setup in AWS console.

image

You may be surprised that you don't see the Thing in AWS yet. That will happen automatically the next time it talks to a TTN gateway. Usually the next uplink, or the next join.

image

image source: all things I have registered on AWS

Details:

image

Test the integration with AWS IoT MQTT

image

The AWS free tier account has limitations. Take care to stay within the limits, to prevent charges. When you have concluded the exercise, it's good practice to disable the integrations and/or switch off the Arduino.

AWS Free tier conditions after 12 months.

Integration Uninstall info

TTN has written a good manual for that too: TTN AWS Messages. I followed the exact steps and it worked.

uplink from Arduino

To see incoming messages, go to the MQTT Test page of the AWS IoT console, and Subscribe to topic lorawan/#. As soon as your Arduino sends a message over LoRaWan, it will appear in the AWS IoT MQTT log . Her's a capture of an incoming payload:

image

That works. The payload is JSON, because we provided an uplink formatter in our TTN device setup.

downlink to Arduino

We can test that in the same MQTT console. Publish a message to the lorawan/downlink topic.

Payload:

{
  "thingName": "A****************7",
  "payload": {  "ledState": "on"   }
}

We can also use JSON here, because we have a downlink formatter in TTN.

image

The message will immediately appear in the live data log in the TTN console:

image

But will not yet arrive on the Arduino. That's because we'll only get downlink data when we start a communication (design choice in my sketch). Once we receive an uplink from the Arduino, the downlink is sent back:

image

And the LED will light up:

image

end to end

How the downlink works: 

At the start of this test, Initial state, my Arduino was not active.

image

  1. on AWS, I posted a topic on the MQTT service to turn the Thing's LED on.
  2. 2 minutes later, I switched on the Arduino. It joined TTN
  3. the first activity of the Arduino sketch, after joining, is to uplink its LED status.
    Immediately after that, it receives the downlink command to turn the LED on (the AWS message).
    See image below for the detail of that.
  4. After the Arduino's LED was switched on, the sketch noticed the state change. It uplinked the new status.

image

Enjoy!

If you just need a simple MQTT service to exchange data with your Arduino, check out  Arduino MKR WAN 1310 integration with The Things Network MQTT .

  • Sign in to reply
Parents
  • DAB
    DAB over 1 year ago

    Nice post Jan.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • DAB
    DAB over 1 year ago

    Nice post Jan.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube