SparkBot = Spark Core + Roomba


#1

SparkBot — (Manually) automatically vacuum your living room!

Overview


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.

Supplies

  1. [Spark Core] (https://www.spark.io) (Chip antenna or u.FL)
  2. Roomba vacuum cleaner (firmware 2006 or later). We used a Roomba Discover series bot.
  3. Male to male jumper cables
  4. 400 pt mini-breadboard (comes with your Core!)
  5. 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 :slight_smile:

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

source ~/.profile

in order to update any changes that you’ve made. Finally run the command with

rc_while

From there, you should be able to use the predefined commands on your keyboard to drive the Roomba around.

Videos


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

Next Steps


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.

Resources


#2

Has anyone attempted this? I have had very little luck - about the only thing that I can get to work is when sending the command to cycle the LED’s, it sometimes plays a tune and acts like it is going to start vacuuming. Other than that no luck - thought this would be a good way to start playing with robotics and Spark, before the kits I ordered arrived.


#3

Well it turns out there was an issue with the serial port speed on the Roomba. I finally decided to try it at 19200 and it worked great!


#4

@mtuckman Happy to hear it! That’s probably not the first fix I would have suggested, so I’m glad you got it working! I’m also glad SparkBot has a friend :smiley:

Post a video! And let us know if you do any other tinkering or development in the meantime.


#5

I tried this as well, but since I’m running a windows box I ended up hacking together a basic php page with javascript to take the arrow keys and map them to the four direction commands. So far it’s working, although my javascript needs a little tightening up. Trying to work in a failsafe so my roomba stops headbutting desks


#6

It’s worth mentioning that the iRobot Create robot (based off the Roomba) has a regulated 5v @ 100ma output, and several digital output 5v @ 20ma pins. See page 4 of this PDF.


#7

@buffington - Unfortunately I am using an older Discovery 4xx model.

@ctruszkowski - Have you tried running it in safe mode?

Going to strip it down to bare metal this evening so I can start building it back up. Unfortunately I have to wait until my boys go to bed before I can work on it since all of this (robotics, the Spark, etc) is a Christmas surprise.


#8

@buffington I’m also only in posession of a few 400/4000 series units.
@mtuckman Safe mode is where the sensors for things like cliff detection are still active and the like yes? I haven’t tried that yet mostly I’ve just been sending it commands like the posted bash script would do but in a javascript/ajax form. Initially I was thinking my issue was ajax calls happening out of order but now I’ve seen a few times where it just gets stuck on a command and the roomba seems to ignore all input and just keeps following it’s last command (which given the code makes sense just trying to find a way around that) also my voltage regulator is getting nice and toasty after only a few minutes plugged in so definitely adding a heatsink to that soon.


#9

As far as I understand the RXD and TXD lines are 0-5V, so is it safe to connect them directly to Spark Core (with 3V3 logic)?


#10

Hi! Any ideas if this project could work on irobots new product:

http://www.irobot.com/About-iRobot/STEM/Create-2.aspx

Seemes with great posibilities.


#11

Hi,

For 5V tolerance :

You can integrate spark core in roomba in order to make it invisible. You can also get 5V from it and directly connect it to Vin removing external regulator. For roomba model with no wake up input on external connector, you can connect core to clean button input and control it from Core.


#12

I know this thread is old, but I’m currently working on a project very similar to this. Did you experience a slow response time from the roomba? If you did how did you deal with it. I get the roomba the command and then it takes it a lot of time to process the command. (Blinking for about a minute or more it is very frustrating)


#13

My experience with the Roomba was that once the message was delivered, it responded almost instantly.

When you say “Blinking for a minute or more”, what do you mean? What is blinking?


#14

Oh thank you for the reply so the roomba’s main light will flash very fast as if it is processing the code then it will just pause. I have an output on my particle that tells me when it has received the code, but then it takes the roomba a long time to actually respond to the command.


#15

How about newer models like the iRobot Roomba 770 and 650? How fast is the response?


#16

Hi,

is there any chance to repost the original post with the pictures?

Cheers


#17

Also if someone is interested. I’ve successfully connected my Roomba with Homekit using Photon.

Code is included in my Homekit library examples:
Particle HAP library

Also i can make some photos of my project. I did not implement full control of Roomba, but only ON/OFF control. I am control it using HomeKit automatization - like “Turn ON Roomba when last person leaves home” / “Turn OFF Roomba (go home) when someone arrives home”