AWS IOT Button is basically used by the developers in order to program based on Amazon Dash Button hardware. You need to connect to Wifi network in order to make the button work. I just got this button and thought to do something with it. So the first step that I need to do is create my AWS account. Once the account is created I can log into AWS IOT console.
One thing I found is that AWS IOT is not available in Canada (Central). Hence I have selected another region US East (Ohio). Here I am going to show you step by step instructions of how to setup the button.
Step 1: In AWS IOT Console, select Registry => Things and then Register a thing
Using Register a thing, we are going to create a button. Provide the button name
You can associate a thing type from the optional configuration dropdown. However if there are no thing types, you can create one. In this case I am creating a thing type named IOTButton
Having done these steps, the thing gets created.
Step 2: Next step is to create the Policy for the device which is IAM policy which will state the security, resources that can act on with the button.
Select Policy from the console and create a new policy. You can use an existing policy also.
In Policy creation page, you can select the action types that you would like to perform. Here I am going to add two actions one is iot: Connect for Connecting the device to the gateway and the other one is iot: Publish for Publishing the button to specific topic.
For action = iot:Connect, I will update the resource URL to *.
For action = iot: Publish, I will update the resource URL to arn:aws:iot:us-east-2:597248753215:topic/iotbutton [which is the thing type we have created]/[DSN Id present at the back of your device]
You can view and edit the policy that got created.
Step 3: Next step is to create a certificate for the device since in order to connect to IOT gateway we need a certificate and a key pair.
Let’s create a certificate
Download the certificates and later on we will upload those certificates to the button
Step 4: Activate the certificate. Once done, we need to select the certificate and associate it with the thing for the button.
Associating the certificate will add identity to the button.
Now attach the created policy to assign some permissions to the identity
Now we have the thing which has the certificate and policy attached to it. Now we should be able to configure the device and send MQTT messages to the gateway.
Step 5: Now to configure the button you need to press the button for 5 seconds. You should see the button blinking.
The password should be the last 8 characters from the DSN id at the back side of the button
Use 192.168.0.1 to configure the button.
Upload the certificate
Upload the private key
Enter the IOT endpoint which you can get from IOT Console => Settings.
Select the endpoint region. In my case it is us-east-1.
Step 6: Now since the device is configured, now if we push the button, we should be able to see the messages. So let’s dive down how we can see the messages.
Here for testing purpose we can go to the Test console of AWS IOT console.
Then subscribe to the topic. The URL here should be Topic name/full serial number of the button.
Exception: One of the issue I was facing was that the device was not able to communicate to the gateway since during the configuration, I have tried to use the access point of my mobile. I just went ahead and re-configured with Step 5, made the access point as my home wifi and also the endpoint region to us-east-2 even though the region was not displaying in the drop down.
You can see the exception in the IOT console.
Once I did the changes, I went ahead and pressed the button once. It blinked for few times and then displayed a green light which shows the communication was successful and message had been sent.
You can test different types of click events for the button.
Message for 1-click:
Message for 2-clicks:
Message for long-press like (2 Seconds):
You can also use another testing tool called MQTT.fx which is pretty easy and can be used for demo purpose as you don’t necessarily required to log into IOT console. Check out this post of how you can connect to MQTT.fx to AWS IOT