Pocket Spy-Robot




Introduction: Pocket Spy-Robot

About: I'm an 18 year old Robotics engineer from the UK, I competed in Vex robotics for 4+ years which explains my career choice pretty well.

Bored during lockdown? Want to explore the dark realm under the living room sofa? Then the pocket-sized spy robot is for you! At just 25mm high, this small robot is capable of venturing into places far too small for people to go, and feeds back all it sees through a convenient phone app!


Mid-level experience in electronics

Basic knowledge of python and the raspberry pi

A large amount of time



  • Raspberry pi Zero W (Not WH as we won't be using the headers provided)
  • Raspberry pi camera
  • SD card for the Pi (8gb or more is best)
  • 2x 18650 batteries and holder (As a charging circuit is not built in a charger tends to help out too!)
  • 2x 300RPM 6V micro geared motors
  • L293D motor controller
  • LM7805 Voltage regulator
  • 22μF capacitor
  • 10μF capacitor
  • 2.54mm SIL header pins and sockets (2 x 8-long sections of each)
  • 2.54mm 90-degree angled header pins
  • 10x M3 x 8mm Countersunk bolts
  • 4x M3 x 12mm Countersunk bolts
  • 14x M3 nylock nuts
  • Dupont connector kit (can do without but it makes life much easier)
  • 5mm x 80mm aluminium or steel rod
  • Assorted wires
  • Solder board


  • Soldering iron and solder
  • Set of files
  • Assorted screwdrivers
  • Craft knife of some kind
  • Superglue
  • Wire cutters
  • Wire strippers
  • Electric drill and bit set (3mm and 5mm will be used to clean up the holes in the print)
  • 3D printer (Though one can have the parts printed and shipped to you by any one of many such services)
  • Mini hacksaw
  • Multimeter
  • Electrical tape

Step 1: Building the Chassis

I realised pretty early on that whilst gaffer tape is incredible, it probably shouldn't be used to make a sturdy chassis, so 3D printing was the next obvious choice (At some point I'm going to pull this one off, as soon as I do I'll upload it.) The parts are designed to be glued together with the interlocking sections seen in the photos above, as I use an Elegoo Mars printer, which produces beautiful prints but unfortunately has a rather small build plate. This is where the files and superglue come in, the edges labelled above will need to be filed down until they fit snugly inside the slots of the next piece, I found that as 3D printers aren't perfect, this is the best way to get a perfect fit. So once the filing is done, glue the parts together! (Just not your fingers, as I learned one too many times) When gluing the parts together I recommend laying them on a flat surface to ensure they set straight. (Weighing them down can help with this)

A couple of the holes will need drilling out with a 5mm bit (labelled in the 5th image), this should be done incredibly carefully, or with the use of a circular file to minimise risk of snapping the part. To make assembly easier later on, all 3mm holes in the chassis should be drilled out with a 3mm bit to ensure the bolts fit well. Also, on the base of the chassis is a series of hexagonal cutouts for the nylocks to fit into, it's worth using a small file to widen these if the nuts don't fit in easily. I found it was much better to design to the exact size, then remove material where needed, as this results in the best fit.

Parts to print:

  • Chassis1.stl
  • Chassis2.stl
  • Chassis3.stl
  • Chassis4.stl
  • 2x motor_housing.stl
  • 2x Wheel1.stl
  • 2x Wheel2.stl
  • top.stl

Step 2: The Circuit

As the whole point of the project is being compact, the circuit to power the pi itself and the motors is built into a single board which sits atop the pi similar to a HAT, connecting by slotting into headers soldered onto the GPIO. As the motors are quite small and won't require much current, I used a L293D dual H-bridge motor controller to power them as the Pi's GPIO can be damaged if used to drive motors (Back EMF and such as well as over-current). The dual H-bridge uses a set of NPN and PNP transistors such that if transistors Q1 and Q4 are powered and thus allowing current to pass through, the motor will spin forwards. If Q2 and Q3 are powered then current flows through the motor in the opposite direction and spins it backwards. This means that the motor can be spun in both directions without the use of relays or other components and lets us power the motor separately to the pi rather than drawing off it.

The LM7805 provides the pi with power through the 5v GPIO pin but should not be used to power the L293D as the pi can require almost all of the 1A output of the 7805, so it's best not to risk melting it.


If the circuit is built incorrectly and any more than 5v is provided to the pi, or it is put through a different pin, the pi will be irreparably damaged. More importantly, the circuit should be thoroughly checked and tested for shorts, especially across the battery inputs as LiPo's have a tendency to cause issues, *Cough*, explosions when shorted, you should probably avoid that. I found the best way to test this was to test the circuit by connecting a 4-block of AA batteries to the input and measuring the output voltage with a multi-meter. Anyway, safety stuff is over, let's do some soldering!

The board should be built according to the circuit diagram above and in a similar configuration to my circuit as this layout fits neatly over the pi and hasn't yet exploded the LiPos (fingers crossed). It's important that the order below is followed as wires will be routed close to or over other wires and pins, this order means that these wires are done last to avoid shorts. When soldering onto the header pins it is important to slot them into a spare section of header to make sure they don't move when heated.


  1. Cut the board down to size and file the cut edge smooth (mine uses 11 rows by 20 rows and helpfully has letters and numbers to code them) I will give the positions of pins on the board with this coordinate system to make life easier. As the board is 2-sided, I will refer to the side facing the pi as the 'B' side and the side away from the pi as the 'A' side.
  2. Solder the L293D and LM7805 in place, the L293D top left pin resides on B side at position C11. The LM7805 will need its output pins bending such that the metal back side of the chip lays flat against the board, the left pin should be in position P8.
  3. Solder the header pins in place, one should first push the shorter side of the pins through the black block until they are flat against the top of said block. They should be pushed through from the A side with the bottom right corner in hole T1 and soldered from the B side as shown and documented in the images above. When this is done, gently cut away the black blocks and slot the 2 rows of pins into the corresponding headers which shouldn't be soldered to the pi yet, these make sure the pins don't move when soldering them.
  4. Next, solder in the motor and battery pins, 4 wide for the motor and 2 wide for the battery. The battery pins should be placed in slots J4 and K4 on the B side, the motor pins between L2 and O2 on the B side.
  5. The two capacitors need soldering in now, both from the B side. The anode (positive leg) of the 22μF capacitor should be in slot P10 on the B side and should be soldered to P8 with the remaining section of leg, before trimming any left over. The cathode (negative leg) should be put through slot P11 and bent round as seen in the image to connect with P7 (the cathode of the 7805). The anode of the 10μF capacitor should be put through slot P4 and the leg soldered to pin P9, the cathode should be put through slot P3 and connected to P7 in the same way as the other capacitor.
  6. The connecting wires should take the paths seen in the images above, so to save reading time I have compiled a list of the pins which should be connected by these, in order and with specified sides, the side specified is the side which the insulated part of the wire resides on. The coordinates will be formatted such that the first letter signifies side, followed by the coordinate. For example, if I was to connect a L293D pin to an output, the same hole the pin uses couldn't be used so the adjacent hole would be, the pin the wire connects to will be placed either side of the holes they go through. This would look like B: A1-A2 to G4-H4 with the wire going through holes A2 and G4. Note: In my photos the A side has no lettering, assume this would be from left to right.
  7. As you've already got the soldering iron out, now is a good time to solder the motor and battery wires, I'd recommend around 15cm for the motor wires, which should be soldered horizontal to the back plate of the motor to save space, a photo of this is above. Connectors are needed on the other end of the motor wires, I'd recommend putting a tiny amount of solder in these after crimping to ensure a solid connection. The red wire from one battery holder should be soldered to the black wire of the other leaving about 4cm between the two, the other two wires need around 10cm each but instead need a connector attaching to the end to connect to the board.


  1. B: C4-B4 to F11-G11

  2. B: C9-B9 to O1-O2

  3. B: G11-H11 to K5-K4

  4. B: F9-G9 to M1-M2

  5. B: F8-G8 to I4-J4

  6. B: F6-G6 to L1-L2

  7. B: K4-L4 to O10-P10

  8. B: F7-H7 to N7-O7

  9. On A side all wires are soldered to that side, no wires are passed through so only 2 coordinates are needed.

  10. A: O4 to O2

  11. A: O5 to N2

  12. A: O10 to M2

  13. A: O7 to P2

  14. A: R4 to Q2

  15. A: Ground pins O7, O8, R7 and R8 should all be connected.

  16. A: E7 to K4

  17. A: O1 to R10

  18. A: M1 to R11

  19. A: E4 to T1

  20. A: G2 to R6

I'd recommend checking this against the above circuit diagram to ensure correct wiring before you test. Testing of the circuit should be done with a multi-meter set to test connectivity, the pins that should be checked are as follows, but if you're competent with electronics already then test as much as you can. To check: Battery input pins, motor pins, all pins of the header for the pi, and the 7805 input and output against ground.

Step 3: Setting Up the Pi

------Quick note------

In this tutorial I assume that your pi is already setup with an image and connected to the internet, if you're setting the pi up for the first time, I suggest you use the following guide from their website to install the image:


------Remote desktop setup------

I found that life is made much easier if one can work with the pi while still inside the robot, but as the HDMI port is blocked with a standoff, remote desktop is the next best thing. This is pretty easy to setup using a package called xrdp and Microsoft's RDP protocol (built into windows so no faffing on that end).

To setup xrdp first ensure your pi is updated by running the commands 'sudo apt-get update' and 'sudo apt-get upgrade'. Next, run the command 'hostname -I' which should return the local IP address of the pi and you're good to go! Hit the windows key on your computer and open a program called 'Remote Desktop Connection' then enter the IP address of your pi in the Computer field, followed by the username 'pi' if you haven't changed this, hit enter and a connection will be established with the pi.

------Package installs------

The first package you'll need is for the camera, as this isn't my area of expertise I've added a link to the official guide to this, which worked for me perfectly.


Once you've followed this guide and installed the software above you're ready to move onto the next step!

Step 4: The Code

------Quick note------

First things first with the code, programming is far from my favourite part of robotics, so while the program is fully functional, the structure is undoubtedly not perfect so if you notice any problems with it I'd really appreciate feedback!

------Program setup------

Download the attached python file to your pi and place it in the Documents folder, then open a terminal to begin setting up auto-run. To make sure you don't need to remote desktop to the pi every time you want to use the robot we can setup the pi such that it will run the program on start-up. Start the setup by typing "sudo nano /etc/rc.local" into the terminal, which should bring up a terminal-based text editor called Nano, scroll to the bottom of the file and find the line saying "exit 0", create a new line above this and type "sudo python /home/pi/Documents Spy_bot.py &". This adds the command to run the python file as pert of the bootup process, as our program will run continuously, we add the "&" to fork the process, allowing the pi to finish booting rather than looping this program. To exit nano, press ctrl+x then y. After exiting back to the terminal type "sudo reboot" to restart the pi and apply the changes.

------Configuring the motors------

If the motors are spinning in the wrong directions open up the Spy_bot.py file with the text editor and scroll to the motor section of code, which will be labelled with instructions as to the exact numbers to swap round. If the left and right motors are swapped it can be either fixed in the code or by swapping the leads round, if you'd prefer to avoid taking it all apart again, swap any 12 in the motor function with 13 and any 7 for 15.

------Code explanation------

The code is annotated with details of what each section does, such that it can be modified and understood easily.

Step 5: Putting It All Together

Mounting the motors:

Having already glued the chassis together and set the pi up you're now ready to assemble the robot! The best place to start is with the motors, their holders are designed to fit snugly so it's likely that a small amount of filing will be needed on the small nubs on the inside of this, which are labelled in the photo above. The holes in the end of these may also need widening slightly such that the raised gold section on the end of the motors fits inside this. Once the motors can fit snugly inside the housings you can remove the motor and bolt the housings into their position at the rear end of the robot using the M3 x 8mm bolts and nylocks, then slotting the motors back into their places.

Attaching the electronics:

Next, the battery holders and raspberry pi can be bolted in place using M3 x 8mm bolts and nylocks according to the photos, the mounting holes in the pi zero may need widening slightly as the bolts will be tight, the safest and best way to do this is with a small round file and a lot of caution. It's worth putting the battery and motor wires underneath where the pi goes as this makes the whole setup much neater without loose wires everywhere.

Now it's time to add the camera, which can be slotted onto the 4 pegs at the front of the chassis with it's cable already in the back, the other end of the ribbon cable should be gently folded to slot into the camera port of the pi, with the contacts of the cable facing down, take care not to harshly bend the ribbon cable as they tend to be rather fragile.

Mounting the top plate:

The 6 standoffs should be 19 mm long, if not then a decent metal file should do the job, when this is done they should be bolted to the top side of the chassis with the fresh end against the plastic if applicable. The top plate can now be bolted onto these, making sure to gently fold the ribbon cable underneath it.

Adding the wheels:

Onto the last step, the wheels! The two wheels with smaller centre holes should be drilled out to 3mm to fit the motor shafts, though if your 3D printer is calibrated to a high level this shouldn't be necessary. The square holes in all of the wheels will need widening slightly such that a nylock can be placed inside them, when this is done a M3 x 12mm and a nylock needs fitting inside each wheel and tightening enough that the head of the bolt is level with the edge of the wheel. The remaining two wheels will need widening in the same fashion as the others, but to 5mm instead to fit the axle. Once the wheels are all prepared I'd recommend using some form of electrical tape or a rubber band to add a grip surface to them, if tape is used, about 90mm is enough to go round the wheel once. The rear wheels are now ready to be attached, the easiest way to do this is to rotate the motor shaft so that the flat surface faces upwards, and bolt the wheel on with the bolt pointing downwards, leaving 1-2mm between the wheel and the motor housing to avoid catching. The front axle can now be placed through the front blocks and the wheels attached.

This step should conclude the project, I hope that this has been informative and easy to follow, and most of all fun! If you have any suggestions, questions or improvements I can make, please let me know, I'm more than happy to answer any questions and update this instructable where needed.

Pocket-Sized Speed Challenge

Participated in the
Pocket-Sized Speed Challenge

Be the First to Share


    • Plastic Challenge

      Plastic Challenge
    • Robots Contest

      Robots Contest
    • Tinkercad Student Design Contest

      Tinkercad Student Design Contest



    1 year ago

    Looks good! : )

    Pyro jackson
    Pyro jackson

    Reply 1 year ago

    thanks I had already got the pins but I bothered you unnecessarily. Thanks for being kind


    Reply 1 year ago


    Pyro jackson
    Pyro jackson

    1 year ago

    I will definitely be making this project but I would be using cardboard ' cause I do not have 3-d printer...... Since I got Indulged in Robotics I Have been searching for this project and at last I found Yours.
    I can't find SIL pins & sockets for the range of 2 x 8 Please help
    Thanks a lot for sharing


    Reply 1 year ago

    Hi, for SIL pins amazon tends to give good prices, after a quick look the following link or similar items will work fine!
    If you're wanting to use cardboard would a set of 2D files to print out and cut be helpful? If so I'd be more than happy to add these to the instructable.

    Pyro jackson
    Pyro jackson

    Reply 1 year ago

    Thanks for asking me, but I found out that my old rc car had what I needed, so I salvaged the body and changed the design a bit to look like a tank. I nailed everything down carefully (not final) and currently me and my cousin are tempering with your codes. Thanks a lot josh you saved my quarantine😂

    Can you please upload a video of robot working too....


    Reply 1 year ago

    Good to hear! As I've started back at work time is a tough one, though I shall try to get a video uploaded as soon as possible. :-)