port) and the hardware port. Serial is always defined,
so all we need to do is set its baud rate.
Next, we want to wake up the Roomba. To do that,
we pulse the DD line low for 500 ms. You should hear your
Roomba beep and its lights will come on. As soon as it
wakes up, a bunch of “stuff” is spewed out. I found that
this only occurs if your Roomba is still in its Vacuum mind.
As soon as I successfully got my Roomba into Control
mode, it stayed there and never spit that data out again.
No big deal, it wasn’t that interesting anyway. It just told
how long the Roomba had been asleep.
After the Roomba is awake, we want to put it into one
of its control modes. The sequence detailed at the end of
the Setup section is what SCI requires to send commands
to a Roomba. This sequence moves the Roomba from
Passive Mode to Safe Mode. Check pages 3 and 4 of the
iRobot Roomba Serial Command Interface (SCI)
Specification that is available at www.irobot.com.
Safe Mode is good for us because no matter what
commands we give our Roomba, the safety cutoff for the
motors remains active. This will help protect our robot from
driving off the stairs! There are other commands that move
Roomba to Full and back to Safe modes listed, as well.
We’ll stay “safe.”
This is the main “bump-n-go” loop for our robot. The
progress is simple:
Look at sensors
If bumped into something on the
Backup and turn right
Else if bumped into something on the
Backup and turn left
I added a little “eye candy” by turning on the corner
sweep brush motor whenever a bump action is active.
Let’s look at the basic functions to see how they work.
I’ve left these command sequences written out long hand
instead of just packing the data into an array and spitting it
out so that you can see all the commands and data easily.
Normally, I’d write a single function to do the command
sequence writing and put all the commands and data into a
byte array for execution.
Most of the commands in this program are just telling
the Roomba to move. Page 4 of the SCI manual details the
Drive command. You tell the Roomba how to move by
using the “137” command and then sending two 16-bit
The first 16-bit integer defines the speed to move. The
range is -500 to 500 millimeters/second.
Straight 32768 (0x8000 hex)
Pivot Clockwise -1
Pivot Counterclockwise 1
I found that my Roomba will not drive straight; it
always turns to the right. I think that I need to clean the
motor rotational sensors in the motor hubs. At least one
of them is not properly reporting wheel position.
The other half of the Roomba controls is the
UpdateSensors() function. This program is set to get
Group 1 sensor data (see page 7 of the SCI manual).
These bytes give us the status of the front bumper
switches, wheel drop switches, “cliff” sensors, virtual walls,
motor over-current, and dirt detectors.
We are only looking at the first byte which is the front
bumper switches. The two #define macros look at bits 0
and 1 which are those bumper switches. If we don’t get
data back, we have an LED flasher loop that tells us.
That’s all there is to it! Then, why did I have so much
SERVO 03.2013 15