Add wifi to an older roomba

Awesome!!!
Are we going to see the fruit of your labor in some write up somewhere? The wiring, the photo, the codes, the parts you use, etc…

Maybe under here Share your Projects! - Home Assistant Community (home-assistant.io)…?

1 Like

Hi everyone, first of all tnx everyone for all the work that has been put in so far by the community!
I just recently picked-up this and wanted to try it myself. I do have a D1_mini connected to gnd,tx,rx with a pnp and I do have established some communication. I used the esphome.yaml example and ESPHomeRoombaComponent.h from Real-Time-Kodi’s github.
it took some time to actually get data from the roomba. not sure if my PNP transistor was wrongly connected or other issues.
the D1_mini does seem to struggle with a lot of ‘error’ messages.
component <unknown> took a long time for an operation (202 ms).
And it doesn’t listen to commands. (the locate button doesn’t appear to do anything).
I need to get a buck converter because it is now still connected to my computer, so trying to have it move around is difficult with the short usb cable :slight_smile:

Has someone already tried building in commands in the code to just send the roomba around like a toy? forward, reverse and so on?
Also wondering if the numbers I see for the battery will be normalized somewhat. I did put in a new battery not long ago, but the roomba was never used with that battery anymore. So the numbers jump from 10% full to 400% full every few minutes.

Sorry, missed this one.

Yeah I think @davidecavestro and @bremby have been using their buttons to control roomba around like a toy.

Check out Add wifi to an older roomba - #178 by davidecavestro and below, for the buttons in the interface.
You should be able to use @davidecavestro’s code.

About errors in the data:
I’m not sure how to prevent that.
I’ve tried adding filters in ESPHome previously, but that also does not work flawlessly.
I’m also not sure if it’s a measuring error by Roomba or data corruption on the serial interface.
Too lazy to figure that out :sweat_smile:

Re: errors on the data:

I swapped out my transistor in favour of a level shifter like this one:

(recommended back in 2018) - it uses a BSS138 field-effect transistor with 10K pullup transistors to each supply. Most important, it has very fast switching speeds and it is quite small (the size of a postage stamp). This has made my UART interface much more reliable - I haven’t seen errors in the data since I installed it.

1 Like

I have made some edits to add new commands and sensors to the ESPHomeRoomba.h Component and published them on Github:

Enjoy!

1 Like

My roomba receives the data well and whenever it’s in the base it’s awake. But very often, when I put it to clean, goes to sleep and goes into a lost state, preventing me from using it remotely until I physically touch a button or put it on the base. How do I fix this?

I took the idea from https://yakinikuman.github.io/pistreaming_roomba/ and used a NPN transistor to connect the clean button’s 13V pad to ground via GPIO to simulate a button press.

I’ve been able to send signals to my Roomba 560 without a problem, but I’ve been having a hard time receiving data from the Roomba. I’ve gone through 2x Raspberry Pi Pico W and 2x ESP32-C3s and a handful of 2N3906 without success. I checked continuity from the internal pad posted by @MichielioZ to the TX port in the DIN in case the DIN wasn’t connected to the motherboard correctly, but that wasn’t it either.

I’m fairly certain I have the 2N3906 wired correctly (with the flat side facing me, left pin to microcontroller’s RX, middle to DIN TX, and right to ground), although I think I’ve tried both ways at some point, but no dice. Sadly, no access to an oscilloscope to verify that there is signal from the DIN port.

After poking around a bit with my multimeter, I can see the voltage drop momentarily about ~0.05 to 0.1V on both the TX side of the Roomba and the RX on the ESP32-C3 Super Mini, so I think it is transmitting. Again, I don’t have access to an oscilloscope, so I can’t verify that it’s actually dropping to low to send data, but I suspect that it is. For some reason, though, the ESP32-C3 is not receiving the data.

I have TX on GPIO21 and RX on GPIO20. I also have a transistor hooked up to GPIO0 that presses the Clean button. I’m using @MichielioZ’s YAML to send the commands, but getting nothing received on the ESP32-C3. I am looking to figure out the RX issues before moving to one of the ESPHome components.

substitutions:
  name: roomba560
  friendly_name: Roomba 560

esphome:
  name: ${name}
  friendly_name: ${friendly_name}

esp32:
  board: esp32-c3-devkitm-1

# Enable logging
logger:

