Raspberry Pi – Setting up for Electronics and Development Work

RaspberryPiThe following is a step-by-step procedure of what I did to get my Raspberry Pi in some sort of working condition, having SSH, VNC access, development tools installed, GPIO and Wiring-Pi Library and having a static IP so that Raspberry Pin can be connected directly to Laptop/PC via an ethernet cable without any router etc.

The hardware setup is as follows:

  • 1x Raspberry Pi having latest Raspbian Image on an 8GB SD card
  • 1x Ethernet Cable, Cross connection
  • 5V Adapter with USB Cable to power Raspberry Pi [powering via laptop USB port is NOT recommended]

Now coming to the steps which I followed to set up my Raspberry Pi for use:

    1. Power up raspberry pi with fresh Raspbian image and connect it to a router using some ethernet cable. Use Win32DiskImager to put install the Raspbian image on an SD Card
    2. Find IP of Raspberry Pi by using any network scanner , I used SoftPerfect Network Scanner. Just make sure to put in proper IP range for the search, there is an IP button at the top to select the right range automatically.
    3. Open PuTTY, and enter Raspi’s IP and connect via SSH
      — user name: pi
      — password: raspberry
    4. To configure any settings etc which you want, enter
      sudo raspi-config
      I expanded the Root File System by expand_rootfs, enabled SSH (though it seems to be already enabled else we wouldn’t be able to use PuTTY) and then upgraded raspi-config [requires Internet and may take some time depending on Internet speed]
    5. Reboot Raspberry Pi by
      sudo reboot
    6. Restart the PuTTY session and login again.

6.5. Before following the the next step, see Step 9 first..!

  1. Enter
    cd /etc/network
    to change to /etc/network directoy, by now entering ls you can see the list of files/directories in the folder, we are interested in the interfaces file.
  2. The interfaces file has the configuration and settings regarding the Ethernet and Wifi interface, we want to make the IP static so we can access Raspberry Pi directly via PC as well without router.
    To access and edit the interfaces file, enter
    sudo nano interfaces
    Now, edit the line: iface eth0 inet dhcp by changind dhcp to static and then add the following lines right below it;
    auto lo
    iface lo inet loopback
    iface eth0 inet static

    Select the IP addresses as you want, I have set it up according to the setting of my home wifi router, your’s may differ a bit.
    to save and exit, press Ctrl+X, then Y for Yes and then ENTER to keep the same file name, now reboot again by entering
    sudo reboot
  3. Now start a new PuTTY session with the new IP you assigned. I had selected the IP so that the Raspberry Pi works with my Wifi router as well and since I have still kept it there and it is connected to Internet, I can isntall a few more things, if you cannot access Internet after changing IP, do these steps and any other online installation BEFORE changing the IP.
  4. Update the package list by entering
    sudo apt-get update
  5. To install TightVNC, enter
    sudo apt-get install tightvncserver
    it will ask for disk spacce usage press Y.
  6. Run VNCServer for the first time to set up passwords, by entering
    vncserver :1
    the 1 is the VNC Server port number.
    set password, 8 characters. I did not set any view-only password so left it blank.
  7. To install some essentials for C/C++ programming, enter
    sudo apt-get install build-essential
    [I found out later that it is already installed]
  8. Installing the RPi.GPIO Python module
    sudo apt-get install python-rpi.gpio
    sudo apt-get install python-rpi.gpio

This much should be enough for most, however, I installed/downloaded a couple more things

  • Python Development toolkit
    sudo apt-get install python-dev
    sudo apt-get install python-smbus
  • I2C Tools Utility
    sudo apt-get install i2c-tools
  • installed GIT
    sudo apt-get install git
  • Cloned of Adafruit’s Raspberry pi code library
    git clone http://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
  • Cloned Wiring-Pi Library
    git clone git://git.drogon.net/wiringPi
  • Installed Arduino
    sudo apt-get install arduino
  • Load and Enable I2C modules at boot time by editing the file modules in /etc/
    sudo nano /etc/modules
    add the following 2 lines at the end of the file:

    save and exit, Ctrl+X, then Y, then Enter
    open another file:
    sudo nano /etc/modprobe.d/raspi-blacklist.conf
    comment the following 2 lines by adding a # at the start.
    #blacklist spi-bcm2708
    #blacklist i2c-bcm2708

    save and exit, Ctrl+X, then Y, then Enter
  • UPDATE: Installing Mono for C# Development
    sudo apt-get install mono-complete
    the installation may take some time, but after it is done, you can use CSharp by typing in csharp
    More information at: http://www.amazedsaint.com/2013/04/hack-raspberry-pi-how-to-build.html


Accessing Raspberry Pi via VNC

After boot and login via PuTTY, type in
vncserver :1
to start the VNC Server at port 1, you should have UltraVNC or some other VNC viewer application installed on your PC, start the viewer and put in the IP of Raspberry Pi along with port number. Connect, enter password and you are now logged in.
To start the VNC Server with specific options, you can use
vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565:
or see the vncserver help yourself to find out more options.


Accessing Raspberry Pi directly from PC

If you are like me, you want to access the Raspberry Pi directly from your PC/Laptop without router etc in between.
to do this, you will need the following, besides a Raspberry Pi and your Laptop.
— An Ethernet cable, cross connection is preferred.
— Raspberry Pi set at some STATIC IP, mine is set as follows:

Set the IP settings of your PC Ethernet adapter as follows:

Laptop/PC - IP Settings
Laptop/PC – IP Settings


Now start a new PuTTY session and do as follows, (start VNCServer)

PuTTY from Login to VNCServer
PuTTY from Login to VNCServer


Login to VNCServer by using the VNC Viewer application, see how the port number is added with the IP address.



FINALLY, Raspberry Pi desktop, accessed from a PC, directly via a LAN Cable, without any Switch or Router.

VNC Window, showing Raspebrry Pi Desktop ‘X’

Note: Most of the stuff mentioned and steps taken and commands used were taken from different websites, some of the ones worth mentioning are:

  • learn.adafruit.com/category/learn-raspberry-pi
  • www.raspberrypi-tutorials.co.uk/raspberry-pi-static-ip-address/