Intro to my Raspberry Pi

June 19, 2013

So, this week I finally got started on physically playing with the RaspberryPi, nothing particularly fancy, just getting it configured, working with my camera board, and a short piece of code to run it on a timelapse. Hence this post, it's the general steps I went through to setup my Pi and camera, along with a few tricks I found from a bit of searching. I will post more next week I expect, as there are still several bugs and issues (possibly some to do with my wigi card being broken - it rattles when shaken).

The basic steps

So, sat down at computer on Monday, and whirled through a few steps to get it up and running on a basic level.

  • Laptop decided not to play ball with SD cards, but rebooted (off and on again) and all was well
  • Read through page 3 (
  • Opened gparted (disk was already FAT32)
  • Downloaded NOOBS (
  • Ran
    unzip -d NOOBS
  • Copied contents onto SD card
  • Put SD card into pi
  • Connected HDMI to pi
  • Connected power to Pi
  • Marvelled at it working first time :-)
  • Connected keyboard via USB hub, again, worked instantly
  • Connected other USB dongles into HUB ready (mouse, wifi)
  • Moved onto NOOBS docs (
  • Stuck with Raspbian for now
  • Waited for a few minutes during installation (made a cup of tea)
  • Now its installed, I went through each step to get it running
    • Expand filesystem: Unnecessary with NOOBS, but for a regular OS you will need to do this if you want all the space available
    • Change User Password: security, so just do it
    • Enable boot to desktop: I did this as am playing, but once I start writing scripts, will probably just go to command line for the sake of performance
    • Internationalization: Confirm settings (en_GB.UTF-8 UTF-8)
    • Enable camera: Sweet, this is all there waiting for me, ON ON ON (
    • Enable to Rastrack: Why not, it's kinda cool to view all the data (
    • Overclock: Not at that stage yet, but may be later ;-)
    • Advanced: Definately go in here to configure hostname/ssh/update
    • Finish
  • First thing I noticed is that it didn't boot into x automatically, so opened manually with
    (note: after a reboot, it went into x instantly)
  • Mouse works instantly, which is great


The usual way when you either have a bug, or finished some config, turn it off and on again. As we know, pulling the power plug, whilst effective, can cause disk corruption, so we will do it the good old command-line way first. The best way to do this is:

  • Open terminal
  • type
    sudo shutdown -h now
  • Screen goes blank (no signal)
  • Pull the powerplug AND the HUB USB cable
  • Ensure lights are off

To reboot, replace the command with

sudo shutdown -r now


Sadly, my WiFi dongle (Tenda w322u) didn't appear to work out of the box, so had to get this working with a few steps.

Worth noting that when I ran the install, nothing installed, so may have been working all along, and all I did was give it a nudge along. OR when you boot up the Pi, you may need to disconnect the dongle, and plug it in once loaded to be recognised. Also, it worked instantly after a reboot, no further config required.

update: It did work just fine, you just need to make sure you have checked the 'enabled' setting, and then run the scan. Be patient though. Also, I found that later it dropped my wifi completely, thinking there is a problem with my wifi dongle completely, so going to get a new one ordered now, opted for this USB dongle from Amazon PiHut.

Cool NOOBS notes

NOOBS is awesome for learning the basics of your Pi, and trying several of the different OSs available (Rasbian, RaspBMC as examples).

Also, after you have used it, you can wipe it completely by holding down shift on boot to change OS to another one (this will loose data) - very handy if you manage to lock yourself out completely when playing with init.d/vnc scripts - ahem!!!

Remote Communications

One thing that I was well aware of was that when in co-working environments I will not have a monitor, which is fine as I can SSH into the device to manage it. But wait, I need the IP to be able to do that, and without a monitor, how do I find out the devices IP. So, I decided to jump onto my android tablet and start installing apps to help. The winner by a long way is something called 'ezNetScan', whilst I have only so far used it on my network at home, it does a fantastic job of explaining devices to me with their names (I can also give custom names if I like). So in theory, so long as I setup my RaspberryPi at home first to allow SSH and have a respectable machine name (eg. 'RaspberryBadger') then I should be okay, will trial all this out on Tuesday and report back.

To go alongside this on my android, I have JuiceSSH setup, I usually use it for checking error logs on my mediacentre, or running updates, but now I can also connect to my Pi to run things if I want to check anything but not boot up the laptop. I resisted purchasing a tablet as tbh they don't have a purpose unless you make one for it. My purposes are: email, social media, news reader, management tool


Sometimes, SSH just wont cut the mustard, you want full desktop control from a remote machine. This is where VNC comes in handy, tips for this were taken from Neil Blacks blog post

  • Install tightVNC on the Pi:
    sudo apt-get install tightvncserver
  • Start server with
  • Install and open VNC software on your main machine (Ubuntu it's called Remote Desktop Viewer)
  • Connect to the IP of your Pi (remember to include the :1 at the end, as this is the desktop session setup
  • Setup a new init.d file for the vncserver: sudo vim /etc/init.d/tightvncserver
  • Paste in:
    #!/bin/sh# /etc/init.d/tightvncserverVNCUSER='pi'case "$1" in    start)        su $VNCUSER -c '/usr/bin/tightvncserver :1'        echo "Starting TightVNC Server for $VNCUSER "        ;;    stop)        pkill Xtightvnc        echo "TightVNC Server stopped"        ;;    *)        echo "Usage: /etc/init.d/tightvncserver {start|stop}"        exit 1        ;;esacexit 0
  • Save/exit vim Make script executable:
    sudo chmod 755 /etc/init.d/tightvncserver
    Add this script to the bootup defaults: sudo update-rc.d tightvncserver defaults Check this script runs:
    sudo /etc/init.d/tightvncserver stop
    then restart Ensure you have ssh access to the box (it locked me out first time I tried this) Reboot, it should setup vnc server under your pi username (with equiv password)


So, most of the projects I want to play with on my Pi (at least in the short term) involve the Pi camera. So, let's see if we can get that running easily.

  • Open terminal
  • go to Desktop:
    cd Desktop/
  • take photo:
    raspistill -o image.jpg
  • Done

Wow, it all works out of the box, that is nice and simple.

Mini tip

No matter whether you think you have everything you need, you probably dont. I have HDMI cables and USB hubs, so wasn't concerned, until I realised I had to start unplugging other things to get this to work. May get some Pi dedicated cables. Also, a cheap case for the pi is tempting, as it feels delicate, and so transporting it to co-working environments is not the easiest of things as a bare board.

Next Steps on my Pi config

A few things I still need to do to be completely happy with my Pi setup

  • File sharing - relying on a USB is a pain, so should look into getting SAMBA working nicely

The timelapse code

Okay, so the project I wanted to write was a timelapse piece to take photos over a long period of time. I have been writing this in Python, and so far it works nicely. Opted for a loop instead of the built in raspistill timelapse functionality as this allows for a little more control to escape out of it and monitor the progress.

If you want to take a look at the code so far, head in over to my GIThub project and look at the 'develop' branch at the moment. I'm afraid there is nothing in the README or anything yet as still got a few bugs to resolve around the camera failing overnight (had to disconnect and reconnect to resolve), aswell as my wifi dongle no longer connecting (grrr).

Also, there is of course lots more functionality to add, mainly things like:

  • Ability to manage the Pi and camera without a monitor (at present, I can trigger the camera, but the preview appears on the Pi desktop, not the VNC desktop
  • Some slightly easier feedback using LEDs because I want to
  • A physical button which when pressed allows me to start a timelapse for 12hours using the built-in default, and also a button to stop the current timelapse

Finally, to create an mpg with the still photos. I used ffmpeg and it seemed to just know what to do instantly, which is great, just move into the folder with all the photos in, and run a modified version of the below command:

ffmpeg -f image2 -i 1371571083_%d.jpg output.mpg
  • -f = force format
  • -i = filename

To view the first video, go to YouTube