Product Code: 48

Buying Links:          


The RasPiRobot Board V3 is an expansion board designed to turn your Raspberry Pi into a robot controller! This board comes fully assembled and includes a switched-mode power supply so you can supply your Raspberry Pi from a variety of battery packs.



The board fits right on top of your Pi’s GPIO socket and allows for bi-directional control of both motors with an H-Bridge motor driver chip. It also allows for control of both motor’s speed independently. The board can also supply the Raspberry Pi with power using a cool and efficient switch mode power supply, allowing you to run a fully-loaded Pi and the robot from 6xAA batteries (not included!)


The main features of version 3 are listed below.

  • Compatible with Raspberry Pi models 3, 2, 1, Zero, A, A+, B and B+
  • Extensive Open Source Python library with examples – download from Github
  • Supplied fully assembled – no soldering
  • Bi-directional control of two motors
  • Variable (PWM) power control. This allows you to both control the speed of the motors independently and the use of lower voltage motors than the battery pack.
  • Supplies the Raspberry Pi with power – run a fully loaded Pi and the Robot from 6 x AA batteries
  • Rangefinder header socket directly compatible with cheap HC-SR-04 ultrasonic range finders. Just plug them in
  • 5V I2C header, pin compatible with Adafruit displays
  • Two buffered open collector outputs capable of 2A each
  • Two LEDs
  • Two switch inputs
  • Screw terminals for motors and battery
  • Through headers allowing access to all GPIO pins (although the RRB3 uses many of them)


finished_kit copy

The RRB3 is powered from a battery pack that needs to be between 6 and 12V DC. Although using 4 x AA batteries can in theory provide 6V, actually the battery voltage will usually quickly fall below that, so it it better to use at least 6 x AA batteries, either rechargeable or regular heavy duty batteries. A 7.2V LiPo battery pack will also work just fine.

Note that you don’t need a separate power supply for the Raspberry Pi. The RRB3 will provide enough power with ease to the Raspberry Pi. However, it is perfectly OK to power your Pi over USB even while the batteries to the RRB3 are connected.

The RRB3 provides power to the motors direct from the battery pack.


Getting Started

On your Raspberry Pi, issue the following commands in a Terminal window:

$ cd ~
$ git clone
$ cd raspirobotboard3/python
$ sudo python install

Attach the RRB3 to your Raspberry Pi. You do not need to attach batteries, motors or anything else to the RRB3 just yet. For now you can just power it through the Pi’s normal USB power connector.

Lets run some tests from the Python Console now that everything is installed. We can experiment with the RRB3, even without any motors

Open a Python console (Python2 not 3) by typing the following into a Terminal window:

$ sudo python

Then, within the python console, type the following, one line at a time:

from rrb3 import *
rr = RRB3(9, 6)

The last step should display the answer “False” because no switch is attached.

If you prefer, you can use True and False in place of 1 and 0 in the examples above.



The library implements a class called RRB3. This is only available for Python 2 and any Python programs that you write that use the library must be run as a super user.

To import the library and create an instance of the class, put this at the top of your Python program.

from rrb3 import *
rr = RRB3(9, 6)

The first parameter ‘9’ is the battery voltage (6 x 1.5V AA batteries). The second parameter (‘6’) is the motor voltage (6V for most low cost robot chassis motors). It is important to set these values correctly, as the library will manage the voltage supplied to the motors, to prevent them burning out or running too fast.

The rest is pretty straightforward, there are just a load of useful methods on the class that you can use.


There are two LEDs built-in to the RaspiRobotBoard, called LED1 and LED2. Both of these can be turned on and off using the following methods:

To turn LED1 on just do:


To turn it off again do:


To control LED2 just do the same thing but using set_led2.

Switch Inputs

The sw1_closed() and sw2_closed() functions return true if the contacts for that switch are closed. By default, the switches are open. You can test out closing the switch by shorting the two contacts with a screwdriver.

The following test program will show you the state of each of the switch contacts.

from rrb3 import *

rr = RRB3()

while True:
    print("SW1=" + str(rr.sw1_closed()) + " SW2=" + str(rr.sw2_closed()))
    raw_input("check again")

Open Collector Outputs

The RRB3 has two high-power open collector outputs. These can each provide up to 2A and so are suitable for driving loads at the battery voltage, such as high power LEDS, IR senders, alarm bells, relays etc.

Each OC output has a pair of screw terminals. Once screw terminal is marked + and this is connected to the positive power input from the batteries. The other connection is the open collector output.

This means that you can just connect your load (say a 12V siren) across the two screw terminals and then control it as described below. If the load you are using has a positive terminal then this needs to be connected to the screw terminal marked +.

To turn the Open Collector OC1 output on just do:


To turn it off again do:


To control OC2, substitute set_oc2 in place of set_oc1 in the examples above

Motor (High Level Interface)

There are two levels of command for controlling the motors. There is a high level interface that assumes that the motors are connected to wheels on a rover. These commands are forward, reverse, left, right and stop.


… will start both motors running in the same direction to move the robot rover forwards. They will continue in this direction until another command is issued.

If you want to move forward for a certain amount of time, you can specify a number of seconds as an optional first argument. If you supply a second parameter between 0 and 1 this will control the speed of the motor. This is set to 0.5 as a defaut. If you want the motors to run indefinately, but also want to control the speed, then use 0 as the first patrameter.

