Early Morning Project: RasPi Zero Roomba

I can’t sleep. Instead of sleeping, I’m hacking robots. Last year during my winter holiday I wired up a Raspberry Pi to my Roomba, to drive it around and such. More recently I got a Raspberry Pi Zero and wanted to do the same thing.

RasPi Zero Roomba

You may be asking “if you’ve already done it with a Raspberry Pi, are you really doing anything new?” The answer is “kind of.” In the previous version was an original Raspberry Pi Model B. I also used a USB-to-serial cable. This version upgrades to a Pi, and uses the onboard UART. So fewer components. Again, I used Jason Bradshaw’s excellent iRobot Node Library.

There were a couple of hiccups setting this all up:

Level Shifting

The Raspberry Pi Zero operates at 3.3v. The Roomba’s serial lines operate at 5v. Fried Pie sounds amazing. Fried Pi sounds like an expensive tragedy ($5 Pi Zeros are cheap but super-unavailable) So I needed to put together a level shifter. I had an AdaFruit Level Shifter sitting around from several years ago, so I soldered that up. The Pi’s pins have 5v and 3.3v, so I was easily able to wire things up.

Level Shifter

What Serial Port?

On my previous Roomba Pi project, I used a USB-to-Serial cable because it was a super simple solution. Trying to use the serial on the Pi wasn’t obvious. At first, I came across an article that said to use the standard Linux port /dev/ttyS0. That failed – it turned out I didn’t have it. Exploring the /dev directory I found the real port /dev/ttyAMA0, but that didn’t work either. It turns out you have to prevent the operating system from taking it over. This is done in the Raspberry Pi config (sudo raspi-config go to Advanced and then to Serial)

Screen Shot 2016-07-20 at 2.20.23 AM

Get the right speed, please

This is kind of dumb, but I couldn’t get it connecting correctly at first because the default in the library was 57600. The Roomba 500 series+ communicates at a default of 115200 bps. Simple fix, and I was off to the races.

The test.js provided in the library is decent for getting going with some basic sensor readings. Now that I’ve gotten the robot up and running, I may ditch Node in favor of Python. I know Javascript better but Python has a strong set of OpenCV bindings, and I’m interested in diving into doing some computer vision stuff.