{"id":377,"date":"2018-04-25T13:20:45","date_gmt":"2018-04-25T17:20:45","guid":{"rendered":"http:\/\/www.thesmarthomehookup.com\/test_install\/?p=377"},"modified":"2023-04-24T15:48:47","modified_gmt":"2023-04-24T19:48:47","slug":"upgrade-your-old-roomba-to-a-smart-botvac-for-5","status":"publish","type":"post","link":"https:\/\/www.thesmarthomehookup.com\/test_install\/upgrade-your-old-roomba-to-a-smart-botvac-for-5\/","title":{"rendered":"Upgrade Your Old Roomba to a Smart BotVac for $5"},"content":{"rendered":"<p><iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/t2NgA8qYcFI\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen=\"\"><\/iframe><\/p>\n<p><strong>Roomba Automation<\/strong><\/p>\n<p>Robotic vacuums have come a long way since 2008 when I bought my refurbished Roomba 530.&nbsp; Today on the hookup we\u2019re going learn how to add some of the best features of newer botvacs to older Roomba vacuums for just&nbsp; couple of bucks.<\/p>\n<p>Recently I was browsing r slash homeautomation and saw a post about how cool the neato botvac D7 was.&nbsp; I watched a few youtube videos comparing the features on the most recent botvacs, and quickly realized that all of my biggest problems with my Roomba had been fixed, and a few of these new features seemed like \u201cmust haves\u201d to me.&nbsp;&nbsp; Specifically, the most important new features to me were remote start, advanced scheduling, and the ability for the botvac to return to base, recharge,&nbsp; then go back out to finish cleaning.&nbsp; An amazon search for these youtube recommended botvacs lead me to some pretty steep price tags in the 400-800 range and I immediately re-evaluated my plans.&nbsp; When I told my wife this story she looked me dead in the eye and said \u201cjust make the old one do the new stuff\u201d\u2026<\/p>\n<p>Smart woman, and also, Challenge Accepted.<\/p>\n<p>I retrieved the Roomba from the box in the garage and began removing screws.&nbsp; I took the bottom off and didn\u2019t find many exposed wires.&nbsp; I flipped it over and removed the top cover, and to my surprise there was an exposed port for some kind of a PS\/2 looking cable port.&nbsp; Bingo.&nbsp; I thought to myself \u201call I need to do is reverse engineer the signal coming from this port\u201d and I\u2019ll be in control!&nbsp; Before going through this trouble I figured I\u2019d do a quick google search about this port.&nbsp; It turns out there is a well documented API for this port and my long term tinkering project got a whole lot simpler.<\/p>\n<p>Lets take a look at the pins on this port.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; It\u2019s got 2 power pins, 2 ground pins, a pin for changing the serial baud rate, a serial RX pin and a serial TX pin.&nbsp; Reading though the Roomba open interface document it seemed like all I needed was an RX\/TX serial connection so an ESP-01 was a perfect solution for adding wifi and getting my old Roomba into home assistant.<\/p>\n<p>The wiring schematic looks like this.&nbsp; There is one semi complicated bit:&nbsp; For some reason the Roomba TX pin doesn\u2019t output a strong enough signal to register in the ESP-01, so we have to boost it up with PNP transistor.&nbsp; Attach the base of the PNP transistor to the TX pin on the Roomba, the collector to your common ground, and the emitter to the RX pin on the ESP-01.&nbsp; Other than that the connections are simple:&nbsp; ESP-01 TX to Roomba RX, power and ground of the Roomba to the buck converter, and buck converter output to the ESP-01.&nbsp; If you\u2019ve never used a buck converter before you basically just hook up your voltage source and turn the screw at the top to set your output voltage, I just tweak mine and check with a multimeter until I get the voltage I want.. somewhere around 3.2V in this case.<\/p>\n<p>Amazon links for the exact stuff I used are down in the description.<\/p>\n<p>The Roomba uses a pretty simple protocol to send commands.&nbsp; If you send a serial byte of \u201c128\u201d to the roomba\u2019s RX pin it starts the open interface and begins listening for other commands.&nbsp; To make the Roomba clean we send a series of serial bytes 128, 131, 135.<\/p>\n<p>Where 128 starts the open interface, 131 puts the roomba into safe mode telling it to use all of its safety sensors like the cliff sensor and bump sensors, and finally 135 starts the roomba\u2019s cleaning mode.<\/p>\n<p>If we want the Roomba to go back to it\u2019s dock we similarly send 128, 131, 143.&nbsp; The only difference here being that we send 143 which is the \u201cseek dock\u201d command.<\/p>\n<p>And that\u2019s really it for sending commands, you can do all kinds of other things like playing specific tones and songs, turning on LEDs, and even controlling the motors directly, but I wasn\u2019t really interested in those for this project.&nbsp; If I had just stopped here my total project would have taken 30 minutes, but I wanted MORE.<\/p>\n<p>The next thing I wanted to do was gather information from my Roomba.&nbsp; This proved to be MUCH more difficult.&nbsp; The open interface documentation seemed to suggest that all I needed to do was send 128, 142, and then the sensor I wanted to read.&nbsp; Unfortunately, all of my attempts to use this command returned jibberish instead of the unsigned long variable it was supposed to return.&nbsp; I spent significantly more time trying to figure this out than I\u2019m comfortable admitting, but I eventually found an Arduino library made by a guy named Mike McCauley that really helped me get a working program together.&nbsp; The sensors that I\u2019m utilizing in my sketch are the battery capacity sensor, the battery maximum capacity sensor, and the charging state sensor.<\/p>\n<p>My entire smart home runs on MQTT, so it was the obvious choice of protocol for my Roomba.&nbsp; I publish MQTT messages to three topics with my Roomba: Roomba\/battery which receives a percentage value calculated by dividing the \u201ccurrent battery capacity\u201d by the \u201cmax battery capacity\u201d and then multiplying by 100\u2026 Roomba\/charging which returns an integer between 0-5 corresponding to THESE different charging states, and Roomba\/status which updates when the clean or seek dock command is sent to the Roomba.<\/p>\n<p>Alright, are we ready to make it?<\/p>\n<p>First, Load up my Arduino sketch from down in the description, put in your wifi information and mqtt information.&nbsp; You can change the MQTT ClientID and topics if you\u2019d like, but you don\u2019t need to.<\/p>\n<p>Next, you&#8217;ll flash the program to your ESP-01 using a USB to TTL adapter, hook up the pins according to this diagram.<\/p>\n<p>After you\u2019ve got the program loaded you can use your MQTT client of choice to make sure it works.&nbsp; Just power up the chip and you should see an \u201crebooted\u201d message in the topic&#8221; checkIn\/roomba&#8221;.&nbsp; That means your flash was successful.<\/p>\n<p>Once we&#8217;re sure it&#8217;s working we can make it as small as possible.&nbsp; You can desolder the pins from the ESP-01 by pushing them through from the top using a hot soldering iron. Once they are pushed through you can pull them out individually with a pair of nippers<\/p>\n<p>Solder up your parts as shown in the schematic, and after you\u2019re done you should have something that looks like this.&nbsp; Plug it in to your Roomba, press the roomba\u2019s power button and you should see data start streaming in.<\/p>\n<p>Now that our Roomba communicates with us and we can issue commands to it the rest of the setup will happen in home assistant and node red.&nbsp; In my configuration.yaml file I added two MQTT sensors for the battery and the status, and an MQTT switch to issue commands and restarted home assistant to load them in. I also did a little bit of customization to get the battery to show as a percent, and I changed the icons on each entry to make them look nicer.<\/p>\n<p>To get an accurate status for the Roomba I use a little bit of nodeRED magic.&nbsp; I didn\u2019t write this into the Arduino code because I still wanted to get battery status 0-5, but I wasn\u2019t happy with just having 0-5 listed as a status in home assistant.<\/p>\n<p>What I do, is I read the Roomba\/status mqtt feed and save it to a flow wide variable called Roomba, then I read the charging feed and send it to a change node.&nbsp; If the charging state is 1, 2, or 3 that means the Roomba is on the charger and it sends an mqtt message of charging to the topic attached to the mqtt sensor in home assistant.&nbsp; If the charging state is 0 or 4 that means the Roomba is not on the charger,&nbsp; so I want the status to tell me the class command issued, which will either be cleaning, or returning.&nbsp; If the charging state is 5, something is wrong, so the status will read \u201cerror\u201d.<\/p>\n<p>Looks nice.<\/p>\n<p>Finally, I needed to get those must-have features implemented\u2026 The first one was done: Remote start is&nbsp; accomplished via the home assistant switch we just installed.&nbsp; Easy.<\/p>\n<p>Next was advanced scheduling, for me this meant that I generally wanted the Roomba to run while my wife and I are at work, I never wanted the Roomba to run when people are home for days off, and I also wanted to be able to disable the schedule when we have company in town since that usually means there are suitcases and clothes on the ground that could cause problems.&nbsp; Here\u2019s how I accomplished this in NodeRED.<\/p>\n<p>One of my favorite nodes is this light scheduler node, if you don\u2019t have it yet I highly recommend you install it in pallet manager by searching for node-red-contrib-light-scheduler (I\u2019ll put that name in the description).&nbsp; I use this to generate a schedule with a \u201cstart\u201d payload for turning on the Roomba.&nbsp; Next it checks the current state of two home assistant components:&nbsp; House guests is a simple input Boolean in home assistant that I toggle when we have people staying with us, and Home Occupied uses my google wifi to sense when my wife and I are home by detecting when our phones are connected to wifi.&nbsp; Both of these states from home assistant are read and each has the ability to halt the flow if they are true.&nbsp; If the flow makes it to the end it will send the \u201cstart\u201d command via MQTT to the roomba.<\/p>\n<p>The last must have feature is that I wanted my Roomba to clean as much as possible while was gone, in other words, I want it to clean until it needs to dock, charge back up to 95%, then go clean again as long as it will be done by the time I get home from work.&nbsp; To do this, we start with the previous Roomba schedule.&nbsp; I have my On payload set to \u201cstart\u201d which is the MQTT command that needs to be sent to the Roomba, and I have my off payload set to \u201coff\u201d which isn\u2019t a command the Roomba will recognize.<\/p>\n<p>You\u2019ll notice that in addition to using this schedule to initially start the Roomba at 8am, it also goes to this change node.&nbsp; In this change node I set a flow wide variable called roombaSchedule using the value from my payload which will either be \u201cstart\u201d or \u201coff\u201d.<\/p>\n<p>Below that I have an MQTT feed from the Roomba\/charging topic, this message is sent every 5 seconds and flows into a \u201creport by exception\u201d node that only continues the feed when the value has changed from the previous value.&nbsp; After that it checks for a charging value of 3, which corresponds to the roomba\u2019s \u201ctrickle charge\u201d that activates when the battery reaches about 95%.&nbsp; If the charging state goes to trickle charge it sends the flow on, sets the payload to that flow wide variable from before called roombaSchedule and sends it on to the Roomba.&nbsp; If it is between the hours of 8am and 1pm roombaSchedule will be equal to \u201cstart\u201d and it will send the Roomba out again to clean, if it\u2019s not within those hours it will send an MQTT message of off, which essentially does nothing.<\/p>\n<p>Now that I had my Roomba doing exactly what I wanted I decided to spend a little bit of money to upgrade the old Nickle Cadmium battery to lithium ion, and I bought a replacement pack of brushes for my now 10 year old Roomba.<\/p>\n<p>I\u2019ve gotta say, this thing cleans like a champ.&nbsp; I clean the bin once a week, and I\u2019m always dumbfounded by the amount of crap that it finds in my house, where does it all come from?<\/p>\n<p>One last note:&nbsp; If you\u2019re going to mess around with this (and I encourage you to do so), I finally figured out that occasionally when unplugging and plugging in wires to the OI port I made the Roomba angry and it would stop responding to any commands on TX or RX.&nbsp; The only way to fix this is to pull the battery momentarily and then reconnect it.&nbsp; I was hours into troubleshooting before I figured this out and it was driving me CRAZY, I might have just saved you 5 hours of your life.<\/p>\n<p>I hope this video inspired you to pull that old Roomba out of storage, or maybe buy one off craigslist and breath some new life into it.&nbsp; I\u2019m confident that if you follow the instructions in this video you\u2019ll be able to upgrade your old Roomba in about 1% of the time it took me to google around to hundreds of dead forum posts and outdated how-to articles.&nbsp; I\u2019m going to fill the video description with every link you need to be successful hacking your Roomba.&nbsp; If you enjoyed this video please consider subscribing! And as always, thanks for watching the hookup.<\/p>\n<h3>Links<\/h3>\n<p>Arduino Sketch:<br \/>\n<a href=\"https:\/\/github.com\/thehookup\/MQTT-Roomba-ESP01\/blob\/master\/RoombaESP01_CONFIGURE.ino\">https:\/\/github.com\/thehookup\/MQTT-Roomba-ESP01\/blob\/master\/RoombaESP01_CONFIGURE.ino<\/a><\/p>\n<p>Required Arduino Libraries:<br \/>\n<a href=\"http:\/\/www.airspayce.com\/mikem\/arduino\/Roomba\/Roomba-1.3.zip\">http:\/\/www.airspayce.com\/mikem\/arduino\/Roomba\/Roomba-1.3.zip<\/a><br \/>\n<a href=\"https:\/\/github.com\/jfturcot\/SimpleTimer\">https:\/\/github.com\/jfturcot\/SimpleTimer<\/a><br \/>\n<a href=\"https:\/\/github.com\/knolleary\/pubsubclient\">https:\/\/github.com\/knolleary\/pubsubclient<\/a><\/p>\n<p>Configuration.yaml Additions:<br \/>\n<a href=\"https:\/\/github.com\/thehookup\/MQTT-Roomba-ESP01\/blob\/master\/configuration.yaml\">https:\/\/github.com\/thehookup\/MQTT-Roomba-ESP01\/blob\/master\/configuration.yaml<\/a><\/p>\n<p>customize.yaml Additions:<br \/>\n<a href=\"https:\/\/github.com\/thehookup\/MQTT-Roomba-ESP01\/blob\/master\/customize.yaml\">https:\/\/github.com\/thehookup\/MQTT-Roomba-ESP01\/blob\/master\/customize.yaml<\/a><\/p>\n<p>NodeRED Flows:<br \/>\n<a href=\"https:\/\/github.com\/thehookup\/MQTT-Roomba-ESP01\/blob\/master\/nodered.txt\">https:\/\/github.com\/thehookup\/MQTT-Roomba-ESP01\/blob\/master\/nodered.txt<\/a><\/p>\n<p>NodeRED scheduling node:<br \/>\n<a href=\"https:\/\/www.npmjs.com\/package\/node-red-contrib-light-scheduler\">https:\/\/www.npmjs.com\/package\/node-red-contrib-light-scheduler<\/a><\/p>\n<p>Wiring Schematic:<br \/>\n<a href=\"https:\/\/github.com\/thehookup\/MQTT-Roomba-ESP01\/blob\/master\/schematic.JPG\">https:\/\/github.com\/thehookup\/MQTT-Roomba-ESP01\/blob\/master\/schematic.JPG<\/a><\/p>\n<p>Parts:<br \/>\nESP-01: <a href=\"https:\/\/amzn.to\/2qVB2p8\">https:\/\/amzn.to\/2qVB2p8<\/a><br \/>\nPNP Transistors: <a href=\"https:\/\/amzn.to\/2FaUfrS\">https:\/\/amzn.to\/2FaUfrS<\/a><br \/>\nBuck Converters: <a href=\"https:\/\/amzn.to\/2K7FY33\">https:\/\/amzn.to\/2K7FY33<\/a><\/p>\n<p>Roomba upgrades:<br \/>\nLithium Battery:<a href=\"https:\/\/amzn.to\/2JnbGbp\"> https:\/\/amzn.to\/2JnbGbp<\/a><br \/>\nBrush Upgrades: <a href=\"https:\/\/amzn.to\/2qVDTOB\">https:\/\/amzn.to\/2qVDTOB<\/a><\/p>\n<p>Tools:<br \/>\nSoldering Iron: <a href=\"https:\/\/amzn.to\/2JUP3Mm\">https:\/\/amzn.to\/2JUP3Mm<\/a><br \/>\nUSB to TTL Adapter: <a href=\"https:\/\/amzn.to\/2Hak9BW\">https:\/\/amzn.to\/2Hak9BW<\/a><\/p>\n<p>Roomba OI Document:<br \/>\n<a href=\"http:\/\/cfpm.org\/~peter\/bfz\/iRobot_Roomba_500_Open_Interface_Spec.pdf\">http:\/\/cfpm.org\/~peter\/bfz\/iRobot_Roomba_500_Open_Interface_Spec.pdf<\/a><\/p>\n<p>Meh, I&#8217;ll just buy a new one:<br \/>\nEcovac Deebot N79 on sale: <a href=\"https:\/\/amzn.to\/2HtjGab\">https:\/\/amzn.to\/2HtjGab<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Support my channel:<br \/>\nPatreon:&nbsp;<a href=\"https:\/\/www.patreon.com\/thehookup\">https:\/\/www.patreon.com\/thehookup<\/a><\/p>\n<p>Music by BenSound.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Roomba Automation Robotic vacuums have come a long way since 2008 when I bought my refurbished Roomba 530.&nbsp; Today on the hookup we\u2019re going learn how to add some of the best features of newer botvacs to older Roomba vacuums for just&nbsp; couple of bucks. Recently I was browsing r slash homeautomation and saw a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2614,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-377","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects"],"acf":[],"mb":[],"mfb_rest_fields":["title","gutenberg_elementor_mode"],"_links":{"self":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/comments?post=377"}],"version-history":[{"count":4,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/377\/revisions"}],"predecessor-version":[{"id":2369,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/377\/revisions\/2369"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/media\/2614"}],"wp:attachment":[{"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/media?parent=377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/categories?post=377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/tags?post=377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}