Lessons Learned From Building an IoT Flamethrower Tank

tank-banner

Background

This project all started because I’m lazy and I hate yard work.  My goal with this project was to create a tank with a small weed torch (flamethrower sounds much more intimidating) that I could remotely drive around to burn any weeds that had the nerve to grow in my yard.

Disclaimer:  this should go without saying, but obviously a remote controlled flamethrower can be very dangerous!  Don’t try copying this & then blaming me if something goes wrong!

Since I had already worked with a Raspberry Pi for  my home arcade cabinet, I figured an Arduino microcontroller would be a good fit for this project. As an added bonus, it gives me a better understanding of a core component for future Internet of Things (IoT) projects.

Don’t feel like reading the whole article? Skip to the video and photo gallery!

Design Progression

  • Concept 1 – The controller was actually hard wired, I had the wrong types of motors, and this was pieced together with mostly spare parts.  This is a very sad looking “tank” – but I didn’t burn the house down, and it motivated me to put more time into it

tank-concept1

  • Concept 2 – This was using a simplified Android app that I wrote which sent commands over Bluetooth.  A Bluetooth receiver was hooked up to the Arduino to process the commands.  The frame was a little flimsy, and trying to send commands from the smartphone was not very user friendly.

tank-concept2

  • Concept 3 – The first fully working version!  Commands are now sent with an Xbox controller and there’s a USB Xbox wireless receiver which relays the commands to the Arduino.  Still not perfect, but it’s very close to being functional.

tank-concept3

 

Lessons Learned / Complications

  1. The Arduino IDE is a bit painful to program in, especially for anyone who’s used to an IDE with more features such as Visual Studio.  Luckily, there’s a Visual Studio extension called Visual Micro which lets you write the Arduino logic & debug your code.  I’m still trying it out, but so far it looks pretty good.  Just the Intellisense capability alone makes it worth it!
  2. Programming an Arduino is easier than I expected it to be.  The code itself is basically C++ (along with some custom wrappers), and it’s divided into 2 main sections – a setup() function that gets run once as the Arduino powers up (initialization logic goes here), and a loop() function which gets executed continuously (here’s where you can read inputs, run custom logic, then set outputs).  Obviously, as your program grows in complexity you probably want to break out the code into additional functions, but technically you only need these 2 functions to have  a fully working program.
  3. Arduino microcontrollers are amazing, and there’s a ton of variety both with the different models of Arduino’s and the “shields” (i.e. expansion boards) that are available.  I chose to use the Arduino Uno to keep the cost down – this is basically the entry level model.  I’m already starting to hit the limits of what it can do, so maybe a fancier model such as the Mega would have been better.  Halfway through the project, I abandoned my original plan to use a custom smartphone app sending commands over Bluetooth, and realized I could use a USB Host shield with a wireless receiver to process commands from a wireless Xbox 360 controller.  If you’re thinking of starting an IoT type project, I’d suggest researching the processors, shields, etc out there so you know what your options are.
  4. Now for the bad news with the Arduino shields – some of them try to use the same I/O ports.  For example, both the USB Host shield and the Motor Control shield tried to use pins 11-13, which is obviously a problem.  There are several workarounds for this.  One option is to use a Go-Between Shield to basically reroute the signals you need.  I was tempted to do this, and might have chose this option if I needed to reroute a lot of pins, but it seemed like overkill for my situation and might just introduce more failure points.  So to follow the “Keep It Simple” principle that’s popular in software development, I just decided to run jumpers to spare pins and that solved the problem.
  5. Can’t find a part you need?  3D printing is easier than you think!  There are some very complicated CAD programs out there with steep learning curves, but those are overkill for 90-95% of the situations.  For most of what I print, I use TinkerCAD – it’s web based so you do not need to install anything, you can access your designs from anywhere and it is extremely simple to use.  By making your parts partially hollow they are very cheap & quick to print.  The tank uses quite a bit of 3D printed parts, and the material for all of it was probably only about $10.  3D printers used to cost several thousand dollars, but they are rapidly dropping in price and some are as low as $250-300.
  6. OK, I’m cheating a bit on this point since I haven’t actually made the tank a true “smart”/connected device yet.  I should’ve thought about the connectivity issue a bit more up front, because one option is to use an Arduino Yun instead of the Uno.  The Yun comes with wifi connectivity built in, so it’s a great choice for IoT projects.  There are many other options to consider – one that looks pretty neat is Blynk, but I haven’t tried it out yet.
  7. Getting the treads to reliably run was much more tricky than I expected – too loose and they’ll pop off the sprocket & guides, too tight and they’ll stall the motors.  Even with the current design it’s still not great, and I’ll likely try to improve it further
  8. Configuring the USB Host shield shouldn’t have been difficult but I was referring to some conflicting & outdated information.  I finally figured it out, and posted a tutorial to help anyone else who might need to set one up.

