This page has three parts. Part one (this one) covers the disassembly of the Dirt Devil and the replacement of its chip with a WEMOS D1-D2. This adds the feature of controlling the Dirt Devil over Wifi. I think it works pretty well, but lacks some features like automatic homing in and charging.

Part two will describe how to replace the WEMOS D1-D2 with a LOLIN32. This board also has the OTA possibilities, but has a lot more pins. This lets us add stuff like sound, extra bumpers and last but not least IR direction finding and automatic docking.

Part three has some links to other sites that describe the Dirt Devil and the hacking of the hardware.

By the way: if you have a different robot cleaner, this page may still be helpful, as long as you have access to the inputs to the motors and sensors and can disable the original intelligence..

Part one

The Dirt Devil is a cheap robot vacuum cleaner. I bought mine in september 2017 for 70 Euros, postage included. It is not very smart, no automatic docking with a reloading station or stuff like that. You turn it on, put it on the floor, and hopefully it will have cleaned most of your living room before the batteries run out.

The good thing is: it is (relatively) cheap and simple, you can rip it apart and have fun with it.

    Before we tell more about the fun we had with the DirtDevil, it is good to know the limits of not only the robot but also of yourself. Take me as an example: I am a rather good programmer but absolutely not comfortable with a soldering iron or electronic components that have more than two, clearly labelled exits. Resistors I can handle. Solenoids too. Diodes and condensators... sometimes. Transistors? No way!

    Enter the Arduino.

    Arduinos and its descendents are small and simple programmable 'computers' consisting mainly of (from my point of view) 'ins' and 'outs'. You can plug wires into those ins and outs and attach those wires to e.g., a thermometer module, and from that point the output of that thermometre is just another variable in a program. Plug a LED in a different set of 'ins' and 'outs' and if the thermometer variable drops below a certain value (e.g, zero) you can light the LED by a line like

    if (thermometer<0) digitalWrite(led,HIGH);
    
    OK, it is a bit more complicated than that, but not very much so. Programmers like me are used to adding libraries, and the selection of the 'ins' and 'outs' generally are described very clearly by the documentation of the particular sensor.
From this point I will assume that you can program an Arduino and attach simple devices to it, with one difference: I will go on calling a programs a program and not, like the Arduino crowd, a 'sketch'. Life is complicated enough. You can use a genuine Arduino, in which case you don't have to worry about the WIFI and OTA parts. If you use a WEMOS or LOLIN32 (see below), you will have to load the correct extensions to the Arduino programming environment. How to do that also falls outside the scope of this tutorial.

Now the Dirt Devil robot. Ignoring the 'intelligence' in its central processor, it is nothing more than two motors that drive the wheels, left and right, that can each go either forward or backward. There is a bumper in the front that can either be free or activated (when it bumps against a table leg). There are three LEDs. And a battery. The aforementioned intelligence sees to it that the robot travels more or less randomly through your living room and when it runs up to a table leg, the bumper will send it a signal to back up and choose a slightly different route.

Can you do better? That is up to you, but to reprogram the thingy a lobotomy of the old brain is needed and then the replacement of that old brain by something that you can program yourself like the Arduino board. In our project we choose a WEMOS D1-R2 as the new brain. Think of the WEMOS as more or less similar to the Arduino (actually based on the esp8266), but with a WIFI chip added. This opens the possibility to command the WEMOS by a smartphone, plus (and more important to me) you can also reprogram the WEMOS 'On The Air' (OTA), i.e. without having to connect it to an USB port every time you want to change the program. On the down side it runs on 3.3 Volt whereas the Dirt Devil delivers 5 Volt. In theory you should bring the incoming signals like the original bumber and sensors down to 3.3 Volt, but I never bothered and no harm came from it. Yet.

Step 1: lobotomy

The first, and most difficult part is the removal of the brain of the Dirt Devil. Taking apart the victim is easy: six screws on its belly and two on the bumper. You will have to remove an anti-slip strip before you can find these last two. The electronics are on a crescent shaped PCB (Printed Circuit Board) in the front. See here for a Youtube movie of the proceedings.

