5

I have an IRobot Roomba model number 565 and I am trying to control it with a Wemos D1 mini with Roomba's OI.

I connected the TX and RX pins from my FTDI adapter to the Roombas RX and TX and I can see information (battery firmware and etc) pop up in Termite (a serial terminal) but if I send the commands 128,131,135 in sequence The Roomba doesn't go to clean mode.

I saw somewhere that sending commands to the Roomba with the serial terminal won't work because it will send 128 as three bytes instead of one. So I used a sketch from someone that publishes information about the Roomba into an MQTT server. So I uploaded it to my Wemos D1 mini and connected the RX and TX accordingly, but it sends "no data" and when I do a power reset it gives me a two-tone beep.

I am really confused about what does that beep mean and why isn't it working correctly. I did try two different sketches but neither of them worked.

How can I command my Roomba to go into clean mode using my Wemos D1 mini?

EDIT: sorry for forgetting to add the links of the sketches I tried. The MQTT one is from a Youtuber called The Hook Up here is his GitHub The second one I saw while searching on why it wasn't working, so here is that one. Also, I was trying to upload this one but I was getting a compiling error so I didn't test it. Also, I didn't find anything about the error beep the Roomba is giving me. The closest thing I get while searching for it is the list of error codes and beeps but it doesn't say anything for only 2 beeps and no voice message. I also totally forgot to mention that when I connect my Roomba with a serial adapter, open Termite(a serial terminal) and then press the clean button I get the following response

Termite

this tells me that there is a high chance that there is OI support in my Roomba.

I also tried using Python as Austin suggested but still, no luck here is my code if you can find some sort of mistake I did

import serial
ser = serial.Serial("COM7", 115200) # open serial port
print(ser.name) # check which port was really used
ser.write(bytearray([128, 131, 135]))
print ("commands sent")
  • what information have you found about the two-tone beep? – jsotola Jun 04 '19 at 19:01
  • 1
    I have edited the question you guys asked for. thanks a lot for letting me know. Also, I was wondering if I should call Irobot and maybe they might help. what do you guys think? And most of the people said that it's my Roomba's fault because theirs are working fine. – Aalian khan Jun 06 '19 at 04:17
  • The serial terminal your using is representing the numbers as ASCII characters, which means typing 128 is actually sending bytes 49, 50, and 56. Why not try doing this in Python with the pyserial library, this will only be a few lines of code. Import serial, make the serial object (ser = serial.Serial("COM#", <baud_rate>), then do a ser.write(bytearray([128, 131, 135]). – AustinTronics Jun 06 '19 at 15:43
  • I don't know much about python. If you can show me an example file that will be great. until then I will try to do it myself and give the results I get – Aalian khan Jun 06 '19 at 18:55
  • Hello @AustinTronics I tried using python and still no luck I posted my code in the question – Aalian khan Jun 07 '19 at 04:11
  • I ended in the same problem as you two years ago. Did you manage to solve it? Thanks – Tebogo Aug 30 '21 at 20:54

1 Answers1

2

Your code looks good, the device is probably sending you back bytes so you need to read them on the port. Adding to what you have, it would look something like this:

import serial
import time

ser = serial.Serial("COM7", 115200) # open serial port
print(ser.name) # check which port was really used
ser.write(bytearray([128, 131, 135]))
print ("commands sent")

start_time = time.time()
while time.time()-start_time < 10:
    if ser.inWaiting() > 0:
        incomming_byte = ser.read()
        print(incomming_byte),      #Prints bytes interpreted as ascii/char values
        #print(ord(incomming_byte)) #Prints bytes interpreted as decimal values

ser.close()

This will loop for 10 seconds checking to see if any bytes are in the serial buffer, and if there is, then it will read the bytes. The comma after the print statement should print all the bytes on the same line as opposed to on multiple new lines. The second print statement is commented out so it wont run, but I put it there in case you wanted to get decimal values back.

  • Great! I tried your script and it returned the following. b'\x80' b'\x83' b'\x87' Now I don't know what this means. Any info on what to do next? – Aalian khan Jun 07 '19 at 18:33
  • Researched a bit and found out that is in Hex so I converted it to decimal and it returned 128 131 135. It seems like its replying back the same thing we sent. I tried other commands like getting the battery and such but it replied with the same bytes that we sent. Odd – Aalian khan Jun 07 '19 at 18:47
  • That is odd. Try sending random bytes that arn't commands and see if you get those back. I also wonder if there are any commands that turn on an LED or makes the device have any physical change where you can visually inspect that it's working. – AustinTronics Jun 07 '19 at 18:56
  • tried to send commands that are not listed in the OI PDF and it returned with an 'n'. when I press buttons on the Roomba it gives me a message saying 'bbox vars saved'. there are commands for controlling the LEDs and I sent the commands but the same behaviour persists. If you want the OI sheet here you go. https://www.irobot.lv/uploaded_files/File/iRobot_Roomba_500_Open_Interface_Spec.pdf – Aalian khan Jun 08 '19 at 00:37
  • Try separating the commands. One command per bytearray. Don't try sending the commands all at once in one bytearray. Also wait a second between each command to give the device enough time to react. So bytearray([128]) followed by a time.sleep(1) followed by a bytearray([131]) followed by another time.sleep(1), etc... – AustinTronics Jun 08 '19 at 00:52
  • Tried it and I got the same result. – Aalian khan Jun 08 '19 at 01:04
  • By same result do you mean the commands are being echoed back? Try sending a bytearray([128]) then a time.sleep(1), then a bytearray([139, 4, 0, 128]). I don't know if it needs to be set in safe mode first before LED commands can be sent to it. See if the LEDs can turn on. If that doesn't work, try power cycling it and then sending the start and LED commands. – AustinTronics Jun 08 '19 at 01:20
  • The same Result got this back COM7 Sending commands Recieving commands b'\x80' b'\x8b' b'\x04' b'\x00' b'\x80' Closing serial port – Aalian khan Jun 15 '19 at 02:24
  • nothing happened – Aalian khan Jun 15 '19 at 16:39
  • I read the documentation further and this should be working for you. It seems like you are getting proper readings when you use termite, which means it's most likely not a hardware/cable issue. What exactly is termite sending to get these responses from the Roomba? Try calling the same commands that gets the same sensor readings from the Roomba that termite is getting. If your still not successful, use a USB sniffing tool to see what termite is actually sending out so you can replicate it in your python script. – AustinTronics Jun 16 '19 at 18:21
  • Sorry for the misunderstanding. Termite doesn't send a command to get those sensor values. When I click the physical clean button on my Roomba, those sensor values get sent to my FTDI serial adapter then to termite where it gets displayed. – Aalian khan Jun 17 '19 at 02:27
  • And what happens when your running the python script and hit the clear button? – AustinTronics Jun 17 '19 at 02:32
  • I get hex bytes in return. I am not sure how to translate it though – Aalian khan Jun 17 '19 at 16:02
  • Based on what I see in your termite console, some of it looks like it should be interpreted as ASCII text, and the rest as values to sensor data. The user manual should show you how to interpret responses from commands – AustinTronics Jun 17 '19 at 17:43
  • it does stat that its ASCII and they recommend using their serial adapter but many have gotten it to work with a PNP transistor on the TX pin – Aalian khan Jul 17 '19 at 18:52