Next Steps

  • Hardware upgrades to make it a true “smart”/IoT device.  This would enable features such as:
    • Data logging & reporting through RESTful web services on www.joshcaplin.com for reporting (total distance traveled, confirmed foliage kills, etc.)
    • Internet or smart phone integration for sending remote commands from anywhere in the world
    • Live video feeds
  • Increase speed, improve reliability for the tracks/treads
  • On/off control from the Xbox controller for the flamethrower
  • Swappable turrets for multitasking such as a beer drink delivery assistant, poor mans Roomba with a shop vac, etc.
  • Maybe a 3D printed drone with vision system to track and follow the tank?

 

Video

Photo Gallery

 

Final Words

For anyone looking to do something similar, two companies I’d suggest looking at are  SparkFun and ServoCity.  They both have a wide variety of parts, both ship very fast, and tech support for both of them are very helpful!

Hopefully this article was helpful – leave a comment below if there’s any details you want me to add, and follow me on Twitter to see my next experiment!

 

 

 

 

 

Advertisements

Configuring an Arduino USB Host Shield – a beginners guide!

I recently struggled through configuring an Arduino USB Host shield.  In hindsight, it’s pretty simple but there was conflicting information I found and I’m not an expert with Arduino development.  Below is the process I’d follow if I needed to do it all over again – this may save you some time if you’re in the same situation I was.
  • Purchase the SparkFun USB Host Shield (and header pins if needed)- part number DEV-09947.  Caution – there’s apparently an old version of the SparkFun shield, there are shields from other vendors, etc.  If you do not have this exact product, then your setup may be different!
  • Solder the pins onto the board.  Be careful not to accidentally connect adjacent pins when soldering.  I took a multimeter and checked for continuity between adjacent pins to help confirm the connections were good.  There are 2 ground pins next to each other, so you should see a connection there, but not for any other adjacent pins.
  • With the SparkFun board, it seems like you MUST supply external power on Vin or the barrel jack.  5V from the USB cable did not work for me.
  • You must also run a jumper from pin D7 to RESET.
  • The external power & jumper issues were the 2 biggest reasons I struggled with getting the board set up – these seem to be mandatory, at least for SparkFun DEV-09947
  • The code/drivers you need to use for this board are on this GitHub page.
  • I didn’t realize it at first, but there’s a diagnostic test which is extremely useful for checking whether your board is working correctly.  Upload this sketch to your Arduino, then open the Serial Monitor to see the diagnostic info.
  • Step 1 – you’ll see it recognize the board, and start a transfer test:

usb-host-shield-diagnostics-step1

  • Step 2 – you’ll see it attempt to test the GPIO pins – you’ll get a scary looking “GPIO test failed” message, but what I didn’t realize at first is that this can be ignored.  Type something in box at the top of the Serial Monitor, then hit “Send” button and the diagnostic test will continue.

usb-host-shield-diagnostics-step2

  • Step 3 – you should see it cycle through a bunch of resets, then it will attempt to detect a USB device – make sure you have something plugged into the USB port on the shield.  You should then see some summary info with a final message of “All tests passed”.

usb-host-shield-diagnostics-step3

  • Next problem I ran into – the light would not come on for the XBox wireless receiver when plugged into the shield, even though it lit up fine when plugged into my PC.  This was a rookie mistake, but I needed the correct library/driver loaded in my sketch file.  Once I did this, the device was recognized and everything worked great.  So make sure you are referencing the correct driver (Bluetooth, PlayStation, XBox,etc) before uploading your Arduino sketch.

Now that I’ve got the shield & wireless receiver working, I’m wrapping up the last few details on my robotic tank.  Follow me on Twitter to see the final result!