# Enable Home Assistant API
api:
  # Insert your default API configuration like password, encryption etc.
  services:
    - service: command
      variables:
        cmd: string
      then:
        - logger.log:
            format: "Command received: %s"
            args: [ 'cmd.c_str()' ]
            level: INFO
            tag: roomba

        - if: # Toggle clean button to wake up
            condition:
              lambda: 'return cmd == "wakeup";'
            then:
              - script.execute: wakeup
              - script.wait: wakeup

        - if: # POWER (sleep)
            condition:
              lambda: 'return cmd == "sleep";'
            then:
              - uart.write: [133]
        - if: # SPOT
            condition:
              lambda: 'return cmd == "spot";'
            then:
              - uart.write: [134]
        - if: # CLEAN
            condition:
              lambda: 'return cmd == "clean";'
            then:
              - script.execute: wakeup
              - script.wait: wakeup
              - uart.write: [135]
        - if: # MAX
            condition:
              lambda: 'return cmd == "max";'
            then:
              - uart.write: [136]
        - if: # SEEK DOCK
            condition:
              lambda: 'return cmd == "dock";'
            then:
              - script.execute: wakeup
              - script.wait: wakeup
              - uart.write: [143]

        - if: # Sensors (get individual/group/all sensor data)
            condition:
              lambda: 'return cmd == "sensors_all";'
            then:
              - uart.write: [142,100]
        - if: # Query list (get data from specified sensors/groups)
            condition:
              lambda: 'return cmd == "sensors_battery";'
            then:
              - uart.write: [149, 6, 21,22,23,24,25,26]

        - if: # Song (record), Play (a recorded song number | only SAFE or FULL mode)
            condition:
              lambda: 'return cmd == "locate";'
            then:
              - uart.write: [140,1, 4, 62,12, 66,12, 69,12, 74,36]
              - uart.write: [131, 141,1]

ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  domain: !secret wifi_domain
  fast_connect: true
  output_power: 8.5db

mdns:
  disabled: true

uart:
  id: uart_bus
  tx_pin: 21
  rx_pin: 20
  baud_rate: 115200
  debug:

#button:
#  - platform: output
#    name: Clean
#    output: clean_button
#    duration: 200ms
#    id: clean

output:
  - platform: gpio
    pin:
      number: 0
    id: clean_button

script:
  - id: wakeup
    then:
      - homeassistant.service:
          service: esphome.${name}_command
          data:
            cmd: sleep
      - delay: 200ms
      - output.turn_on: clean_button
      - delay: 200ms
      - output.turn_off: clean_button
      - delay: 200ms
      - uart.write: [128, 131]
      - delay: 200ms
      - uart.write: [131, 164, 32, 111, 110, 32] # Writes ON
      - delay: 200ms

Maybe a stupid question, but did you send the serial start command to the Roomba.
After I had issues with a short circuit in my Roomba it completely failed to respond.
But apparently it fully reset the software somehow and you have to send the serial start command at least once to initiate the serial connection again.

I’m not sure if the command is sent by default in all different versions of the code that passed by in this topic.

So it’s always good to check :slightly_smiling_face:

Start is [128, 131], right? I have that in my modified “wakeup” command that I run, and I can see my custom text show up on the 7 segment display. I can also send commands no problem after running Wakeup. Clean, dock, locate, etc. all are sent fine to the Roomba, and the Roomba responds correctly. The only problem is when sending the “sensors_all” or “sensors_battery” - I can see from the UART log that the message is sent to the Roomba, and from the multimeter, I can also see that there’s small blip (drop in voltage) that I can see both on the TX pin of the Roomba and on the RX pin (= PNP emitter) of the ESP32-C3 Super Mini, but there’s nothing in the UART log about anything being received.

I’ve hooked up LD2410Cs using UART to identical boards using GPIO21/GPIO20 for TX/RX, so I’m really at a loss as to what’s going. I was just searching around and saw some people having issues with RX on GPIO20 of the ESP32-C3 when coding using the Arduino IDE unless they enabled CDC, so just in case, I tried moving to pins 7/6 instead, but still nothing.

To quote myself:

if you want (all) the sensors in HA you need a custom component…

The commands I use, are just that, commands. With all the non-sensor commands, you see a clear response by the action the Roomba takes (or not). I never bothered with sensor readings, as I only ever wanted to control custom schedule(s) and whether it should clean or not. So I would suggest to try a custom component if you really need those readings …

If nothing is coming into the UART RX though, a custom component isn’t going to help. I’m just trying to debug the connection before moving to a custom component implementation.

If I read your comment correctly, the hardware IS receiving through UART, the software just doesn’t “know” about it …
Again, my configuration just sends commands to the Roomba.

a custom component isn’t going to help

