The littlest roomba control
How to control a roomba with the least effort
Since I got my hands on an ancient iRobot roomba 555 I wanted to be able to control it via HomeAssistant.
This is my example how you can control roomba with esphome. Esphome will is a quite nice tool to program esp microcontrollers (esp32 or esp8266) to communicate with homassistant by just using a single yaml file.
In my case I just want to make the roomba start cleaning when I have left my
home for a couple of minutes. This is why I only need one action: cleaning.
To bring the roomba into cleaning mode we can send the byte-code 128,131,135
.
Thats all.
load uart
The esphome-config needs a uart-section where you define the IO-ports of your esp. According to the roomba handbook wee need a baudrate of 115200. Other roombas might need a different baudrate.
uart:
baud_rate: 115200
tx_pin: GPIO12
rx_pin: GPIO14
Create the wakeup-pin
The roomba needs a wakeup pin. Setting the pin to high and back to low will bring the roomba to life.
switch:
- platform: gpio
inverted: true
pin: GPIO5
id: brc
name: "wake-pin"
on_turn_on:
- delay: 500ms
- switch.turn_off: brc
- delay: 100ms
Create a virtual start-switch
Esphome can create virtual switch which makes an action available within homeassistant. The Start button has the following function:
- Set the wakeup-pin to high and low to make sure roomba is listening to the uart-bus
- wait 500ms. Just to be sure Roomba is in attention-mode
- write our magic bytecode 128, 131, 135
- turn-off the switch itself - this way we can activate it again later
- platform: template
id: start
name: "Start Roomba"
turn_on_action:
- switch.turn_on: brc
- delay: 500ms
- uart.write:
- switch.turn_off: start
The full YAML-File:
Alltogether this looks a following:
esphome:
name: roomba
platform: ESP8266
board: esp12e
ota:
password: wifi_password
logger:
api:
wifi:
ssid: wifi_ssid
password: wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Roomba Fallback Hotspot"
password: wifi_password
captive_portal:
web_server:
port: 80
uart:
baud_rate: 115200
tx_pin: GPIO12
rx_pin: GPIO14
switch:
- platform: gpio
inverted: true
pin: GPIO5
id: brc
name: "wake-pin"
on_turn_on:
- delay: 500ms
- switch.turn_off: brc
- delay: 100ms
- platform: template
id: start
name: "Start Roomba"
turn_on_action:
- switch.turn_on: brc
- delay: 500ms
- uart.write:
- switch.turn_off: start