Schedule a Roomba (with Arduino)

We're the happy owners of a Roomba 620.

It's really doing a great job, but a scheduling feature is lacking, which means that we always had to trigger the cleaning process manually.

Fortunately, the iRobot Open Interface allows for easy programming. There are numerous ways of communicating with a Roomba. Here, we'll be using an Arduino, which is probably the easiest / cheapest way to do it.

Basically, the Arduino will act as a bridge between the computer and the robot, allowing us to send scheduling commands.

Step 1: What You Need

  • A Roomba (I am using a 600 series model)
  • An Arduino Uno and its USB cable (any other model should do the job as well)
  • A computer
  • 4 wires

And that's it.

Step 2: Remove Roomba's Cover

The Open Interface port should now be visible.

Step 3: Plug!

Using the wires, connect the Arduino to the Roomba as follows:

Roomba port 7 (GND) <-> Arduino GND
Roomba port 3 (RXD) <-> Arduino D4
Roomba port 4 (TXD) <-> Arduino D3
Roomba port 5 (BRC) <-> Arduino D5

The ground (GND) should be connected first and disconnected last, it's safer (for the Arduino).

Note: Don't connect the Roomba ports 1-2 to the Arduino, their voltage might damage your board!

Step 4: Programming Time

Connect the USB cable between the Arduino and the computer.

Start the Arduino software (freely available here).