Don't get me started on Youtube as a medium for the transfer of facts and knowledge. No! Don't!

While you take apart the Dirt Devil, you may want to poke around in its innards. In that case you should realize that there are some failsafes that prevent the motors from running. One is if the sensors underneath do not "see" the ground. Also there is an optocoupler on the PCB that has to be interrupted. Normally this happens when the dirt container is in place, but otherwise you should put something between its contacts (I just used a piece of tissue; see the red arrow in the photograph of the PCB). There are a dozen connectors that attach the motors and sensors to the PCB. I dug out some color markers and marked them before removal so I could easily put everything back later. Pull each of them off the board with a small pair of pliers. Then remove the four screws on top of the PCB and you have the brain of the creature in your hands.

So far you have done nothing that cannot be reversed. But now you have to remove the old intelligence. It resides in a chip marked RV285R which you will not find on Google, but actually it is a EM78P153K (which also tells me nothing). Anyway, the 'ins' (the bumper) and the 'outs' (the motors and LEDs) are connected to this chip.

P50Blue LED P51Red LED
P67Bumper P52Wheel motor
P66Speaker? P53Wheel motor
Vdd5 Volt VssGround
P65Accu leeg P60Accu vol
P64ventilator V61Wheel motor
P63deksel? P62Wheel motor
The original chip and pinout

  

You have to replace this chip by an Arduino or WEMOS. Also, you can solder the wires right on top of the connections of that chip and leave it in place, like Markus Mueller (of the Youtube movie) did. The Arduino is strong enough to override the RV285R and if you are careful, you can reverse the procedure.

PCB with chip removed. You can see the 2 x 7 holes in the center of the board (blue-green line). The red arrow points to the optocoupler with a fluff of tissue between the prongs

I myself preferred to take the original chip out. For me this was the difficult part: as I said, I am not comfortable with a soldering iron and indeed I damaged some traces of the PCB in that they came loose from the substrate.

Step 2: the braintransplant

I then soldered Dupont wires with connectors and all into the holes where the RV285R once lived. After that I hotglued the PCB traces and the dupont wires into a solid mass so that the damaged PCB traces could not work loose. Of course I also noted the color of the wires and marked wires with the same color extra with a felt marker. I then connected the WEMOS to the wires, powered it on, checked for smoke and then started programming it.

Dirt Devil reassembled with a medusa's head of wires protruding.

If you use OTA, you have to attach the WEMOS to the USB port of your computer for the first download. After that you can attach the board to the wires of the Dirt Devil and leave it there while you tinker with the program. Note that the WEMOS then gets its power from the same circuit as the original chip just by inserting the wire that you soldered to the PCB into the V5 connector and the opposite ground wire to the GND of the WEMOS. If you follow my setup, the other wires get connected to D0-D7 and, of course to V5 and Gnd.

Note that some pins are not connected. They had something to do with the battery reload circuit, because there are some issues on that point. I damaged them anyway, so they will not be used.

After I got my program reasonably well up and running, I cut a hole in the top cover of the Dirt Devil, eased the wires through he hole and screwed the Dirt Devil together again. I then cut a hole in the lid of the dustbin, so I could lower the WEMOS into it, as I wanted the silhouette as low as possible. For the same reason I bent the pins going into the WEMOS in an angle op 90 degrees. Still, some sticks will have to be added to the bumper, so the Dirt Devil will not knock its new brain out under a cupboard. In any case you will have to increase the height of the bumper by a strip or pins sticking up...

Hole cut into the lid of the Dirt Devil

Arduino sitting in its hole. PVC strip fitted to bumper to increase height. Note the hole up center for the IR sensor

Step 3: The programming

