When Amazon first launched the Dash button back in 2015, I doubted that I'd be able to find a place for them in my life. While I fully expect the Internet of Things to take over aspects of my day-to-day in the next few years, I'm still quite happy (for the time being at least) to take a trip to the shop for kitchen roll, shaving foam and other such household items. Hence, you'd be unlikely to see one of those buttons in my house.
That all changed after a fun and insightful #ODIFridays broadcast in December, which showcased some stuff their labs team had been working on. In this session, the ODI's Stuart Harrison talked about developing a modern day version of a star chart for his son using a Raspberry Pi and a couple of these dash buttons (you can watch the video on YouTube and read more about how achieved this on Hacker Noon). It turns out that it's actually relatively simple to capture a dash button press and do something more interesting/useful than you know, buy stuff. So, armed with this knowledge, but with no small children to quantify, what could I build with it?
As it happened a suitable problem presented itself sooner rather than later. One of my relatives has recently been prescribed some new medication which needs to be closely monitored by the doctor. However, as it is also 'take when required' we needed a way of recording when it was being used.
The original plan to write down the dates and times on a notepad proved to be more problematic than initially thought. Paper can go missing easily, scribbled notes can be misread and most importantly, we all know you can never find a pen exactly when you need one. Given the desire to simplify the process and the need for accurate recording, I thought that this would make a good pilot project for a dash button. After digging out my old Model 1 Raspberry Pi and installing an up-to-date version of the OS, I started to tinker around following the instructions from Stuarts blog.
Putting it Together##
node-dash-button library which makes the magic happen runs on Node.js. This depends on
libpcap for sniffing network traffic, so the first step was getting all of those set up on the Pi. That took a little longer than anticipated due to some installation issues but eventually I got the Raspberry Pi to play ball.
From there, the dash button needed to be configured to connect to wi-fi, which is done through the Amazon mobile app. Once connected, the app asked me what product I wanted to link the button to. At this point, I just closed the app, as I didn't want the button to be setup to make purchase requests (that would get expensive pretty quickly). I then needed to determine what the MAC address of the button was, by running
node-dash-button/bin/findbutton from the Pi. This handy utility sniffs the network for traffic from devices, so you can work out the MAC address of the buttons as you press them. Armed with this information, I was then able to code a simple node application which would react when the buttons were detected on the network.
For this use case, the button sends a simple request to my account on IFTTT, a service that allows you to build custom actions across numerous web applications and IoT devices. These applets are a quick and simple way to connect a number of internet based actions in a straightforward 'If This, Then That' way (hence the name).
When the account receives the request, it will send the date,time and medication information to an online spreadsheet which can then be shared with nurses and medical workers as required, as well as viewed on my relatives tablet during home visits. It also sends a notification to my phone when the button has been pressed. Once I had tested the button, I then had to reconfigure the button to work on my relatives home network. At first, it wouldn't work, but after some intense
Googling/troubleshooting, I found that the dash button only supports a 2.4GHz wi-fi band. This was easy enough to fix by enabling this on the router and the button connected first time.
I added a script to the Pi that would automatically start the application on boot, in case it crashed or there was a loss of power. It was then installed in an unobtrusive corner of the flat, ready to go.
Results and What Next?##
The all important button was attached to the medication case (they have a handy adhesive on the back which is perfect for this) and I waited to see if it would work out. We kept a paper and pencil record as a fallback and I could also check the console logs if the IFTTT link stopped working for whatever reason. However, the service has worked every time so far, and the end users are very happy at how easy it is to track and monitor the information now.
The code, which I'll be putting up on GitHub when I get a chance is pretty straightforward to adapt for your own purpose. With the combination of applets available on IFTTT there are a huge number of potential applications to try. Some fun examples are mentioned on the node-dash-button page but I'd be interested to hear about other examples or suggestions, especially from a museum/cultural heritage perspective, as I'm keen to see what could be achieved with these in this area. Suffice to say, it's likely this may not be the last dash button in my life.