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 coupling 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 Dirt Devil, 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 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 an Arduino, in which case you don't have to worry about the WIFI and OTA parts. If you use a WEMOS (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 an Arduino board. We selected 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.

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
P65nothing P60nothing
P64ventilator V61Wheel motor
P63nothing 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 may or may not have had a function in the original PCB, but the WEMOS has no pins free any more. I wonder whether they had something to do with the battery reload circuit, because there are some issues on that point.

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. 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:

        <?php
        $datum=time()+3600;
        echo "Time:".$datum."<br>";
        echo "dirtdevil";
         ?>
        

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.

  • 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, put pinMode INPUT_PULLUP and mode CHANGE did the trick:
        volatile buttonState;
        ...
        
        void setup()
        {
        pinMode( CONTACTSENSOR,INPUT_PULLUP); //kontaktsensor 
        attachInterrupt(digitalPinToInterrupt(CONTACTSENSOR), bumper, CHANGE);
        buttonState=0;
        ...
        }
    
        void loop()
        {
        ...
        if (buttonState)
          {
          buttonState=0;
          ...
          }
        ...
        }
        
        void bumper
        {
        buttonState=1;
        }
        
    

  • 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 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....

(To be continued)

TODOS and PROBLEMS:

attaching sensors for finding a loading station when current is low

build a home/loading station.

figure out why now the accu does not stop loading. 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? There are two undocumented pins left.

The voltage divider does not seem to be sensitive enough to give a good indication of the juice left in the battery.


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