Now you can just download my program into the WEMOS, load the appropriate website in your browser and check whether the Dirt Devil reacts. Start with the ventilator of the vacuum cleaning function, it is an easy on-off switch and the Dirt Devil will not do a lemming from the top of your desk to the floor because you accidentally activated the wheels. If nothing happens and not even the lights blink, check and recheck your wiring. Or perhaps your battery is dead and you have to recharge it?

    This is a link to an intermediary state of the program, where the basics are enabled, but no IR sensor yet. Use at your own risk!

    The program expects a webpage on your home server (servername) with the name 'dirtdevil.php' to get the time. It displays te time for the Dirtdevil to read and will accept output that the Dirtdevil sends (time, voltage and a message):

        <?php
        $remote_addr=$_SERVER['REMOTE_ADDR'];
        $password=$_REQUEST['password'];
        $lading=$_REQUEST['lading'];
        $tijd=$_REQUEST['tijd'];
        $message=$_REQUEST['message'];
    
        $datum=time()+3600;
        if (date('I')==1) $datum+=3600;
        echo "Time:".$datum."<br>";
        echo "dirtdevil";
     
        $fp=fopen("lading","a+");
        fputs($fp,$tijd." ".$lading." ".$message."\n");
        fclose($fp);
    
        

I will now describe my program and the problems I encountered, so you can improve on it. Please note that my examples for the moment only cover the basics. The best strategies for traversing a room with obstacles I leave to you.

  • The wifi part was easy because I already had completed other simple projects that featured small servers on a WEMOS board. I will not go into detail here: check the code.

  • However, programming by OTA means that the Serial link cannot be used for debugging. I suggest that you make use of the server capabilities of the WEMOS to report on the values of variables, turn motors on or off individually etc. Alternatively, make a data-only cable by cutting the 5 Volt wire in an old USB cable (didn't work for me, but a normal USB cable worked just fine although some say that it should not work.).

  • The OTA stuff I just copied and pasted from the examples that came with the Arduino programming environment.

  • The pins of a WEMOS are different from the Arduino. There seems to be ony one analog port (A0) and 9 digital ports (D0-D8). Most other pins duplicate the digital pins for, e.g. I2C and similar stuff. So with four connections for the wheels (back and forth), one for the ventilator, two for the LEDs and one for the speaker there is nothing left apart from the A0 (which has its own limitations). I wanted to add a docking facility, so I discarded the speaker in favour of an IR sensor. Then, I will want to measure the level of the battery, where the A0 comes in.

  • A different problem was the interrupt needed for the bumper. On the Arduino site it says that the Arduinos have just a few interrupts on particular pins. The WEMOS however is based on the esp8266, where almost all pins have an interrupt. That makes it easier to allocate the pins, because you don't have to reserve, say, pin 2 for the bumper. I had some real trouble in fixing this interrupt and finally settled for a simpler construct that just read the bumper.

    NOTA BENE The bumper is wired to the same pin as are the bottom sensors! So if you are experimenting with the bumper, see to it that the Dirt Devel stands on a flat surface and is not upside down or suspended! If the bottom sensors cut in, the bumper will not operate!

  • To build a docking station, you will first need an indication of the power left in the batteries (or else how do you know that docking is necessary?).
    A voltage divider with a 100K and a 10K resistor connected to the WEMOS one and only analog pin (A0) did the trick. The 100K resistor got wired to the positive pole of the battery and the 10K to the negative side. The Dirtdevil will run fine for more than an hour, dropping from 14V to 12V, after that the performance will deteriorate and the machine will stop in a few minutes. However, the voltage divider will slowly drain the battery. I then took an 1 M and a 100K resistor, that draw less current but are a bit more imprecise. A 0.1 µF cap over the smaller resistor should cure that. YMMV.

    Actually, according to Librevac's scheme, there are two pins attached to the battery electronics from which to read its charge. As I said, I damaged some traces when de-soldering the original chip, and therefore I had to build my own...

TODOS and PROBLEMS:

An obvious improvement would be to attach a sensor for finding a loading station when current is low

However, at this moment the current to the Wemos is cut when a loader is attached. No idea why this is so. Probably to prevent high currents from damaging the original chip. That means that even if the battery is reloaded, the Wemos will not react until the current is cut again.

Also, if the switch on the Dirtdevil is in the off position, and power is connected, the ventilator will start running until I disconnect the positive lead from the Wemos board. In that position the battery will load, but it is very hot after a nignt at the loader and has to be taken out and reinserted before it delivers its power again. Possibly the original chip took care of that, but how?

(To be continued)

Part two: using an ESP32

I have been warned not to experiment with both the usb cable and the power source of the Dirt Devil attached at the same time. That means that you cannot debug by sending information to the serial terminal of the ArduinoIDE. The solution should be to take an old usb cable and to cut the red wire inside it. Now the cable will not be connected to the 5 Volt souce of the USB terminal. Didn't work for me though, whereas a straight USB cable worked just fine.

If you cut the wire, Do not forget to label the cable as "data only"!

A problem is that the WEMOS offers easy OTA updates and lots of memory, but not enough IO pins. The UNO/ESP8266 combo on the other hand has lots of pins, but no OTA. So in this second project I will be using a LOLIN32 that like the WEMOS offers Wifi and OTA and also lots of pins..

Actually it was as easy as replacing the WEMOS by a LOLIN32 (and of course recompiling the source for the esp32 boards). The 5V coming from the PCB went into the 5V pin of the LOLIN, the negative in the GND and then you have to assign the A0-A14 pins of the LOLIN to the corresponding functions.

A caveat though. As the LOLIN has 12-bits Analog capacity, they run from 0 to 4096 in stead of 1024. This means that in the function that reads the voltage from the analog pin, the result must be divided by 4096 in stead of 1024.

Now I have lots of pins left for other enhancements. The first that comes to mind is a self docking function on a battery low condition. This means that I have to design a docking station from the junk I have lying around with an IR led.

The docking station consists of a IR emittor (LED) in series with a 47 Ohm resistor on 6 Volt. Of course I will have to build some contacts with a current of 18 Volt against which the loading contacts of the Dirt Devil will rest. Mmmmm....

A second enhancement would be two more contacts on the bumper, to tell if an obstacle is to the right or to the left of the robot (see picture).

The bumper, with two switches added

Light and sound. The Dirt Devil has two leds and a speaker. With the extra pins I can give signals about its condition. For some reason the leds and the speaker have stopped working with the LOLIN32. I can live without the leds, but a speaker is really needed.

The LOLIN32 board is much smaller than the WEMOS and now I can squeeze it between the top of the battery compartiment and the cover. Even better, if and when I get a new LOLIN32, I can omit the headers and solder the wires directly to the board. We will have to see about that. In any case, there is a kind of ridge at the center back inside the cover, just above the battery. You should remove that to get more space.

The LOLIN32 on top of the battery compartment (red arrow) and the inside of the top cover showing where the ridge was removed (black arrow). Most of the LOLIN32 is obscured by an 8-pins connector lying flat on the board.


Part three

Acknowledgments and further information.

Thanks to Markus Mueller (of the Youtube movie) I could figure out which was which.

More about the Dirt Devil and the Arduino (dutch): on the site of Thijsmans. For the moment nothing new, but hopefully that will change soon. Meanwhile there is a discussion between him ane me over email (also in dutch). The two pictures mentioned are here and here.

Frank Weijers built an ultrasonic sensor for a newer model of the Dirt Devil, also using a wemos board. This sensor detects objects like rugs and carpets, that are too low to activate the bumper. See his instructables page for details.

Also this site with a more negative review of a Dirtdevil-like robocleaner. This site has more information on the pinout.
I think this last author is overly negative. Sure, the Dirt Devil is lacking in bells and whistles, but this makes it more suitable as a hacking platform, not less.

Another pinout, from Librervac (see notes at end of page)

Pin Type Function pullup/pulldown active Comment
1out green LED high
2in bumper or sensor +5V low
3out buzzer requires PWM, also 1-pin connector on the board is connected here
4power VDD
5in battery low +5V
6out vacuum and side brushes high
7in top lid
8out left wheel forward high
9out left wheel back high
10?battery charged probably input, when charging "high" means "charged"
11power VSS
12out right wheel back high
13out right wheel forward high
14out red led also connected to unpopulated port, no idea what these port do (both are connected together)

I can be reached as paai @ paijmans.net