Monday 22 August 2016

PiZero Bot V2.0

Back in December 2015 I created my first Raspberry Pi Zero based Bot. It was a little ungainly with cables looping all over it and a USB WiFi dongle sticking out the side but it was relatively small, moved around and, at the time, I felt there was still plenty of room to make it more compact.
PiZero Bot V1.0
The aim of the next variant was to squeeze all the components into a mint tin that was only slightly larger than the Pi Zero itself. This proved something of a challenge and it wasn't until the release of Pimoroni's Zero LiPo board and Average Man's ProtoZero development board that I was able to get everything compact enough to fit inside.

The tin is only slightly bigger then the Pi Zero
I had never quite figured out how to best connect the AdaFruit PowerBoost to my PiZero without it getting in the way of the other components I needed to squeeze in, but the Zero LiPo fits snugly onto the Pi Zero PCB, taking up a minimal amount of space. With the power in place next step was to come up with a more minimal motor driver. After ordering a pack of L283D motor controllers (Buying several in case I killed one) I mounted it upside down on the ProtoZero board, after doing several dry runs to ensure I had enough space to fit in the wires and somewhere for the motors to attach.
A thin, PCB sandwich.
As this bot has no sensors (yet) it has to be manually controlled. After several attempts to squeeze in a USB dongle failed I settled on using a TTL to Bluetooth adaptor (A HC-06 module), soldering it to GPIO pins 15 and 18, the Tx and Rx pins on the Raspberry Pi. This particular TTL module is designed for 3.3V IO operations, so I didn't need to risk driving the pins at 5V, or trying to find space to fit a 5V to 3.3V converter.  Using an app called 'BlueTerm' I could now connect to the serial console on the Raspberry Pi and send it commands from my phone.

Hardware is of little use without software to control it. Normally I'd be looking at connecting up a PS3 DualShock controller to drive the bot around, however that isn't quite so easy to set up over a serial link, so it was time to look at a different way to control a bot. A few weeks previous I had taken a look at the GPIO Zero python library and knew it had a variety of helper classes. Taking a look at the currently supported devices I found that it not only had a GPIO based Motor class but a fully implemented Robot class, allowing a 2 motor robot to be up and running in 3 lines of python.

from gpiozero import Robot
r = Robot(left=(23,22), right=(25,24))

A couple of tweaks to the connections to make sure the motors were going in the right direction and it was time to fit everything inside the tin. Being a metal tin it was conductive on the inside and, as I didn't want a short, I covered it as best as I could with Kapton tape, adding extra tape to the PiZero itself for extra safety.

With the motors and ball caster glued into place, and the battery held in place with blu-tak, PiZero Bot V2 was almost ready to go. I extended the python code to listen for the WASD keys to drive the robot from my phone and it was off for a test drive.

A relatively successful trip, although the battery appeared to be dying towards the end as it was starting to struggle to move. I know the battery wasn't fully charged at the time, so I'll have to test again to see how well it lasts. I do have a larger battery that is around the size of the mint tin, but I was avoiding using it as it adds to the height of the robot, and that somewhat defeated the point of making the smallest robot I can.

Of course its also a little tricky to control when driving it via key presses alone, but it should be possible to write an Android app, or similar, that can implement an analogue controller that communicates over serial to the Raspberry Pi.

As ever there is always more to do. I still want to add at least one sensor to this bot, probably a proximity detection one, so it can be left to drive around by itself. However with all the wires stuffed inside it there's not much room to extend it cleanly. I may have to look at designing my own PCB so I can get rid of most of the wires, freeing up some space to connect up a sensor, punching some holes in the front of the tin to allow it to be connected up. But that will have to wait for V3, as I have some other projects that need finishing up first.



  1. Nice work! Regarding the power: are you running the Pi and the motors from the one battery? If so, how have you connected them? Also, have you considered using a Wiimote for control, or did you specifically want to use the phone?

    1. Everything is running off the one battery, with the Pi connected to it via the Zero LiPo board and the motors powered from the 5V pin on the Pi itself. Ideally the I'd connect the motors directly to the battery, but that was hard to squeeze into the space.

      I'm currently using the phone as its not a full Bluetooth dongle on the Pi (Its serial only). To use a Wiimore, or other controller, I'd need something else to connect to it and pass the information over the serial link. A second PiZero with a bluetooth dongle would most likely work for that.

  2. Hey, congrats on fitting it all in such a small package! Where did you get the motors, tyres and caster from?

    1. The motors I picked up for free at the Raspberry Pi Birthday Bash a few years ago. They are the vibration motors from a mobile phone.
      The tyres are from a Meccano race car set I grabbed in a Christmas sale and the caster is a Pololu ball caster, which can be found in various stores.