Some examples:

rr.forward()       # forward half speed indefinately
rr.forward(5)      # forward for 5 seconds at half speed
rr.forward(5, 1)   # forward for 5 seconds at full speed

The commands left, right and reverse all work in the same way.

The stop command stops all the motors.

Stepper Motor Interface

There RRB3 can be used to drive a single bipolar stepper motor with one coil connected to the L motor driver and the other to the R terminals.

Two commands are available to make the motor step in one direction or the other:

rr.step_forward(5, 200)  # step in one direction for 200 steps with a 5ms delay between each phase change
rr.set_reverse(5, 200)   # other direction

Motor (Low Level Interface)

The low level interface is intended for control of the motors directly. It allows you to control the speed of each motor and its direction independently.

The method for this (set_motors) takes four arguments: the left speed, left motor direction, right spped and direction.

So to set both motors going forward at full speed, you would just use the following:

rr.set_motors(1, 0, 1, 0)

.. and half speed would be:

rr.set_motors(0.5, 0, 0.5, 0)

to send the motors both at half speed in opposite directions is:

rr.set_motors(0.5, 1, 0.5, 0)

Range Finder

If you fit the RRB3 with an SR-04 ultrasonic rangefinder, then you can use the following call to measure the distance to the enarest obstacle in cm.



You can download the schematic here.

Absolute Maximum Ratings

Input Voltage: 6-12V (9 recommended when driving motors)

Motor Current total average: 1.2A Motor Current total peak: 3.2A (built-in thermal shutdown)

OC1 and OC2 output currents: 2A at battery voltage (unprotected)

Max current supplied to Pi (excluding motor current): 1.5A

Using I2C Displays

The I2C socket is pin compatible with these Adafruit displays:

To use these you will need to download Adafruit’s Python library for the Pi from here.

Make sure that you plug the display in the right way around. The socket pins are labelled on the RRB3, make sure they match up with the labels on the display. You can use male to female jumper wires if you wish to put the display further away or its too big.


If one of the motor channels doesn’t work.

* Try swapping the polarity of the motor leads over on the same L or R channel. Is it now the forward command that works?
* Try the motor connected directly to a a battery. Does it rotate in both directions when you swap the polarity of the leads.
* Does the Pi reset when you do ‘forward’? This could indicate a power source that’s too weak.
* Do you have a multimeter to test the outputs?
* Make sure that NONE of the motor leads are connected to GND.
* Make sure that no other software is using the GPIO pins. If this isn’t a ‘fresh from the box’ pi there is every likelihood that something else is using one of the GPIO pins you need so if you re-install Raspbian it should clear this up.



7 thoughts on “RasPiRobot Board V3

  1. admin Post author

    The board uses this driver chip:

    The problem will be the inrush current dropping the supply voltage and crashing your Pi, unless you use very short thick leads to batteries with low internal resistance. So you would probably need to supply the Pi from a separate battery.

  2. Demian Clements

    I picked up the RasPiRobot Rover Kit recently and after rebuilding it from scratch 3 times, reformatting with a fresh OS 3 times, and testing all motors and outputs I am at a total loss as to why it isn’t driving the motors. I’ve played with the code, but I assume all git sources should work without modification assuming directions are followed.

    LEDs work, the rangefinder works, nothing seems to be awry with the Pi itself.

    None of the searches or forums I scoured through have provided me any progress on this.

    Is it possible the outputs are not functioning correctly despite registering a change in resistance when the code for engaging the motors is run?

    This is my first foray into actual electronics despite decades of computer use.

  3. admin Post author

    Hi Demian,
    The first thing to note is that the motors will only be active if the RRB3 has a battery pack attached. That is powering the RRB3 from the Pi’s USB power will allow all functions to work except the motors.

    Could this be your problem?


  4. otto-mated


    You have spec’d upto a 12v input. Can this be higher?
    From the schematic, I see you use an MP1496 step down converter. MPS spec sheet,, shows an input range of 4.5-16v input range.

    So if one connected this to a 12v power system, such as a car, or other mobile platform, that is then recharged, then it should be able to run during recharging? Charging of such items such as lead acid, run at about 13.8v, and could peak as high as 16v.

    I’m going to speculate that MPS designed the chip for the mobile market and should be able to handle the higher recharge voltage.

    Is there anything on the board that would prevent this from being used in the 12v mobile environment?

    Another question, the MPS spec suggests this is 2A. The Raspberry Pi 3 spec,, suggests a recommended power of 2.5A. So if you are driving motors and proximity sensor, is this driver a bit under powered for continuous operation?

    Best regards,


  5. admin Post author

    Hi Otto,
    While, as you say, the switching PSU can cope with an input up to 16V, the maximum input voltage for the motor controller IC (TB6612FNG) is 15V. The large electrolytics are rated at 16V – so in short – yes you should be fine at 13-14V.
    As for the supply current to the Pi, a Pi B+ to Pi3 rarely draws more than 1A and the power to the motor comes from the unregulated side.
    Hope this helps.

  6. Demian Clements

    Unfortunately not, I am powering the board from the 6 batteries from the battery pack. They are fully charged and the outputs appear to be producing a sustained voltage. To limit power draw I have made sure to have nothing else connected (including the rangefinder) and am using SSH to interact with the device.

Leave a Reply

Your email address will not be published. Required fields are marked *