• For devs

Hardware Fun: Building An Email-Controlled Gun For PyCon 2013

Mailgun Team
5 min read

We don’t sponsor (or attend) many conferences at Mailgun. In fact, to this date we have only sponsored one, PyCon. We make an exception for PyCon because it has always felt like the perfect conference for Mailgun.

First and most importantly, Mailgun is built primarily using Python. Second, the conference lacks a lot of the BS that most conferences have. It serves as an admirable juxtaposition to SXSW every year. It is about building stuff and advancing Python. We have yet to make it to SXSW but we make a point of being a sponsor of PyCon every year.

Getting ready for PyCon

This year we wanted to do something a little more interesting than just showing up with T-shirts and stickers. We wanted to stand out a bit. It’s hard to compete with HP’s free beer but we thought if we could come up with something in the spirit of the conference we could attract some attention beyond the t-shirt vultures.

We thought of a few ideas for swag we could order but that didn’t really excite us. What did excite us was building a real life Mailgun. We came up with the idea of building a sentry gun that was triggered by sending an email through Mailgun. It allowed us to demonstrate a use case (albeit a very obscure use case) for Mailgun and, as one of our visitors mentioned at our booth, it served to “bring the software into the physical world”.

Getting beyond the idea phase

We started with the idea of using a paint ball gun. After a quick check with the conference organizers we realized our lawyers may not like that idea. So we ended up settling on a nerf gun. Contestants could trigger the gun by sending an email to a Mailgun Route. The Mailgun Route would accept the email and POST to a web service which would then signal the gun to fire. If the gun hit a target, the contestant would win a t-shirt. You had to earn the T-shirt at the Mailgun booth.

The first big hurdle was that we are not hardware hackers and we didn’t have a lot of time to figure it out. Fortunately, we knew some folks from YC that could help us out with that, Upverter.

Upverter offers cloud-based engineering tools and they had a big network of hardware folks. We asked them if they could help us out. We gave them a lot of leeway on the design and materials and in a few days they had spun up a contest to build the “Mailgun”.

Upverter makes the idea a reality

In a couple weeks Upverter had three submissions and this winning design.

Below is summary of the design process from Upverter:

We settled on the Nerf Vulcan Rapid Fire EBF-25 since it had a full automatic mode. With the gun chosen, the requirements were posted:

  • Develop hardware and software to pan the gun using a servo motor, and fire it using a relay.

  • Bonus points for using Python, since it would be demoed at a Python event.

The final design used a Raspberry Pi running a Flask web server. MailGun was used to make POST requests to this server, which would fire the gun. Other post requests could start and stop the panning action of the gun.

The pi-blaster library for PWM was used to control the servos and ensure that the timing on the trigger pin would fire a single bullet.

The source code for the design is available on Github.

The mechanical design used a tripod for support, and a simple gearbox allowing the servo to rotate the gun. It would continuously pan, firing a dart when an email was received. Firing was handled by the gun’s stock mechanism, using a relay to fake the trigger signal.

80/20 rule rears its ugly head

The gun and other hardware arrived the Tuesday before Pycon mostly assembled and ready to go. Although, as we thought further about how this would actually work, we realized we had a few more challenges to deal with.

1) How do we automate the target? We could put up some kind of target and just watch to see if it hit but that is kind of lame. Someone would have to sit there and watch and there could be distractions.

2) We needed a queue for submissions. There could be multiple people submitting emails at nearly the same time.

3) We needed a way to tell people where they are in the queue and who won.

4) Network access could be tricky at the conference venue. The Rasberry Pi IP address may not be publicly accessible so submitting an HTTP POST to it may not be possible.

Like most things, the last 20% of the project included a lot of details that needed to be sorted out. Unfortunately, we only had two days.

Luckily, one of our brilliant engineers, Anton, had just arrived from Russia and he sprung into action. Here’s the design he came up for the system.

Anton set up a web server and wrote an application to deal with most of these challenges. The web app would queue submissions and display the queue and the winner in a browser. We could then just connect a monitor to any computer to show the contestants the status of their submission. Also, the web app would enable the Rasberry Pi to poll the web server for submissions rather than having to accept POSTs.

Anton practicing poor gun safety while working on the gun.

In a genius move, Anton came up with the idea of using an android tablet as the target. The device’s accelerometer would trigger a hit and then it would POST to the web app. It had the added benefit of being able to display the Mailgun logo on the screen as the target.

Anton also added some nice touches like the protective lego case around the Raspberry Pi.

The gun was a pretty big hit at the conference. We had over 400 submissions and a lot of winners. Perhaps we made it too easy.

Also, the gun gave us the added benefit of being able to screw around when it was slow during sessions. Here’s Anton with a devilish grin while turning the gun into automatic mode.

Yes, the whole contraption was a bit of a Rube Goldberg machine hack but it sure was fun…and that’s kind of the point of Pycon.

Last updated on August 28, 2020

  • Related posts
  • Recent posts
  • Top posts
View all

Always be in the know and grab free email resources!

No spam, ever. Only musings and writings from the Mailgun team.

By sending this form, I agree that Mailgun may contact me and process my data in accordance with its Privacy Policy.

sign up
It's easy to get started. And it's free.
See what you can accomplish with the world's best email delivery platform.
Sign up for Free