There’s as reason for the custom component(s) to exist and to my understanding, one of those reasons is to receive (detailed) information from the Roomba.
If you need this functionality the only advice I can give is to test with a custom component …

Right, it appears there is electrical signal, but it’s not being RXed on the UART bus. This isn’t about parsing the signal - there is nothing at all in the UART RX debug, meaning that the ESP32-C3 is not seeing any messages on UART. The custom component is only going to take the byte stream on the UART bus and parse them into sensor data, but if the chip is saying there are no bytes received on the UART bus, it’s only going to give similar errors as others are reporting when something is miswired. (I’ve tried before.) This is where I’m confused, because I think the wiring is correct, and I’ve successfully used the ESP32-C3 Super Mini to receive UART signals on other projects before using the same pins.

I stand corrected. I can’t say I understand why, but when I went to using one of the integrations, sensors are read the UART RX debug messages show up in the logs.

When I started off with Pico Ws a few months back since that’s what I had lying around at the time, I couldn’t get sensors and wasn’t sure about whether I had the transistors wired correctly, so that’s why I went to the “low level” route to see if I can at least get raw messages without using an integration and planned to go back to the integration when that was resolved. I went to replace the linear voltage regulator with a buck converter, and now I had ESP32-C3s, so I decided to switch out the Pico W at the same time, but I wanted to see the raw communications working first before trying the integrations again. I think I read somewhere that the Roomba doesn’t send stop bytes, so I even tried changing the YAML to print UART debug messages on timeout instead, but that didn’t work either…

(belated) thanks for the response.

I gave up on this for a while and got back to it. I plugged it to my pc with an ftdi and tried to use termite to relay commands to it. On turning it on it does put out some random data. When I try to send 0x8087 (start, then clean), oddly enough it was sending bouncing the commands back as if I’d connected the tx and rx pins together. This shouldn’t be happening, right? I’m really a complete novice on the hardware side of stuff. I wonder if I managed to damage the sci at some point.

I did also get started on converting other peoples work to an external component, but since I can’t test it with my roomba it’s kinda stuck, but might be useful to someone else looking to convert to an external component(since if you update the esphome plugin now it won’t compile custom components): GitHub - juhanic/esp_roomba: a rewrite of the custom roomba component for esphome

Mm, if it’s spitting out garbage on startup, are you sure you have the correct settings?
A baudrate of 115200, 8 data bits and 1 stop bit, no parity bits.
The thing that roomba spits out on startup, should be readable.
It should state the firmware version among other things. (not sure what the rest is.)

Awesome work on the conversion!
I’ve been meaning to get to converting, but haven’t found the time to do it yet :see_no_evil:.
I’ll definitely take a look at what you’ve created.
Thanks!

What program are you using to send commands?

I used termite Termite: a simple RS232 terminal

If you have any better suggestions I’m all ears as this certainly isn’t my area of expertise :slight_smile:

I did get the terminal to display the roombas output, just had the wrong baud rate.

Interestingly enough while yesterday it was bouncing back what I sent on tx, now there’s just nothing happening regardless of what I send. I suspect I may have damage the rx pin on the roomba side with the various different attempts at sending it a clear signal via pnp transistors and whatnot, but I’m unsure how to diagnose it

I just tried to connect to my roomba using the FTDI device I posted earlier and using Termite.

I removed the battery
Connected
Then reinserted the battery.

This was the output:

bl-start
STR730
bootloader id: #x470C575C 51BE6FFF
bootloader info rev: #xF000
bootloader rev: #x0001
2007-05-14-1715-L   
Roomba by iRobot!
str730
2012-03-22-1549-L   
battery-current-zero 252

2012-03-22-1549-L   
r3_robot/tags/release-3.2.6:4975 CLEAN

bootloader id: 470C 575C 51BE 6FFF 
assembly: 3.3
revision: 0
flash version: 10
flash info crc passed: 1


processor-sleep

When the led of the roomba clean button is off and you press it to wake the roomba, my output is this:

key-wakeup
slept for 0 minutes 29 seconds

2012-03-22-1549-L   
r3_robot/tags/release-3.2.6:4975 CLEAN

bootloader id: 470C 575C 51BE 6FFF 
assembly: 3.3
revision: 0
flash version: 10
flash info crc passed: 1

battery-current-zero 253

I didn’t try sending commands via termite as it is not easy to send binary data.
Sending commands like “128” does not work (start command).
You need to send 128 as binary.
Termite is only for debugging to see if your roomba/serial is still alive.
If the above works, the esp should work too :slight_smile:.

Hope this helps.