Wifi controlled Raspberry Pi robot

I will document my journey to build a wifi controlled Raspberry Pi robot here. This post will be updated as and when I have progress on the project.

Desirable features:
- controllable via wifi
- Web interface to control the robot.
- movable using 4 wheels
- has a display (16×2 LCD display is sufficient)
- has a webcam for live feed
- webcam can be rotated for capture at different angles
- run on battery

Nice to have features:
- Mobile interface to control the robot
- a speaker for robot to “talk” (text sent via the website command, then robot speaks using TTS ?)
- a microphone for interaction with human (other people speaks to the robot, and I can hear back at the website command?)
- object tracking: robot is able to track moving objects and follows that object

Hardware Components:
- Raspberry Pi, Model B
- Wifi dongle
- 16×2 LCD display – USD $5
- PCB boards
- 4 wheels DC motors – USD $16
- USB webcam / Piwebcam
- Servo motor – USD $5.15

Tools
- Breadboard
- Dupont cables
- PCB boards
- Solid core cable – US $2.95

Optional Tools
- Raspberry Pi GPIO Cobbler extension – USD $8
- Pin header – USD $1.5
- Breadboard power supply – USD $1.5

Considering power bank for Raspberry Pi

I am in need of a suitable battery pack to power my Raspberry Pi and all its peripherals. This entry is to list down any considerations made along the way :
Remember RaspPi runs at 5V, hence input power is required to provide a steady 5V stream, more and you may destroy the Pi, less and the Pi will start to behave wildly.

A Raspberry Pi needs 5V with 700 mA, meaning it has a consumption of 3.5 Watt.
Note that consumption indicates a maximum value because it can never get more power that the indicated consumption.

(1) Buy an off-the-shelf power bank. A useful article to decide on which power bank to buy : FB don’t buy power bank until you read this

(2) Use AA batteries with UBEC-Universal Battery Eliminator Circuit, which essentially is a switch mode voltage regulator .

Set up a live webcam streamer on Raspberry Pi

I used Motion as the camera live streamer. Found a great short and comprehensive guide for the setup here.

To keep long story short, these are the important commands:

  1. sudo apt-get install motion
  2. sudo nano /etc/motion/motion.conf
    => in the config file, change these values :
    Daemon = OFF to ON
    webcam_localhost = ON to OFF
    minimum_motion_frames 5 to 2999
    (changing minimum_motion_frames to avoid Motion to capture exessive screenshots whenever movement is detected. I only need the live stream camera function.
    Btw, your screen captures are stored in /tmp/motion )
  3. sudo nano /etc/default/motion
    Then change the value “start_motion_daemon=no” to “yes”
  4. sudo service motion start
  5. Access at : http://[pi ip address]:8081
    I accessed ok using Firefox. Chromes doesnot work for some reason.

Settings in my Raspberry pi /etc/network/interfaces

pi@raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback

#allow-hotplug wlan0
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static
address 192.168.1.18
netmask 255.255.255.0
gateway 192.168.1.254
broadcast 192.168.1.255
network 192.168.1.0

#auto eth0
#iface eth0 inet static
# Your static IP
#address 192.168.137.10
#gateway 192.168.137.1
#netmask 255.255.255.0
#network 192.168.137.0
#broadcast 192.168.137.255

Frequently used Unix / Raspberry Pi commands (I kinda mix them up in this single post)

ps ax | grep vnc search for process which name contains “vnc” in all running processes
cat /etc/rc.local this file defines the commands at startup
crontab -l list user’s crontab.
crontab -e edit user’s crontab. You can use crontab to define autoscript at bootup
Simply add an entry starting with @reboot
eg. @reboot sleep 180; sh ~/startupscript.sh #after bootup, wait for 3minutes then run startupscript.sh
kill -9 1234 kill the running process which id is 1234
tightvncserver start tightVNC server
cat /etc/network/interfaces view network information pre-configured on raspberry pi
wpa_passphrase [yourSSID] [yourpassword] to generate an entry for your wifi ssid and password.
You then take this entry and set in /etc/wpa_supplicant/wpa_supplicant.conf
sudo shutdown -ht 0 now shutdown pi and halt after shutdown
sudo /etc/init.d/networking restart restart network, to take new settings into effect
lsusb view all connecting devices via USB
sudo service [service_name] start start a service
sudo service [service_name] stop stop a service