1
$\begingroup$

I'm new to Roomba Create2.

I just want the program to send and receive data of the bumper sensor only.

I tried this code on an Arduino Uno:

#include <SoftwareSerial.h>
#include "roombaDefines.h"
int rxPin = 10;
int txPin = 11;
int sensorbytes;
SoftwareSerial Roomba(rxPin, txPin);
void setup()
{
  Roomba.begin(19200);
  Serial.begin(9600);
  pinMode(ddPin, OUTPUT);
  wakeUp ();   // Wake-up Roomba
  startSafe(); // Start Roomba in Safe Mode
  setPowerLED(128, 255);
  delay(1000);
  setPowerLED(128, 0);
  delay(1000);
}
void loop() 
{  
  Roomba.write(142);
  Roomba.write(7);
  delay(100);
  sensorbytes = Roomba.read();

   if (sensorbytes!=0 )
   {
    setPowerLED(255,255);
    Serial.println(sensorbytes);
   }
   else
   {
    setPowerLED(255,0);
    Serial.println("not_Press");
   }
   delay(100);
}

The robot code works fine for a period of time but after about two minutes I got some weird data from the robot (it shows in my serial monitor) and it makes my program seem to delay and crash.

So I tried to check where it comes from

void loop() 
{

int i = 0;

  while(Roomba.available() ) {
    byte c = Roomba.read();
    sensorbytes = c;
    Serial.println(sensorbytes);
    i++;
  }
  delay(150);
}

to check that the robot sends data via the serial port or not. Even if I don't command it, I get a packet of data, maybe every two minutes:

32
32
32
32
70
108
97
115
104
32
67
82
67
32
115
117
99
148
205
205
233
32
48
120
48
32
40
48
120
48
41
10
13

and it is the same. So I think that the Roomba Create2 will send data via the serial port every two minutes.

Can I avoid that data?

$\endgroup$
3
  • 2
    $\begingroup$ can i avoid that data ?? ... it is unclear what you are asking ..... are you asking how to stop roomba from sending it? $\endgroup$
    – jsotola
    Jul 14, 2018 at 19:06
  • 1
    $\begingroup$ decimal 32 is ascii space and decimal 10 and 13 is ascii newline and carriage return ............. put the values into a single string 32 32 32 32 70 108 97 115 104 32 67 82 67 32 115 117 99 148 205 205 233 32 48 120 48 32 40 48 120 48 41 10 13 ............... then convert to ASCII at a site like this on branah.com/ascii-converter ............. the result is this . Flash CRC suc ÍÍé 0x0 (0x0) ...... it looks like a part of a response to a command $\endgroup$
    – jsotola
    Jul 14, 2018 at 19:14
  • $\begingroup$ Thank you for your reply for my understanding if i did not send command to roomba it should not send me back the data right ? but i get this data even i i didnt command it $\endgroup$ Jul 21, 2018 at 11:57

1 Answer 1

1
$\begingroup$

You might want to take a look at the iRobot Create 2 OI spec https://www.irobotweb.com/~/media/MainSite/PDFs/About/STEM/Create/iRobot_Roomba_600_Open_Interface_Spec.pdf

I'm using a different controller so I can't test your code. Just be sure you are set for 115,200 baud.

You might also want to try sending a 128,7 command to fully reset the Create 2 before starting to send your 142,7 sensor read command which should only return a single byte on every command

You might also want to send the recommended "start" command

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.