I bought a few Amazon Dash Buttons as part of Prime Day. These are the cheaper $4.99 buttons, not the more expensive $19.99 AWS IoT Buttons. In this blog post I’ll walk through how to make these cheaper buttons do what the more expensive button does.
What You Need
- One or more Amazon Dash Buttons. You’ll need to add the button to your Amazon account, but do not pick a product to buy. Just exit the set-up process without picking a product and you’ll be all set.
- Computer with root (sudo) access (or RaspberryPi or other device capable of running Python).
- The code from GitHub.
How exactly does the dash button work? In a nutshell, every time you press it, the button connects to the Wi-Fi network, pings Amazon, and then shuts back down for power savings. We’ll exploit the first step in that process – connecting to the Wi-Fi network. Using Python, we can listen for special “ARP probe” packets the Dash Button sends when it attempts to connect to Wi-Fi. All you need to know is the MAC address of the Dash Button and then listen for these ARP packets. When an ARP packet with your Dash Button’s MAC address is detected, you know the button was pressed, and you can call whatever Python methods you want.
Finding the MAC Address
The first step once you’ve set up your Dash Button (but have no picked a product to actually buy!) is to find the button’s MAC address. Grab your computer and connect it to the same Wi-Fi network as your button, then run the pydashbutton.py script as root and watch for any MAC addresses that are printed when you press the button. One important thing to note is that there seems to be throttling when pressing the button. Pressing the button multiple times per minute might not work.
Running Methods on Button Press
Now that you have the MAC address to listen for, all you need to do is throw some if/else logic into that same listener script to run code when a MAC address is detected. Check out the script and make any modifications you need. I included a simple example for logging button presses to a Google Sheet when pressing a button.
Check out the code on GitHub. Have fun!