X
Popular Searches

How to Program Your Own Dash Buttons with AWS

IoT Enterprise Button

While Dash buttons may have been discontinued, their design lives on with AWS’s IoT Buttons. Instead of ordering junk food, these can be set up to trigger AWS Lambda functions, allowing you to script your own functionality with NodeJS and Python.

What Does the IoT Enterprise Button Do?

The concept is pretty simple. You press the button, and it triggers a Lambda function, which is a serverless application that runs in the the Amazon Web Services cloud and executes whatever command or script you want it to. For example, you could have this button connect to the LIFX API to control your smart lights, or any other smart device that has an API. You could even have them connect to your Amazon account to order products for you, completing the circle and creating your own dash button. The possibilities are really up to you; as long as you can program, you can make this button do just about anything.

What’s even better is that the button has three modes—single-click, double-click, and long-press—which is passed to the Lambda function and can trigger different actions based on the press type. This essentially turns this one button into three with the alternate modes.

They’re a bit pricier than the $5 Dash buttons, coming in at $26 a piece. This is probably due to the fact that the cost isn’t subsidized by you feeding Amazon money just by pressing it. But for how useful these things are, that’s not a bad price, even compared to similar less-featured smart home buttons. You can pick them up on (you guess it) Amazon.

They’re great, and were actually surprisingly simple to set up and get working. The main issue though is the latency—because these things are designed to run off a single battery for thousands of presses, they stay in low-power mode until you press them. Because of this, it takes about four seconds for the button to turn on, connect to Wi-Fi, and trigger the Lambda function. Depending on your use case, this can be a dealbreaker, but I’ve been using one to control my smart lights in lieu of an automation hub and haven’t found it to be too annoying.

AWS makes a few types of these IoT buttons, but the IoT Enterprise button is the upgrade version of the old “IoT Button”. Most notably, it’s much easier to set up and manage deployments through AWS’s “IoT 1-Click” service without having to install or manage certificates. At $20 a pop, and being small enough to fit in a pocket, these buttons are great.

AWS also makes an LTE variant of this button, in conjunction with AT&T. Due to the nature of setting up a Wi-Fi based-IoT device like this, it’s not very feasible to give the standard IoT Enterprise buttons out to remote clients without configuring the buttons on-site on their network. It’s a bit pricier, at $40, and is quite a bit bigger, but will work anywhere there is cell signal, and is reportedly a lot faster than the Wi-Fi-based variant. The setup for these should be mostly the same, as they use the same backend under the hood.

Either way, you can’t really proceed with setup until you order one, so you’ll probably want to bookmark this page for later, and come back in a few days once it arrives.

Setting Up an IoT Button

Once your button arrives, download the IoT button setup app for iOS or Android. This acts as a scanner that will link buttons to your account. This requires you to be on the same Wi-Fi network as them, which makes setup super simple for the IoT Enterprise buttons.

Open the app, sign in with your AWS account or IAM user credentials, and select “Configure WiFi” under the IoT Enterprise section:

Select "Configure WiFi" under the IoT Enterprise

This will bring up a scanner which will ask you to scan the device ID found on the packaging of the device. Once scanned, you’ll have to claim the devices, and put them in pairing mode by holding down the button for 6 seconds. This will connect to the device over Bluetooth, and configure it with the WiFi credentials you’ve chosen.

Claim you button by pressing the device for 6 seconds

You can add any number of devices this way, and if you’ve already set up your IoT project, you can add them directly to it from the app.

If you’re just following along, you’ll have to create a project to configure the settings for your devices and handle placements. Head over to the IoT Console in your browser, and create a new project under Manage > Projects:

create new project

Give it a name, then move on to the next screen. The first thing you’ll need to add is a device template. This basically defines the type of device you’re deploying, and what action it triggers when it’s pressed. If you’re just configuring one device, you’ll still need to create a template to add it to. If you have multiple devices, you can create multiple-device templates for different actions, or add multiple devices to the same template to have two buttons that do the same thing.

Your options are sending SMS, email, or triggering a Lambda function. You’ll probably want to trigger a Lambda function, so select the function here. Annoyingly, there’s no option to refresh this list, so if you just created a Lambda function for this template, you’ll have to refresh the page and start the project setup over.

add device tempalte and select lambda function

That should complete the project setup. On the next screen, choose to add a new “Device Placement,” which basically associates a physical device with a device template and project, and is used to track devices in the field.

create placement

Once that’s done, the button should be connected. If you press it, it should run your chosen Lambda function, and generate a new press event in the log. If it’s not working, you should test your Lambda function to make sure it’s not an issue with that, and make sure the press is showing up in the log.

The press information is passed to the Lambda function in the event parameter of the handler function:

{
  deviceInfo: {
    deviceId: 'G030PM037162UXE3',
    type: 'button',
    remainingLife: 99.05,
    attributes: {
      projectRegion: 'us-east-1',
      projectName: 'LightSwitch',
      placementName: 'BathroomLightSwitch',
      deviceTemplateName: 'DeviceType'
    }
  },
  deviceEvent: {
    buttonClicked: { clickType: 'DOUBLE', reportedTime: '2019-12-22T04:32:28.325Z' }
  },
  placementInfo: {
    projectName: 'LightSwitch',
    placementName: 'BathroomLightSwitch',
    attributes: {},
    devices: { DeviceType: 'G030PM037162UXE3' }
  }
}

The most useful thing here is the deviceEvent and clickType, which you can use in your function to do execute different actions depending on whether or not the user single-clicked, double-clicked, or long-pressed. If you ignore this value in your script, all press types will be the same.

From here, programming it is up to you. You can read our guide to working with Lambda functions to learn more.

Anthony Heddings Anthony Heddings
Anthony Heddings is the resident cloud engineer for LifeSavvy Media, a technical writer, programmer, and an expert at Amazon's AWS platform. He's written hundreds of articles for How-To Geek and CloudSavvy IT that have been read millions of times. Read Full Bio »

The above article may contain affiliate links, which help support CloudSavvy IT.