Roomba Discovery Wifi code help

Inside the Roomba and Scooba and more, Cool mods, Repair and Upgrades - including the all new iRobot Create Kit. Let's void that warranty baby!

Roomba Discovery Wifi code help

Postby Lostfile » June 3rd, 2019, 6:29 pm

Hello,

I recently got a hold of a Roomba Discovery (4210) and wanted to add wifi functionality to it so I could issue commands with IFTTT. I am trying to accomplish this by using a Particle Photon and a buck convertor attached to the SCI port. I wrote a short .ino script but I can't seem to get any response from the Roomba no matter what I try; no response from the DDpin toggle or anything.

I have the RX, TX, ground, vin, and ddpin hooked up correctly and, as far as I can tell, this Roomba was built in November 2005 so it should have the 2.1 firmware. I don't have a computer to pull serial data - I've been writing and flashing all my code using my phone.

My code is below. Maybe someone can spot something I'm doing wrong or has an idea of something I could try?

My code:

//Roomba status variable
//0 = off, 1 = cleaning, 2 = docking
int roombaStatus = 0;
int ledPin = D7;
int ddPin = D5;

void setup(){
//Setup cloud function and variable
Particle.function("roombaCommand", roombaCommand);
Particle.variable("roombaStatus", roombaStatus);
//Setup status LED
pinMode(ledPin, OUTPUT);
//Setup wakeup pin
pinMode(ddPin, OUTPUT);
//Start wakeup sequence
digitalWrite(ddPin, HIGH);
delay(100);
digitalWrite(ddPin, LOW);
delay(500);
digitalWrite(ddPin, HIGH);
delay(2000);
//Setup baud
Serial1.begin(57600);
//Flash status LED
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
}

void loop(){}

//Cloud function called through IFTTT
int roombaCommand(String command){
if(command == "clean"){
clean();
return 0;
}
if(command == "dock"){
dock();
return 0;
}
if(command == "stop"){
stop();
return 0;
}
return -1;
}

void clean(){
//turn on D7 led to confirm command
digitalWrite(ledPin, HIGH);
//128,131,135 - start roomba clean
Serial1.write(128);
delay(50);
Serial1.write(131);
delay(50);
Serial1.write(135);
delay(50);
//set cloud status to 'cleaning'
roombaStatus = 1;
//turn off D7 led to confirm command
digitalWrite(ledPin, LOW);
}

void dock(){
//turn on D7 led to confirm command
digitalWrite(ledPin, HIGH);
//128,131,143 - send roomba back to dock
Serial1.write(128);
delay(50);
Serial1.write(131);
delay(50);
Serial1.write(143);
delay(50);
//set cloud status to 'docking'
roombaStatus = 2;
//turn off D7 led to confirm command
digitalWrite(ledPin, LOW);
}

void stop(){
//turn on D7 led to confirm command
digitalWrite(ledPin, HIGH);
//128,131,133 - stop roomba
Serial1.write(128);
delay(50);
Serial1.write(131);
delay(50);
Serial1.write(133);
delay(50);
//set cloud status to 'off'
roombaStatus = 0;
//turn off D7 led to confirm command
digitalWrite(ledPin, LOW);
}

I've tried setting the Roomba's baud to 19200 using the 'hold power button for 10 seconds' trick, but it doesn't seem to work so I'm not sure what is going on with this thing.
Lostfile
 
Posts: 1
Joined: June 3rd, 2019, 6:07 pm

Re: Roomba Discovery Wifi code help

Postby ps0001 » June 3rd, 2019, 8:41 pm

  1. Check your wiring. As simple as it sounds, that'd be the first thing I'd do.
  2. Next, I would add some commands to your setup() routine. I see where you wake up the Roomba, but it looks like you don't do anything else unless your Photon gets commands from IFTTT, or however you have it arranged. Just to eliminate a possible point of failure, I would try communicating with the robot directly in setup() or loop().
I'm impressed that you're even attempting all this without a computer! There's no way I could write much code on my phone!
ps0001
Robot Addict
 
Posts: 193
Joined: December 5th, 2017, 4:25 pm

Re: Roomba Discovery Wifi code help

Postby vic7767 » June 3rd, 2019, 9:45 pm

When the Roomba is connected to a power supply and charging a battery, there is a data stream that is automatically sending charging data once per second via the SCI port as long as the power supply is connected to the Roomba. You can download a TCP/IP app for your phone and the monitor your comm port using the wifi ip address and comm port number.Once you can see the ASCII data on the app then you can try testing your code.

Also sometimes the SCI port will lock up. The easiest way to clear that condition is to remove and then replace the battery.
Roomba and Neato Mods, come visit: http://www.vic7767.com/
User avatar
vic7767
Robot Master
 
Posts: 14944
Joined: January 14th, 2006, 8:31 pm
Location: Haughton Louisiana - USA


Return to Robotic Hacking

Who is online

Users browsing this forum: Botty, BrettS, fergambo, im1kissfan, Miles267, mobzd, mofan, twistdh and 404 guests