SparkBot — (Manually) automatically vacuum your living room!
David, one of our software engineers, had an old Roomba from 2006 lying around his house, and was kind enough to bring it into the office for me. In anticipation of [Robots Conf] (http://robotsconf.com) in Florida, the Spark team decided to see what we could throw together in the 24 hours leading up to the event. SparkBot has come a long way in a short time, and we’ve got a lot of plans for him going forward. As of right now, our little friend can
- Drive around via computer terminal remote control
- Toggle vacuums ON/OFF
- Toggle LEDs ON/OFF
- Create and play MIDI songs
- Respond to environment via bump sensor
- Be commanded to auto-seek the home docking station
- Return to fully automatic clean mode
All of this is facilitated via the built-in terminal port on the Roomba. You need to check to make sure that your Roomba has firmware that dates to 2006 or later. You can do that fairly simply by holding down the power button during startup for 10 seconds–it will respond with a little morse code response. You can find more information about that process [here] (http://skaterj10.hackhut.com/2013/01/22/roomba-hacking-101/). Enough talking—here’s how it works.
- [Spark Core] (https://www.spark.io) (Chip antenna or u.FL)
- Roomba vacuum cleaner (firmware 2006 or later). We used a Roomba Discover series bot.
- Male to male jumper cables
- 400 pt mini-breadboard (comes with your Core!)
- Voltage Regulator (up to 20V in, 3.3 or 5V out)
Connecting the Hardware
Conveniently, the Roomba has a fully documented [Serial Command Interface] (http://www.irobot.com/images/consumer/hacker/Roomba_SCI_Spec_Manual.pdf) for manual control and exposes the PS/2 port on the side of the robot for easy access.
From here, we connected male to male jumpers from the corresponding pins on the Roomba to the breadboarded Core. The only connection that isn’t directly from the PS/2 port to the Core is the power line. Because the Roomba’s battery runs at 14.4V, we have to down-regulate the voltage to at least 5V in order to safely power the Core.
We happened to have a [LM340T-5.0] (http://www.ti.com/lit/ds/symlink/lm340-n.pdf) regulator lying around, which accepts inputs up to an absolute maximum of 34V, so that did the trick.
NOTE: The LM340T-5.0 ran a little hot during extended use—I’d consider using a regulator better suited for such a large power dissipation requirement.
Also note that TX on the Roomba goes to RX on the Core, and RX on the Roomba goes to TX on the Core. This can be a little tricky sometimes, so if your robot isn’t responding, try swapping these two lines. Based on the datasheet for the LM340T-5.0, I also added a 0.22 uF capacitors between both the input line and ground, as well as the output line and ground.
Firmware for the Core
Below is a gist file that contains the firmware programmed onto the Core. It was great being able to program the Core wirelessly, since it was seated in the breadboard which was stuck to the Roomba. Updating over-the-wire would have meant seating the dirty robot on my lap while I ran a USB micro cable to the Core
The two most useful resources that helped me write the firmware were the Roomba SCI Spec Manual, and the Spark Core docs. Using the Roomba SCI documentation, there is a bunch more features that you could program into your own robot. I’d highly recommend taking a look at it—the guys at Roomba did a fantastic job of making a vacuum primarily designed for “set-and-forget” moonlight as a hackable device.
In the Spark documentation, the most useful section was the “Core firmware reference” section, which describes how to expose Spark functions to the API. Make sure you’re passing in a string and returning an integer!
Bash script for remote control
Below is a gist file that contains the bash scrip that I used as a controlled to make API calls to SparkBot.
Thanks to Joe Goggins from the Spark team for putting this together. With just a few minor tweaks, I was able to add in extra lines for all the fun Roomba SCI commands. Make sure you run
in order to update any changes that you’ve made. Finally run the command with
From there, you should be able to use the predefined commands on your keyboard to drive the Roomba around.
Here are some links to early videos of SparkBot during development, and also our demonstration at the Science Fair at Robots Conf! We didn’t win any awards, but he performed brilliantly.
SparkBot Creation -> https://www.facebook.com/photo.php?v=634126339959873
Science Fair Demo -> https://www.youtube.com/watch?v=2nbO35Ch6qs
Once we here at Spark finish porting the random() function from Arduino, I’d love to change the playSong() function to generate a random 8 note tune every time you call it. Also, I’d love to create different tunes that SparkBot automatically plays when he runs into something while driving, when you turn him on, when you take control of him, and when you set him free to auto-clean. I think giving him some more personality would make him an even more helpful addition to the Spark team.
- [Spark Core Documentation] (http://docs.spark.io)
- [Helpful post on hacking your Roomba] (http://skaterj10.hackhut.com/2013/01/22/roomba-hacking-101/)
- [iRobot Roomba SCI Specification Manual] (http://www.irobot.com/images/consumer/hacker/Roomba_SCI_Spec_Manual.pdf)
- Basic [7805 Voltage Regulator] (https://www.sparkfun.com/products/107) in TO-220 package from SparkFun
- Gist for [Sparkbot_firmware] (https://gist.github.com/brandoaire/7893934)
- Gist for [Sparkbot_bashscript] (https://gist.github.com/brandoaire/7797078)