PgBox Robot is a robot built upon two coupling boxes. The robot uses a Raspberry Pi as brain. These chapters will describe in detail how the robot is built and programmed. 

Raspberry Pi B Rev 2 700Mhz single core is used. 

There are many different Linux distributions for Raspberry Pi, PgBox Robot uses Raspbian, which is built upon Debian.

Raspbian install, follow this procedure: 

  1. Download Raspbian Debian Wheezy:
    • The following version is
  2. Format an SD card for ext4 with Gparted
    • Make sure you know what you are doing to format the correct disk.
  3. Unzip the file
  4. Open terminal in the folder you unzipped
  5. Type the following command to write the Raspbian imaged to the SD card, in this case the SD card is on /dev/sde
    • sudo umount /dev/sde
    • sudo dcfldd bs=4M if=2015-05-05-raspbian-wheezy.img of=/dev/sde
    • Be sure to write to the correct disk sda is usually the operating system disk and you ruin your operating system if you write to this disk, the disk used here is sde.
  6. Run: sudo sync
    • ync forsikrer å flushe minnet slik at det er sikkert å ta ut minnekortet.

After installation, the memory card is inserted into the Raspberry Pi device.

Use SSH to log on to your Raspberry Pi after inserting the memory card and booting up.

  1. ssh pi@
    • password raspberry
    • This is the IP address your Raspberry has received on your network.
  2. Configurate Raspberry
    • sudo raspi-config
  3. Update your raspberry:
    • sudo apt-get update
    • sudo apt-get ugrade

Now the Raspberry Pi should be ready to use. And we can start programming and connecting devices that are going into the robot, such as motor drivers, sensors, etc…

There are several ways / programming languages you can use to program a robot on the Raspberry Pi.

Initially, Python will be used, which will put some real-time restrictions on the robot. But in most cases, the control system will respond quickly enough to perform the robot’s tasks without problems. If you have programmed a little in Python, it is quick to develop programs for such a robot, as much is available in libraries. A good number of libraries have also been created for Raspberry Pi. C code might be easier if you want to make drivers.

You can also program in C, C ++ and otherwise everything else of programming Linux has to offer.

CoDeSys is also a PLS programming tool that you can use on Pi. This makes your Pi a PLS. CoDeSys for Raspberry Pi costs 50 Euro from

Motors, wheels and steering electronics for the drive module are all purchased on e-bay and mounted in a junction box.

The robot has two wheels one on each side and one ball wheel at the back.

To control the motors, two channels are used from an RC servo controller, which is controlled using the UART serial port RS232. This outputs PWM signal correspondingly for control of RC servos.

There is a motor driver for each motor, these are RC motor drivers for brush motors. It is important that these are driverless brakes, otherwise it will be difficult to control the robot when reversing. These motor drivers are controlled from the RC servo controller board.

There are two wheels, this for the robot to be able to turn around its own axis. This is the most common for this type of robot that uses odemetry control. The ball wheel helps the robot to turn around its own axis.

360deg linear potmeters are mounted as encoders on the wheels.

  • Motors and wheelsl: 2 sets Smart Car Robot Plastic Tire Wheel Tyre + DC3-6V Gear Motor For Robot
  • Ball wheel:  Roller Ball Bearing Metal Caster Flexible for Smart Car robot
  • Servo driver card: 16 Channels Servo Motor USB UART Controller Driver Board For Arduino Robot MCU
  • Motor driver: RC 10A Brushed ESC Two Way Motor Speed Controller No Brake For 1/16 1/18



Motor box


Motor driver


Motor driver installed

To be able to use both the mains voltage and the battery on the robot, a power supply has to be installed.



Most of the robot uses 5V power, similar to USB power.

To obtain sufficient power, a “DC-DC Converter 12V to 5V 3A Step Down Power Supply Module Micro USB Waterproof” has been used.

Link: DC-DC Converter 12V to 5V 3A Step Down Power Supply Module Micro USB Waterproof

There are also fuses, an on / off button, and a 12V power in plug.


The last picture here shows a series of pins for 5V and GND.

As the pictures show, most of the robot is attached with either screws or glue gun.

To be able drop the cord on the robot we install a Wifi device, WiPi, which is a USB wifi adapter, designed for Raspberry Pi.


The WiFi adapter has to be configured for the network. 


pi@raspberrypi ~ $ sudo cp /etc/network/interfaces /etc/network/interfaces_org
pi@raspberrypi ~ $ sudo jed /etc/network/interfaces


The interface file:

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Change wlan0 to:

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid “Your network SSID”
wpa-psk “Your network passord”


Restart network:

pi@raspberrypi ~ $ sudo ifdown wlan0

pi@raspberrypi ~ $ sudo ifup wlan0

Now the robot will connect to the network. 


Ultrasonic range sensor HC-SR04 is installed at the front and back.

HC-SR04 is an ultrasonic sensor that can measure distances from about 2 cm to 4 meters, with very good accuracy.
A driver must be written in the control system for this sensor.
The sensor works by trigging a starting pulse. When the HC-SR04 receives the starting pulse it sends an 8 pulse ultrasonic burst. The control system driver detects  the echo. You have to calculate in the driver how long it takes from pulse to the echo.


Pyroelectric Infrared Body Motion Sensor.
Room sensor that detects motion in the room based on infrared light. There is one such sensor on the front and one on the back of the robot.
This sensor should detect movement in the room in front of or behind the robot so that it can turn towards where the movement is. That is, if a person enters the room, the robot will detect this and turn towards it.

The camera module is a custom camera module for Raspberry Pi. 

It connects to one of the sockets on the Pi board, and uses the CSI interface. 

The CSI bus has ha high data rate whish gives almost no delay on the camera, compared to a standard USB camera which can have a delay up to a couple seconds.


The Custard pi 3 card is a 12 bit 8 channel analog io card for the Raspberry Pi. The card is has a stack connector for the Pi. SPI interface is used for the data transfer.

Further configuration will come later this week.

Leave a Reply