DEV Community

Takahiro-Y01
Takahiro-Y01

Posted on • Edited on

How to connect "The Things Network(TTN V3)" and "AWS IoT Core".

This article will show you how to connect "The Things Network V3" and "AWS IoT Core".

1. TTN Settings

  • Select the application to connect from TTN, and select "AWS IoT" from "Integrations".
  • Then click on the "Deployment Guide".

Image description

  • Scroll down.
  • For "Select your AWS region", select your region.
  • Then click "Deploy for The Things Network" under "Community".

Image description

2. AWS Settings

  • Enter the TTN cluster address or TTN application ID.

Image description

  • See below for cluster address and application ID

Image description

Creating an API key

  • Select "API keys" from the TTN application and click "Add API key".

Image description

  • Make the settings as shown in the image.

Image description

  • Copy the created API key and paste it into the aws settings screen.

Image description

Image description

  • When the stack is created by aws, it will be as follows.
  • Creating the stack will take a few minutes.

Image description

3. Set up with AWS IoT Core

  • Log in to the aws IoT Core.
  • And if you check "Things", you can see that a new device has been added.

Image description

  • Let's check if the data can be obtained.
  • Enter "lorawan / #" in "MQTT test client".

Image description

  • After waiting for a while, the data will be earned.

Image description

  • However, this alone is not enough to extract only the variables you want.
  • Let's add a rule for the data format.
  • I use a distance sensor, so I try to get only the distance.

Image description

Image description

  • Edit the SQL statement.

Image description

  • These are the SQL statements I used.
SELECT end_device_ids.device_id AS device, received_at AS r_date, uplink_message.decoded_payload.distance AS distance FROM 'lorawan/A840414/uplink' WHERE uplink_message.decoded_payload.distance > 20
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

Image description

Image description

Top comments (0)