New domain and blog

New domain and blog
Please head over to my new domain to view my blog and current projects

Tuesday 16 April 2013

Raspberry Pi: Direct connection to Windows 7

This is something I have been wanting to try for quite some time but never really found much info on how to do it. Well I sat down the other day to get it done and realised that it is MUCH easier than I expected.

My objective is to directly connect my Raspberry Pi to my laptop using an ethernet cable. In the next few months I am going to be away from a decent internet connection but I still wanted to do some work on my RasPi. So my Google searching started, finished and here is what to do.

The process uses a built-in feature of Windows 7 called Internet Connection Sharing (ICS). In a nutshell, you can use any Windows computer with more than one network connection, WiFi and LAN, and share the connection to other computers. 

Firstly you need to set up the settings on Windows. You need to go to the properties of your disconnected LAN connection and click on the sharing tab. Then check the box to allow other network users to connect through this internet connection.


The tricky thing to set up is the IP address that you are going to give the RasPi. You need to check the TCP/IPv4 settings under the Networking Tab. I picked an IP address and gave my RasPi a static address so that I know what it is when ever I use this connection.

Next you need to power up your Raspberry Pi and connect to it some way. Either use a WiFi connection that is already set up, an ethernet connection to your router or using the serial port on the GPIO.

You then need to set up the IP address by editing the interfaces file.
sudo nano /etc/network/interfaces
Change the part of the file that refers to your eth0 connection to look similar to below. You might have other settings in there like WiFi IP addresses and passwords but just leave those alone.
iface eth0 inet static 
address 192.168.137.184 
netmask 255.255.255.0

Once you have saved the interfaces file, send the shutdown command so that you can change over the connections. Once powered off, directly connect your RasPi ethernet port to your Windows ethernet port. You should be able to use both straight-through and cross-over cables. Now power up the RasPi.

Once booted up, you should be able to log in with Putty to the static IP address that you set above. 

And that is pretty much it. Another cool thing by connecting this way is that you should be able to power your Raspberry Pi from your computer USB port. This makes transport really easy as all you need is an ethernet cable and a USB cable to get up and running. 

Hope this helps and if you have comments or questions, please leave them below and I'll get back to you as soon as I can.

Greg

2 comments:

  1. This works great but to give the Pi access to the Internet you'll need an extra line -

    gateway 192.168.137.1

    Editing /etc/resolv.conf might be required too.

    ReplyDelete
    Replies
    1. Thanks for the feedback and advice. I wondered why I couldn't get internet access but just haven't had a chance to look at it properly. Will give it a try as soon as I get a free moment.

      Delete