I road-tested the Harting MICA Complete IIoT Starter Kit. In this follow up blog, I'm connecting the Mica to AWS (Amazon Web Services). The goal if this blog is to register the device and test a message from and to the AWS IoT service. |
Set Up the Thing
Prerequisite: have a free tier AWS account
You have to let AWS IoT know that you want to connect the Mica to it. The process involves creating certificates and setting up rights.
In your browser, log in to the AWS console and Open the AWS IoT Core service
Let's first make a security policy that allows our device to publish and subscribe to all topics on our AWS IoT service.
When running the AWS test kit later, a stricter policy will be generated.
Navigate to Secure -> Policy
Then go to Secure -> Certificates.
Sect your certificate, and attach the policy to it, via the Action menu.
Create a new Thing.
Only the name is mandatory. I created a group, but that - and other settings on this page, are optional.
Then click on Create Certificate. Download all certificates, and the root certificate "RSA 2048 bit key: Amazon Root CA 1".
Store them in a safe place.
Click Activate, then Attach Policy.
Select the policy you created earlier.
Prepare the Test Kit
Open your Thing in AWS IoT, and select Interact
Click on Connect to the Device, then Get Started.
Select Node.js and Linux:
Then Next
Then download your kit. We'll deploy it on a to-be-created Mica container.
Click on Next the last time, and keepthe window open. Once we have the Mica set up, we can see traffic arriving on this page.
The messages will display where the red arrow is in the image above, once we configured the Mica.
Configure the Mica
For this exercise, create a fresh Alpine container, called AWS.
Enable DHCP for IPv4.
First change the default root password.
passwd
We're going to use AWS' javascript test package. Install node.js on your container:
apk update apk add --upgrade apk-tools apk upgrade --available apt-get add nodejs apt-get add curl
Test the install
node --version
go to your home directory, and create a subdir clled aws.
cd ~ mkdir aws cd aws
Move your downloaded tst kit to that folder. I used winSCP and the SCP protocol for that.
Then execute the list of commands that are listed on the AWS page that you left open from the previous activities.
unzip connect_device_package.zip chmod +x start.sh ./start.sh
Hooray! Messages arrive.
Also send a message to the device:
Stop the application after some time with ctrl-c, to avoid an AWS invoice!
Happy messaging.