Set the port using the menu Tools > Port > Arduino Uno (or whichever board you're using).

Open the serial monitor and select 19200 bauds.

Copy the following program:

// Roomba Scheduler

// Roomba port 7 (GND) onto Arduino GND // Roomba port 3 (RXD) onto Arduino D4 // Roomba port 4 (TXD) onto Arduino D3 // Roomba port 5 (BRC) onto Arduino D5

#include

int rxPin = 3 ; int txPin = 4 ; int ddPin = 5 ; int ledPin = 13 ;

SoftwareSerial Roomba(rxPin, txPin) ;

void setup() {

// Arduino pins setup

pinMode(ddPin, OUTPUT) ; pinMode(ledPin, OUTPUT) ; digitalWrite(ledPin, HIGH) ; digitalWrite(ddPin, LOW) ; delay(2000) ;

// Changing Roomba baud rate to 19200 digitalWrite(ddPin, HIGH) ; delay(100) ; digitalWrite(ddPin, LOW) ; delay(200) ; digitalWrite(ddPin, HIGH) ; delay(100) ; digitalWrite(ddPin, LOW) ; delay(200) ; digitalWrite(ddPin, HIGH) ; delay(100) ; digitalWrite(ddPin, LOW) ; delay(200) ; digitalWrite(ddPin, HIGH) ; delay(100) ;

// Serial communication setup

Serial.begin(19200) ; Roomba.begin(19200) ;

// Roomba Open Interface setup

Serial.println("Roomba Open Interface setup...") ; delay (1000) ; Roomba.write(128) ; // START delay(150) ; Serial.println("Sending Safe Mode command...") ; delay (1000) ; Roomba.write(131) ; // CONTROL delay(150) ; digitalWrite(ledPin, LOW) ; delay (500) ;

// Sing a song

sing() ;

// Set current time setCurrentTime(2, 13, 42) ;

// Set schedule

setSchedule() ;

// Finishing

Serial.println("Roomba Open Interface stopping...") ;

Roomba.write((byte)173) ; // Stop the OI

Serial.println ("All Done Baby!") ;

}

void loop() {

}

void sing () {

Serial.println("Singing...") ;

Roomba.write((byte)140) ; Roomba.write((byte)0) ; Roomba.write((byte)7) ; delay(500) ;

Roomba.write((byte)76) ; Roomba.write((byte)16) ; Roomba.write((byte)76) ; Roomba.write((byte)32) ; Roomba.write((byte)79) ; Roomba.write((byte)16) ; Roomba.write((byte)79) ; Roomba.write((byte)16) ; Roomba.write((byte)77) ; Roomba.write((byte)16) ; Roomba.write((byte)74) ; Roomba.write((byte)16) ; Roomba.write((byte)72) ; Roomba.write((byte)32) ; delay(500) ;

Roomba.write((byte)141) ; delay(50) ; Roomba.write((byte)0) ; delay(50) ;

delay(500) ;

Serial.println("Singing [OK]") ;

}

void setCurrentTime (int aDayOfWeek, int anHourCount, int aMinuteCount) {

Serial.println("Setting current time...") ;

Roomba.write((byte)168) ; // Command code Roomba.write((byte)aDayOfWeek) ; // Day (0: Sunday, 1: Monday, 2:Tuesday, 3:Wednesday, 4: Thursday, 5: Friday, 6: Saturday) Roomba.write((byte)anHourCount) ; // Hour Roomba.write((byte)aMinuteCount) ; // Minute

delay(500) ;

Serial.println("Setting current time [OK]") ;

}

void setSchedule () {

Serial.println("Setting schedule...") ;

Roomba.write((byte)167) ; // Command code Roomba.write((byte)127) ; // Days (127 (dec) = 01111111 (binary) = 0(Sat)(Fri)(Thu)(Wed)(Tue)(Mon)(Sun) -> schedule everyday) Roomba.write((byte)16) ; // Sunday Hour Roomba.write((byte)45) ; // Sunday Minute Roomba.write((byte)15) ; // Monday Hour Roomba.write((byte)0) ; // Monday Minute Roomba.write((byte)15) ; // Tuesday Hour Roomba.write((byte)0) ; // Tuesday Minute Roomba.write((byte)15) ; // Wednesday Hour Roomba.write((byte)0) ; // Wednesday Minute Roomba.write((byte)15) ; // Thursday Hour Roomba.write((byte)0) ; // Thursday Minute Roomba.write((byte)15) ; // Friday Hour Roomba.write((byte)0) ; // Friday Minute Roomba.write((byte)15) ; // Saturday Hour Roomba.write((byte)0) ; // Saturday Minute

delay(500) ;

Serial.println("Setting schedule [OK]") ; }

Step 5: Adjust Your Parameters

You have to adjust the following parameters in the code:

    Set the current time: (Day, Hour, Minute)

    setCurrentTime(2, 13, 42) ;

      Set the desired schedule:

      Roomba.write((byte)127) ; // Days (127 (decimal) = 1111111 (binary) = (Sat)(Fri)(Thu)(Wed)(Tue)(Mon)(Sun) -> schedule everyday)
        Roomba.write((byte)16) ; // Sunday Hour
        Roomba.write((byte)45) ; // Sunday Minute
        Roomba.write((byte)15) ; // Monday Hour
        Roomba.write((byte)0) ; // Monday Minute
        Roomba.write((byte)15) ; // Tuesday Hour
        Roomba.write((byte)0) ; // Tuesday Minute
        Roomba.write((byte)15) ; // Wednesday Hour
        Roomba.write((byte)0) ; // Wednesday Minute
        Roomba.write((byte)15) ; // Thursday Hour
        Roomba.write((byte)0) ; // Thursday Minute
        Roomba.write((byte)15) ; // Friday Hour
        Roomba.write((byte)0) ; // Friday Minute
        Roomba.write((byte)15) ; // Saturday Hour
        Roomba.write((byte)0) ; // Saturday Minute

      Step 6: Let's Go!

      Click the arrow button to execute your program.

      It should take a couple of seconds. Check the monitor, the following text should appear:

      Roomba Open Interface setup...
      Sending Safe Mode command... Singing... Singing [OK] Setting current time... Setting current time [OK] Setting schedule... Setting schedule [OK] Roomba Open Interface stopping... All Done Baby!

      If everything goes smooth, Roomba will sing a cool song.

      You're done! Just unplug and put the lid back.

      Congrats!

      Share

        Recommendations

        • Faux-Real Contest

          Faux-Real Contest
        • Sweet Treats Challenge

          Sweet Treats Challenge
        • Remix Contest

          Remix Contest

        Discussions

        0
        None
        randofo

        4 weeks ago

        Nice solution.