Using AWS Cloud Services for SenseCAP T1000 Tracker
AWS IoT provides the cloud services that connect your IoT devices to other devices and AWS cloud services. AWS IoT provides device software that can help you integrate your IoT devices into AWS IoT-based solutions. If your devices can connect to AWS IoT, AWS IoT can connect them to the cloud services that AWS provides.
Login to AWS IoT console
If you do not have an AWS account, click here to create one.
Add Gateway
Navigate to Internet of Things
, then click IoT Core
.
On the left menu,select LPWAN devices
→ Gateways
, click Add gateway
Gateway's EUI
: The EUI of your gateway, you can find it on the device label.
Frequency
: The gateway's frequency band.
Name
: Name your gateway(optional)
SubBand
: Optionally, you can also specify LoRaWAN configuration data such as the subbands that you want to use and filters that can control the flow of traffic. For more information, see Configure position of wireless resources with AWS IoT Core for LoRaWAN.
Configure your gateway
Gateway Certificate
To authenticate your gateway so that it can securely communicate with AWS IoT, your LoRaWAN gateway must present a private key and certificate to AWS IoT Core for LoRaWAN.
Click Create certificate
.
Download and save the certificate files and the server trust certificates.
There shoule be four files inside, you'll use them later to configure the gateway.
Gateway Permission
If you haven't created the IoTWirelessGatewayCertManagerRole IAM role for your account, create the role before you continue adding the gateway. Your gateways won't be able to communicate with AWS IoT without this role.
Choose the Role: IoT Wireless Gateway Cert Manager Role
, then submit the configuration.
Copy the CUPS URL, we will use it in the next step.
Gateway Configuration
Login to the Luci configure page of the gateway, check Get_Started for more details.
Navigate to LoRa
> LoRa Network
.
Mode
: Basic Station
Gateway EUI
: Your gateway eui
Server
: CUPS Server
URL
: The CUPS URL we copied before
Authentication Mode
: TLS Server and Client Authentication
Copy the content of the certificate file we downloaded before(the certificate can be opened in text form).
Navigate to the Gateways page and choose the gateway you've added.
In the LoRaWAN specific details section of the Gateway details page, you'll see the connection status and the date and time the last uplink was received.
Add Profiles
Device and service profiles can be defined to describe common device configurations. These profiles describe configuration parameters that are shared by devices to make it easier to add those devices. AWS IoT Core for LoRaWAN supports device profiles and service profiles.
Add devices profiles
Navigate to Devices
> Profiles
, click Add device profile
.
Provide a Device profile name, select the Frequency band (RfRegion)that you're using for the device and gateway, and keep the other settings to the default values.
Add service profiles
Navigate to Devices
> Profiles
, click Add service profile
It's recommend that you leave the setting AddGWMetaData
enabled so that you'll receive additional gateway metadata for each payload, such as RSSIand SNR for the data transmission.
Add Destination
Navigate to Devices
> Destination
, click Add destination
.
Here select Publish to AWS IoT Core Message Broker
and name the destination's MQTT topic
Permissions: Select an existing service role > IoT Wireless Gateway Cert Manager Role
A destination name can only have alphanumeric, - (hyphen) and _ (underscore) characters and it can't have any spaces.
Add LoRaWAN Devices
Add wireless device
Navigate to LPWAN devices
> Devices
, click Add wireless device
.
Wireless device specification
: OTAAv1.0x
DevEUI/APP EUI/APP key
: can be found in the SenseCAP Mate APP, check Get_Started for more details.
Select the device profile and destination you created in the previous step.
Navigate to the Devices page and choose the device you added before.
In the Details section of the Wireless devices details page, you'll see the date received.
Configure the decoder
Create Message Rules
Navigate to Message routing
tab → Rules
, and click Create Rule
button.
Name your rule and submit it.
SQL version
: 2016-03-23
SQL statement
: SELECT * FROM "YourDestinationTopic"
Here we fill in t1000-raw
according to Add Destination
Scroll down to Rule actions
section, and select Lambda
from Action 1
, then click Create a Lambda function
.
Function name
: Name your function.
Runtime
: Node.js 20.x
Architexture
: x86_64
Click Create function
button to create a new function.
After creating the function, it goes to the function's config page. We will configure it later so just go back to the rules page.
Click the Refresh button and select the Lambda function you create before. Then click Next
to Step 4.
Check that all details of the rule are correct, then click Create
to create the rule.
Configure the Lambda Function
Back to Message routing
tab → Rules
, select the rule you created before.
Click Lambda
from Actions
and then click the link to go to the Lambda function configuration page.
On the following funcition config page, rename the index.mjs
file to index.js
, remove all the code and replace it with the script from Resource, then click Deploy
button.
Replace the region
and device id
according to your device.
After configuring the decoder, Click Configuration
→ Permissions
→ Edit
.
Click View the xxxxxxxxxxx
role at the bottom.
Click Add permissions
→ Attach policies
.
Search AdministratorAccess
, check the box left it, and then click Add Permissions
.
Check the data
Check the data on page MQTT test client
, input #
and click Subscribe
button, you will see the data.
The raw payload of T1000 Tracker publish from t1000-raw
and the decoded data publish from tracker/measurement
.