Go Down

Topic: iRobot Create 2 Baud Rate Issue (Read 605 times) previous topic - next topic

tzankoff

Hi, guys! I need some help here because I am beyond stumped on this seemingly painfully simple procedure. I am trying to get my Arduino Mega to talk to an iRobot Create 2. I have seen numerous examples in various forums on how to do this, but none of them seem to work despite matching code. I have tried communicating with the robot at both baud rates (19200 and 115200), with and without the pulse that sends the robot into a lower baud rate, with no success.

One thing that I have noticed is that the initial pulse awakens the robot but the subsequent pulse does not keep it awake and the robot goes back to sleep a couple of minutes later. The timeline of events is as follows:

00:00 Initial pulse awakens robot.
03:00 A pulse is sent.
05:00 Robot goes to sleep after five minutes of inactivity
06:00 A pulse is sent. Robot wakes up again.
09:00 A pulse is sent.
10:00 Robot goes to sleep after five minutes of inactivity

Can somebody please look at my code and my wiring and tell me if I am doing anything wrong with them? I am hoping that there is somebody who knows something that I do not because I could really use some help here. I honestly do not understand why this is not working.

Thanks in advance. :-)

Code: [Select]

// CREATE 2                                    ARDUINO MEGA
// 2 (Power) ------> 1N4001 Diodes (x2) -----> Power
// 7 (Ground) -------------------------------> Ground
// 5 (BRC) ----------------------------------> 2
// 4 (TXD) not connected yet
// 3 (RXD) not connected yet

#include <SoftwareSerial.h>

int baudPin = 2;
int i;
int ledPin = 13;
int rxPin = 19;
int txPin = 18;

unsigned long baudTimer = 180000; // 3 minutes
unsigned long prevTimer = 0;
unsigned long thisTimer = 0;

SoftwareSerial Roomba(rxPin, txPin);

void setup() {
  pinMode(baudPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);

  delay(2000);
  Roomba.begin(19200);
  Serial.begin(115200);

  for (i = 1; i <= 3; i++) {
    digitalWrite(baudPin, HIGH);
    delay(250);
    digitalWrite(baudPin, LOW);
    delay(500);
    digitalWrite(baudPin, HIGH);
    delay(250);
  }

  // Roomba.write(128);
}

void loop() {
  thisTimer = millis();

  if (thisTimer - prevTimer > baudTimer) {
    prevTimer = thisTimer;
    digitalWrite(baudPin, LOW);
    delay(500);
    digitalWrite(baudPin, HIGH);
    delay(250);
    Serial.print("Pulse sent...\n");
  }
}

Go Up