Skip to content

Part 2. Finding the Button's Address

Rachel edited this page Sep 19, 2017 · 6 revisions

Step 1: Install Node JS

To find (and subsequently use) your Dash button's hardware address, we need to use Node JS. This can be installed on any computer - Mac, Linux (Raspberry Pi), or Windows.

Our final project hinges on having a computer that's connected to the same network our button is running an uninterrupted Node script, so keep that in mind when choosing your device. An at-home desktop or Raspberry Pi would be perfect.

I choose to use a Pi 3, but a Pi Zero with a WiFi dongle would work too!

To install Node JS on your computer, follow the appropriate instructions:

Step 2: Install Node-Dash-Button

Alex Horton wrote a fantastic module just for what we're trying to do called node-dash-button. We need to install it, along with the node package manager (npm) and libpcap (enter these commands in the command line):

sudo apt-get install npm
sudo apt-get install libpcap-dev
npm install node-dash-button

Note: "sudo" may not be necessary if you're installing on something other than a Pi - it's always good to try without it first. If you get a permissions error on install, then you need to use it.

Step 3: Find the Address

To actually find the button's address, we need to run the "findbutton" script inside of the node-dash-button module we installed:

cd node_modules/node-dash-button
sudo node bin/findbutton

You will see something similar to the following start printing in your terminal:

Watching for arp & udp requests on your local network, please try to press your dash now
Dash buttons should appear as manufactured by 'Amazon Technologies Inc.'

Possible dash hardware address detected: f8:04:2e:2b:eb:45 Manufacturer: SAMSUNG ELECTRO-MECHANICS(THAILAND) Protocol: arp

Press the Dash button and look for a listing with Amazon as the Manufacturer:

Possible dash hardware address detected: 48:51:b7:55:69:14 Manufacturer: Intel Corporate Protocol: arp
Possible dash hardware address detected: 34:e6:d7:1b:ba:ea Manufacturer: Dell Inc. Protocol: arp
Possible dash hardware address detected: b8:e8:56:32:c5:94 Manufacturer: Apple Protocol: arp
Possible dash hardware address detected: 48:51:b7:55:69:14 Manufacturer: Intel Corporate Protocol: arp
Possible dash hardware address detected: ac:64:be:8b:ce:86 Manufacturer: Amazon Technologies Inc. Protocol: udp

Stop the script when you think you see your button on the list with Ctl-c. You may have to push your button a couple times if there are multiple Amazon listings.

The address that we're looking for is "ac:64:be:8b:ce:86".

Step 4: Testing Button Presses

You can confirm that you found the correct address by writing a simple script to print a message every time the button is pressed.

Create a new script inside of the node-dash-button directory (where you should still be after scanning for the button's address):

sudo nano button_test.js

And copy-paste the following into the file:

var dash_button = require('node-dash-button'),
    dash = dash_button('xx:xx:xx:xx:xx:xx'), //REPLACE WITH YOUR ADDRESS
    exec = require('child_process').exec;

dash.on('detected', function() {
    console.log('Button pushed!');
});

Replace the x's on the second line with your newly found button address. Save the file with Ctl-x, y.

Start the script and press your button. You should see "Button pushed!" print out.

sudo node button_test.js

Now that we can detect button presses, we can trigger actions based on them!

<< Part 1: Setting up the Dash Button - Part 3: Triggering an Alert on a Press >>