Sunday, January 31, 2016

Party Button Version 1 Amazon Dash Hack

I previously blogged about the Amazon Dash button hack here and here. I decided to step up the Dash button game a bit an create something cooler. Introducing the Party Button.

I have been messing with relays and the Arduino this weekend so I decided to incorporate all that fun into a Party Button using the Amazon Dash. When you start a party a python script is started that sends a signal to the Arduino to fire up the relay. The Relay controls an outlet that has party lights and a stereo receiver atached to it. Everything is powered on and then the Python script will pick out a random song and start it up using VLC command line.

Python Script

I used python to setup the ARP sniffer (needed to sense when the Amazon Dash Button was pressed), pick out a random song from a directory, send a signal to start the relay using the Arduino, and play the selected song using VLC.

I had to send the off command (HIGH signal or 1) to the relay at the start of the script because when you activated the Serial port using Python it would automatically reset the signal to the Relay causing it to come on. So I set a sleep command to sleep 5 seconds and then send the off signal to turn off the relay.

Since the ARP sniffer required Linux to work properly (scapy library works out of the box in Linux) a nice side benefit was the fact I could send a signal directly to the serial port using the pySerial module.

Party Button Test Rounds

So we went through a few test rounds of the Party Button. I uploaded the video to YouTube. You can see I had 2 handy wingmen helping me with the testing.

Saturday, January 30, 2016

Arduino Relay Outlet

Finally started to dabble with relays and AC power. Insert the normal when you are playing with power you can die warning here. Make sure you know what you are messing with before proceeding.

My end goal is to have 8 outlets that I can turn off and on. This post will show you one outlet.

Parts List

Helpful Article

There are tons of articles out there on how to hook up a relay to an Arduino, however it seemed most were lacking detail. I finally stumbled on this awesome article and was able to adapt it to the 8 Channel Relay:

Specifically this image. I spent a ton of time trying to find something like this.

The pic above is what I ended up with.

  • Hot wire (black) from power cord is wired to common (middle terminal) on the relay.
  • Connect hot wire (black) into NO terminal of Relay and connect it to hot terminal (gold) on your outlet.
  • Ground wire (green) from power cord connects to Ground (green screw) on outlet
  • Neutral wire (white) from power cord connects to Neutral (silver screw) on outlet
  • From Digital Out 7 on Arduino to IN1 on Relay module. IN1 is the first channel
  • From VCC on Relay to 5V on Arduino
  • From GND on Relay to GND on Arduino

You will want to make sure your connections look cleaner than the above screen shot. I went back and cleaned them up and added some electrical tape reduce the risk of a short and or shock.

Arduino Code

You can test the relay before adding the juice, to make sure your wiring is correct. This script will turn the relay on wait a little bit, then turn it off. It will cycle through like this in a loop so you can test it out.

From here you can get more advanced and trigger the relay based off other conditions such as sensor output, etc.

This is my first step towards working with Christmas light automation. I am also working on an Amazon Dash Party Button hack that I will blog about shortly.

Wednesday, January 20, 2016

Link Dump 1/20/2016


Here at the office we have a never ending, pretty much daily Nerf Gun War. The battles typically start without much warning when someone fires a shot in your general direction. We have a vast assortment of Nerf Gun and ammo to choose from.

To liven things up a bit some co-workers also bought a thunder pack of smaller Knockoff Nerf Footballs from China. Throughout the day a football will enter your airspace without warning. Thus the need for MAWS

Missile Advanced Warning System

I wanted a way to know when a missile or other large object was incoming to give me time to duck or at least brace for impact. I also wanted a reason to order some PIR sensors for the Arduino. I was the lucky recipient of an Amazon gift card for Christmas so I quickly ordered a pair of sensors.

Hooking the sensors up to the Arduino was a cinch. Basically I just wanted to light up an LED when the sensor noticed movement. The sample code worked perfectly. All I had to do was add another set of variables to control the second sensor. MAWS is outfitted with two PIR sensors for double, that's right double the motion sensing power.


Inital testing indicated that there was little chance MAWS v1 would pick up the Nerf Elite Strike darts. These darts are small and travel fast (especially from the modified Nerf Guns in the office) to be detected by the 2 dollar PIR sensors I purchased.

The NERF Mega darts are also too small to be detected. The MAWS system did pick up a few shots from the Mega darts but the success rate was very low.

Larger projectiles were detected...sometimes.These include Nerf footballs and other various soft projectile type objects.


No fewer than 5 minutes were spent in MAWS construction. This is all prototype so nothing fancy was needed. I grabbed a couple cardboard boxes and a box cutter. Since this was a prototype I decided to just tape together wires with electrical tape to extend the reach of the LEDs.

I taped the LEDs to the top corner of my monitor and ran the MAWS system up to the top of my cube. I moved it back a little so the MAWS system would not pick up my movements for false positives.


The MAWS system is performing at least as well as in the initial testing. I'd say the success rate is about 2.5% just spit-balling. I'd call that a successful project (considering my past projects). I mean imagine if 1000 projectiles are being thrown my way. That is 25 projectiles that are successfully identified before impact...not bad.

It has been a good conversation piece if nothing else. Also it functions well as an advanced warning system if a visitor walks up behind me. So all and all not a bad project.

I imagine if I swing for some more pricey sensors I would have a bit more success.

Desk Cycle Bike Race

A buddy of mine at work purchased a Fit Desk Under desk Elliptical trainer. You may recall another buddy of mine (Chad Bisher) has one and uses it to illegally win FitiBit Workweek Hustle challenges. Anyway, intrigued I wanted to try it out when it arrived.

I immediately determined this is something I'd like to purchase. As luck would have it Chad Bisher's wife, the doc, had purchased a Desk Cycle but rarely used it and was willing to sell it to me.

I quickly installed it and got it adjusted to my work area and started pedaling. Of course in true thejoestory fashion I was not satisfied with merely riding the bike and receiving the health benefits. I quickly challenged my co-worker to a competition. A virtual bike race to various destinations in the world. We will see who can pedal the farthest, the fastest, etc.


Thus the Bikerace website was born.

Our first destination was Chicago from our HQ here in Kansas City. I am not sure why or how I picked Chicago. Anyway we started tracking metrics: Miles, Time, Calories burned. Progress to the goal was displayed on the site.

I decided to use the bootstrap framework for this site. I have been using foundation a lot and wanted to change things up a bit. Bootstrap has a lot of features to offer. We will see how it goes.

One thing we noticed right away was the difference in speed calculations between the two bikes. The FitDesk seems to measure speed differently. My co-workers speed was registering 5 MPH faster than the Desk Cycle.

We both tried the other person's cycle and the results were similar. Therefore I will add a modifier to my buddy's distance. As you can see in the screenshot...I have ridden over 2 hours more than him and I am only 9 miles ahead of him to Chicago.

Anyway I will tweak the numbers and see how it goes.

Future Plans

I would like to pinpoint where we each rider is located along the route based on miles. I have not figured out how to do that on Google Maps yet. I need to figure out how to do Lat/Long math along a path given a specific bearing. Should be an interesting challenge.

Other than that we just have to come up with where we want to ride next. By the time the Tour de France rolls around we may mimic some of the legs by cranking up the resistance on the bike for the mountain climbs and such. Yes I know it is nothing like the real tour...just something fun to try.

Monday, January 4, 2016