Hacking my Roomba
Like most programmers, I live alone, which means I end up in charge of rather more housework than I am altogether prepared to do. To fix it, I bought a Roomba. Specifically, I bought the cheapest Roomba there is, on the basis that it’s a robot that cleans my floor and I didn’t entirely understand what the premium version of that product would be.
It turns out that the cheap one can’t be scheduled to run at a particular time. At least, not using the buttons on top. If you take the face-plate off, there’s a serial port, and if you send the number 135 into it, the Roomba will clean the floor.
The Roomba's serial port has two 'battery voltage' pins and two ground pins. There's anywhere up to about 21V across this gap, which is enough to explode a Raspberry Pi. The voltage regulator takes this high voltage as input, and keeps its output pin a steady 5V above gound, perfect for the Pi. I used a linear regulator at first but changed to a switching regulator when I discovered how hot it ran.
The Roomba also exposes a serial-in pin, a serial-out pin, and a binary 'wake-up' pin. These accept logical input at 5V. The Pi has a bank of pins called the GPIO, which can be used for more or less anything you need. The problem is that they run at 3.3V, and so we need the logic level converter to bridge the gap.
The logic converter needs to be powered both at 3.3V and 5V to work, so it's connected to both the regulator's 5V output and the Pi's 3.3V reference pin, resulting in a bit of a bird's-nest of wires where everything is connected to everything else. But it works.
I then wrote a Node.js library to control the Roomba, using a standard serial port library, and the Pi’s in-built GPIO control command. It worked very well, and I was able to SSH into my vacuum cleaner and tell it to hoover the floor.
Which is great and all, but it’s not entirely less effort than walking over and pressing the button. But because I’m using Node here, I could add an Express server. By making it a Progressive Web App, I could even make it install on my phone’s home screen. As long as I’m on the network, I can clean the floor from my phone. If I go one step further, and expose that server to the internet, I can clean the floor from anywhere. I can connect it to If This Then That and clean the floor with my voice.
Which means I now legitimately own a Smart Device, and so the obvious question is, can it run Doom? And I mean, yes, it’s a regular PC. I just happen to have taped it to a vacuum cleaner, for which it can hardly be blamed. Although to be fair I didn’t tape a screen to it so while it can merrily play Doom to itself, you wouldn’t be able to join in.
By this point I’ve done everything I wanted: I’ve got a server running that lets me control the Roomba, I can schedule it, I can start it cleaning, and send it home, and it’ll play its merry Roomba song when it gets there. I can do everything the premium housework-robot can do and more… and yet somehow I don’t feel like I’m using the hack to its full potential.
Because the serial connection doesn’t just mimic the buttons. I can control the Roomba more directly. I can turn the lights on and off; I can turn the brush motors on and off; I can read the sensors; I can even upload my own merry Roomba songs so it will play I Want To Break Free while it trundles around cleaning my floor. And I can drive the wheels myself.
And to be honest, I’m not using the other end of the hack to its full potential. I’ve got a web browser at my disposal. I don’t have to limit myself to buttons and links any more. I have APIs to access webcams and touchscreens, and even the accelerometers on my phone. And I can even access my gamepad. So naturally I rigged my Roomba so I could drive it around with a videogame controller.
I guess I could have stopped there.
Obviously I'm aware that what I've done here is essentially to buy the one brand of vacuum cleaner that can drive itself around, and then retrofit it not to, but think of the real-world applications of this. This thing could make backbench MPs entirely obsolete. MPs vote by physically going into one room for 'aye' or another for 'no' — a Roomba can do that — and they support their leaders vocally in debates, but they're not actually allowed to talk or clap and frankly if your job is to make non-word noises then a vacuum cleaner is if anything overqualified.
But actually, there’s another thing modern web browsers can do: they can stream video. So I fitted a camera to the Pi, and now it really can play Doom. Sure, not actual Doom, but I’ve got a first-person view of a 3D world and I can control it with a gamepad. That’s a first-person shooter in my book.
And yes, I do mean “shooter”. Because I mounted the camera on the back of the Roomba, and the back of the Roomba has a vent — all vacuum cleaners do, or else they’d explode if they sucked in too much air and it couldn’t go anywhere. So as well as mapping the analogue stick to the wheels, I mapped the A button to the suction fan. Arranging a few stand-up paper enemies around my room, I can move around them and shoot them with blasts of air, killing them.
And so I present: Doomba.