Connect All the Things: An IoT Nerf Gun

Introduction

As part of my foray into the Internet of Things (IoT) I was looking for a project I could sink my teeth in because I find it easier to learn something by doing it rather than just reading about it.

It just happened to be that at JavaOne this year they will have a Maker Zone, and they were looking for participants who could build something interesting to show to the attendees.  As a regular visitor of the MakerFaire in my back yard, this immediately piqued my interest, and after rummaging through my 9 year old son’s toy boxes, I decided that I wanted to mod one of his Nerf guns.

This blog post will detail what I did and how I did it.

My plan was to turn the Nerf gun itself into an internet-connected device that would then allow me to poll its status (online/offline/launching) and to launch darts remotely, just using an internet connection.

To make my life a little bit easier, I started with a semi-automatic Nerf gun called NERF N-STRIKE MODULUS ECS-10 BLASTER.  All the user has to do is start the flywheels and then pull a trigger which pushes the foam darts (using a lever and push rod) between the 2 fast-spinning flywheels, which ensure the speedy exit of the dart from the barrel.

Internals of an unmodified Modulus Nerf Gun

Internals of an unmodified Modulus Nerf Gun

Instead of having the user start the flywheels and pull the trigger, I had to use some electromechanical solution for both.  Let’s talk about each solution individually.

Flywheel Control: Relay

This component is, strictly speaking, already electromechanical: when the user pulls the flywheel control trigger, s/he is actually physically pressing a button (hidden under the orange lid right behind the flywheel control trigger) that starts up the flywheels.

All I had to do was replace the mechanical button with one that I could control electronically, e.g. a relay. I could have opted for a transistor as well but decided to go for the relay as I like the satisfying “click” sound they make when activated 🙂

I will show later how this was actually done.

Trigger: Servo

The trigger mechanism on the other hand is completely mechanical, and I had to replace this with some sort of electronic component in order to be able to control it electronically.  The actual trigger movement is very small, but it is “amplified” by the lever it is connected to.

This lever then pushes a rod forward, which is what makes the dart squeeze between the flywheels.

My initial thought was to replace the rod with some sort of push solenoid, but those typically have a very small stroke, too small for this purpose.  I also looked at very small actuators but they suffered from the same drawback, plus they were also very expensive and relatively slow.

So instead, I decided to replace the trigger with a servo that would control the lever.  The axis of the servo would sit inline with the axis of the lever so when the servo turns, it turns the lever, exactly what happens when you pull the trigger.

Internet Connection: ESP8266

The final component of the build was to put the Nerf Gun on the internet.

For this is decided to settle on the ESP8266 chip, more precise the ESP8266 ESP-12 variant. Besides being a wifi chip, this also has several GPIO pins that I use to control both the flywheel relay and the servo with some to spare for other components I might want to add later, e.g. a darts counter, range finder, etc.

Unfortunately the chip runs on 3.3V, and the Nerf gun supplies 6V (4 x 1.5V AA batteries) to the flywheel motors. So I either had to use another battery that supplies 3.3V or tap into the 6V and step it down to 3.3V.

I actually tried both, but in the end opted for the latter, as it simpler to just replace 1 set of batteries when we run out than 2.

Also, if 1 set of batteries runs out, the other part becomes completely unusable as well, so there is no benefit to having separate power sources for that either.  This complicated the build, but certainly benefited the UX. Hey, I am in UX after all.

Breadboard Schema

Breadboard layout of IoT Nerf Gun

Breadboard layout of IoT Nerf Gun

I hope this is rather self-explanatory.  Note that you have to connect CH_PD to Vin/Vcc, otherwise the chip doesn’t power up.

Also GPIO15 has to be connected to GND. If the ESP module doesn’t come preinstalled with Lua (mine didn’t), then you have to flash it first with Lua.

This is outside the scope of this article and there are plenty of articles on the internet explaining how to do this but be aware that if you need to do this, you have to pull GPIO0 (that’s GPIO zero) to GND and pull GPIO2 to HIGH.

Then, once you have flashed it with Lua, you have to disconnect these connections, and you can use both pins for controlling other things.  Also, in order to upload anything to the ESP8266 you need to use the TX and RX pins and a USB to TTL (Serial) adapter, e.g. FTDI.

First Build

For my first build, I actually used a NodeMCU board which is a breakout board for the ESP8266-12 that includes a 5V->3.3V power converter, reset and flash buttons and is breadboard compatible, unlike the actual ESP8266 which has a 2mm pitch rather than 2.54mm, making it easier to breadboard with.

However, it is much larger than the naked ESP chip and I had a hard time containing it all in the Nerf gun. One of my objectives was to keep the Nerf gun “plain” looking.

IMG_5954

NodeMCU Dev Board on the left, ESP8266-12 on the right

I started with the servo integration as I figured that was the hardest.  Integrating the relay should be relatively easy compared to that.  Here is a Vine video with my first working version of the ESP8266 and the Servo motor attached, using a crude web service:

I then modded the gun to accommodate the servo. As the servo was too big to fit in the gun, I had to cut a hole in the side of the gun and hot-glue the servo in place.

I tried a few micro servos first but none of them were powerful enough to push the dart, and also, they didn’t fit either.

I then modified the lever so that the servo could control it.  This meant I had to shorten the axis of the lever and cut 2 slits which could then be gripped by the servo.  As the servo turns, so does the lever, does the dart gets pushed by the servo between the flywheels:

ModdifiedGripper

At this point, I was also using all sorts of connectors to connect the battery to the different motors and ESP.

I thought that this would make it easier to route all the cables in the Nerf gun and later disconnect everything if I need to open the gun.

However, this turned out to not be the case and in later iterations I just soldered the connections straight to the necessary components, with as short a cable as possible, with the exception of the servo connection as the servo was the only component that was physically connected to the other part of the Nerf gun.

This way, if I did have to open up the Nerf gun, I could still disconnect the halves from one another.

Final Build

As you can see, this yields far less cable to deal with and it is easy to close the Nerf gun this way, with room to spare.

You can also see that at this stage, I added an externally accessible connector that connects to RX, TX and GND of the ESP chip.

This allows me to debug and reprogram the ESP chip without opening the Nerf gun!  This has proven to be exceptionally useful, as you can imagine. There are 14 tiny screws holding the nerf gun together.

I also disabled one of the safety mechanism on the Nerf gun so I can fire it without closing the jam door on top of the Nerf gun.

This made it easier to debug some issues I had with the serve not pushing the darts correctly through the flywheels and jamming the Nerf Gun.  Here are a few more Vine videos of the IoT Nerf Gun in action.

This one shows the servo pushing the rod from the inside:

And a view from the top with the jam door open:

In the second part of this blog post, I will go into more detail about the software I wrote to control the Nerf gun.

One comment

  1. Incredible! I just got an ECS-10 and very much looking forward to taking inspiration from this build. Great job.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.