Meltwater's Raspberry Pi Hardware
Meltwater's Raspberry Pi Hardware
Meltwater's Raspberry Pi Hardware
Remember if you need the wired network for your computer (i.e. to get internet) then you shall have to
make a choice about which one you wish to use (or get an extra network port by adding a USB
network dongle). If you use wireless connections, then you can still have both!
Any standard network cable should be suitable (needs to have a male RJ45 connector on each end),
most cables available will be fine for our needs.
Note: You can use a normal network cable since the Raspberry Pi LAN chip is smart enough to reconfigure
itself for direct network connections (in the past older computers would have needed a special cross-over
cable).
Ive also created a cut-down version of the instructions for more advanced users who wont need all
the details:
In A Nut ShellDirect Network Connection (http://pihw.wordpress.com/guides/direct-networkconnection/in-a-nut-shell-direct-network-connection/)
Other computers will often give themselves a default address (in the address range 169.254.0.0
Other computers will often give themselves a default address (in the address range 169.254.0.0
169.254.255.255) but the Raspberry Pi doesnt do this (yet). Besides even if the Raspberry Pi did, we
would still need to know what address it had picked to be able to connect to it!
To get around this, we have to give the Raspberry Pi a fixed IP address (i.e. we tell it what its IP
Address should be so it doesnt have to wait for one).
There is just one complication to this, and that is if your laptop is configured to a fixed IP too. At first
this may not seem like a problem, since if both IPs are fixed then we will know the address of both
computers every time.
However for them to be able to talk to each other directly, they need to have similar addresses (at
minimum the first number should match, but we shall match at least the first 2 in this case to work with
default network settings). For more information on this, see the section at the bottom of the page about
SUBNETs.
Windows Instructions:
1. From the Start Menu, run the Control Panel.
(Windows 7/Vista) Open Network and Sharing Center and click on Change adapter settings on
the left side.
(Windows XP) Open Network Connections
2. Find the item which relates to your Wired network adaptor (by default this is usually called Local
Area Connection).
(http://pihw.files.wordpress.com/2013/04/networkadaptors.png)
Locate the Wired Network Adaptor Local Area Connection
3. Right-click on it and open Properties.
(http://pihw.files.wordpress.com/2013/04/networkproperties.png)
Network Properties Window, find the TCP/IP Entry
4. Select the item which is called Internet Protocol (TCP/IP) or Internet Protocol Version 4
(TCP/IPv4) if there are two (the other is Version 6), and open the Properties.
(http://pihw.files.wordpress.com/2013/04/networkpropertiesauto.png)
Wired Network Adaptor is configured as Automatic
Hopefully, the IP Address will be set to Obtain an IP address automatically. If not dont worry, just
take a note of the IP address and Subnet Mask set here (you may find the rest of the information useful
to keep, but we wont need it this time). If you know what you are doing, you can change this setting
to automatic, or you can leave it alone (we shouldnt need to adjust it as long as we know the IP
Address).
For network settings where the IP address is obtained automatically, use an address in the range
169.254.X.X (169.254.0.0 169.254.255.255):
ip=169.254.0.2
For network settings where the IP address is fixed, use an address which matches the laptop/computers
address except the last one.
ip=192.168.0.2
Ensure you take note of this IP address (you will need it every time you want to directly connect to
the Raspberry Pi).
6. Make new copy of cmdline.txt and rename it cmdline.direct
7. To swap between configurations, just replace cmdline.txt with either cmdline.normal
or cmdline.direct (or use the commands in Option 2 to do it directly on the Raspberry Pi the change
will take effect next time you power up)
8. Return the card to the Raspberry Pi. Attach the network cable attached to both the computer and
Raspberry Pi and power up.
NOTE THE FOLLOWING:
1. You will need to wait for your computer to finish detecting the network settings (you may see a small
networking icon flashing in your system tray while it does, or open up the network settings to see when
it has finished and has an IP address) it can take around 1/2 minute. Your computer may report the
connection as limited or no connection when connected to the Raspberry Pi in this way, this is
normal as indicates it is a direct computer to computer connection rather than a standard network.
2. If you forget or decide not to plug in the network cable, the Raspberry Pi will wait 2 minutes (or
until you connect the cable) before completing its start-up (so if you only have a keyboard and
monitor attached, you need to wait!).
3. If you are using multiple wired network adaptors (i.e. Using an extra USB-LAN dongle) on your
computer you may find you have to unplug the other network cable and reattach afterwards (my
Windows XP machine needed this before it would connect through the direct link).
Option 2: Set-up using a monitor and keyboard (i.e. before you really need
it):
You will now see that having a keyboard and monitor available at this stage is helpful for when we set
You will now see that having a keyboard and monitor available at this stage is helpful for when we set
this up, as we can test each step.
1. Boot up the Raspberry Pi and plug in the network cable to both machines.
2. When the Raspberry Pi has booted ensure you log in and open the terminal if not already open.
Type the following:
hostname -I
You will probably find that nothing is shown, as this is trying to show you the current IP address
(which is not allocated yet). If it does show something, then you may have already have a fixed IP
address (if you do take note of it in case you need to put it back later).
3. Now set the new address as follows:
For network settings where the IP address is obtained automatically, use an address in the range
169.254.X.X (169.254.0.0 169.254.255.255):
hostname -I
You will see we now have the IP address set.
We should now be able to ping the laptop.
5. Find the laptop address (if it wasnt a fixed address) by returning to the list of Network Adaptors in
windows and double clicking on the icon to see its Status (dont worry about the warning of limited
or no connection).
Then select the Support tab and then Details. You should see the laptops IP address.
ping 169.254.0.1
We should get lots of responses (the laptop is responding the Raspberry Pi through the network cable)!
Ctrl+C to stop that. (If you didnt then double check your connections and the IP addresses you are
using).
As mentioned before, the new IP address will be lost when we reboot, so we need to ensure it is set every
time we boot (or at least every time we want it to be when we boot).
To do that we can edit the cmdline.txt file which is located on the boot partition of the SD Card.
6. Make a copy of the file, with the following command:
ip=169.254.0.2
Ctrl+x and y to save and exit.
8. Make a copy of this file too:
Summary
Now you should be able to do most of the things you would normally do when connected to a network.
It is even possible to use this direct network link to share your laptop/computers internet connection (if
it is connected via Wifi for example), although Ive not needed to do this yet.
One VERY useful thing to do is to set up Putty and Xming to allow you to control the terminal and
graphical programs directly from your laptop/computer.
(http://pihw.files.wordpress.com/2013/03/scratch-x11.png)
Scratch running nicely inside a window using X-11!
See the main Guide toRemote Connections (http://pihw.wordpress.com/guides/guide-to-remoteconnections/) for links for how to set-up VNC and shared folders, and X-11 on other computers.
In the PuTTY configuration, find Connection, SSH, X11 and tick the check-box for X11
forwarding. If you leave the X display location blank, it will assume the default Server 0:0 (you can
confirm the server number by hovering your mouse over the Xming icon in the system tray when it is
running). You can save your set-up within Putty so you will wont have to do this each time.
(http://pihw.files.wordpress.com/2013/03/puttycongif-x11.png)
Putty Configuration for X11 Forwarding
cd ~
sudo cp .Xauthority ~root/
More details and links are in the main Guide toRemote Connections
(http://pihw.wordpress.com/guides/guide-to-remote-connections/).
X11Forwarding yes
Save if required (ctrl+x,Y, enter), and reboot:
sudo reboot
nano switchip.sh
Just press ctrl+x and y, to save and exit when you are done.
switchip.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
#Function to swap to Direct IP Address
direct () { sudo cp /boot/cmdline.direct /boot/cmdline.txt;}
#Function to swap to Normal Automatic IP Address
normal () { sudo cp /boot/cmdline.normal /boot/cmdline.txt;}
# Menu using case-esac
echo "Select IP Address? Use Direct or Auto or Keep (d/a/-)?"
read answer
case $answer in
d|D) echo Use Direct IP;direct;;
a|A) echo Use Auto IP;normal;;
*) echo Keep - No Change;;
esac
echo cmdline.txt
echo ____________
20
cat /boot/cmdline.txt
You could even extend this to allow you to setup fixed IP addresses for different networks, so you can
always be sure you can find your IP and connect correctly.
ping www.google.com
or:
ping 173.194.45.49
Subnets:
Networks use subnets to help handle the fact that there could be a HUGE number of computers on a
network (like the internet) and it would be impossible for a computer to listen to and respond to any
computer in the address range 0.0.0.0 to 255.255.255.255.
To handle this, networks will use a subnet mask, this ensures that a computer only needs to respond to
computers with are within the same SUBSET, which is defined by the SUBNET MASK setting.
The mask is a series of flags which defines which range of addresses the computer will respond to (by
filtering out any which are not within the allowed range):
255.255.255.0
Means it will respond to computers which have IP addressing matching at least the 3 first numbers. So
a computer with an address of 192.168.1.90 and subnet mask of 255.255.255.0 will only talk to other
computers with addresses in the range 192.168.1.0-192.168.1.255 (except 90 of course!). Large networks
often use SUBNETs to split up larger networks into sections so that they run more efficiently.
Note: You will not be able to set the SUBNET MASK to wider than 255.0.0.0. The Raspberry Pi defaults
to a subnet mask of 255.255.0.0, which is perfect for most situations.
References:
Thanks to fellow MagPi - Colin Deady for testing out on Mac for me.
Thanks to the following sites for providing various parts of the puzzle (in no specific order):
www.kernel.org kernel documention
(https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt)
http://learn.adafruit.com/adafruits-raspberry-pi-lesson-6-using-ssh (http://learn.adafruit.com/adafruitsraspberry-pi-lesson-6-using-ssh)
http://people.arsc.edu/~murakami/xming/ (http://people.arsc.edu/~murakami/xming/)
http://jeremy-nicola.info/portfolio-item/ssh-x-forwarding-on-windows/ (http://jeremynicola.info/portfolio-item/ssh-x-forwarding-on-windows/)
http://en.wikipedia.org/wiki/Subnetwork (http://en.wikipedia.org/wiki/Subnetwork)
http://en.wikipedia.org/wiki/Link-local_address (http://en.wikipedia.org/wiki/Link-local_address)
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=22716
(http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=22716)
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=27&t=24993
(http://www.raspberrypi.org/phpBB3/viewtopic.php?f=27&t=24993)
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=32&t=26934
(http://www.raspberrypi.org/phpBB3/viewtopic.php?f=32&t=26934)
Comments
supto says:
July 16, 2013 at 3:47 am
successful thank you very much and appreciate your awesome work which made our job very easy.
Reply
Direct Access Raspberry Pi Shell and Desktop on Laptop/PC without installing anything
Yes, this configuration works just fine. You can do RPI software updates via the direct
connected PC and the WiFi shared port. I find that some RPI programs like Leafpad do not
work under this connection option but I would only use this connection method for software
updates on the RPI anyway. Otherwise just use the direct connection mode. Oh yes, make
sure the PC ethernet port is not set to sharing as that run me around for a while. Tims
package works great.
Richard
Andrew Cluff says:
July 19, 2013 at 2:39 pm
hey my pi wont ping the laptop.
Reply
Aaron P says:
July 19, 2013 at 3:10 pm
Excellent walkthrough! Tried it with NOOBS but the cmdline.txt file does not exist. Downloaded the
newest Raspbian image from raspberrypi.org/downloads, imaged that to my SD card, let it start up
once all the way, turned it off and followed the directions on this page. Worked like a charm. No
hiccups. Xming works excellent for this. Thank you for the good writeup!
Reply
meltwater2000 says:
July 29, 2013 at 9:49 am
Yep, Ive yet to have chance to try NOOBS, I am hoping there is a similar way to specify the
start up command-line, there probably is just moved somewhere.
Reply
PiNE says:
July 24, 2013 at 2:18 pm
Hi Meltwater,
Got direct connection working (with PuTTY and UltraVNC) but the one thing that gave me
problems was pinging the W7 PC during the initial set up. The Pi sent packages but the PC did not
reply. Looking at The Network and Sharing Centre, the PC seemed to be receiving stuff, but was
not responding. Hmmm? Checking the PCs IP address, it showed 169.254.98.136.
Not important because Ive got the direct link working, but any ideas why the PC did not respond?
Cheers
Reply
meltwater2000 says:
July 29, 2013 at 9:38 am
Might be down to your default firewall settings perhaps, or sometimes it can get confused about
which connection to use (such as wifi). I think this is because it classes the direct link as a bad
link (there is no internet or router responding) it will respond on the other link instead.
Reply
Louis says:
July 28, 2013 at 3:31 pm
Im stuck, if followed the instructions, made sure everything is as identical as it can be (apart from ip
adresses) but when i open PuTTy is freezes, waits then says connections timed out
Reply
Louis says:
July 28, 2013 at 3:32 pm
A few typos: I open PuTTy it connection has
Reply
Louis says:
July 28, 2013 at 3:59 pm
Forget all that, it works now, but my question is now: how do you configure it to show the
programs/desktop?
Louis says:
July 28, 2013 at 4:51 pm
Finally got it all working, please ignore all my other posts
meltwater2000 says:
July 29, 2013 at 9:40 am
No problem, Linux can be very fussy about the text file format.
Les says:
July 29, 2013 at 9:01 am
Im hoping to use the Pi to collect data from inside a beehive. How would I link the Pi and a W7
laptop wirelessly, so that the laptop can control the Pi and collect the data?
Reply
meltwater2000 says:
July 29, 2013 at 9:35 am
Ive not had chance to experiment much with wifi links so far, but you may find some of the
solutions at the bottom of this post useful.
http://blogs.arcsoftwareconsultancy.com/pi/
Reply
Les says:
July 29, 2013 at 11:14 am
Ooops. Jumped before I was bitten. Picked up the ip from the Pi with ifconfig. Set the laptop to
the same network. Both had the same mask. Loaded putty on the laptopdone.
Apologies for being gormless.
Reply
meltwater2000 says:
I wanted to thank you for the awesome instructions. I found myself in an isolated part of the coast of
I wanted to thank you for the awesome instructions. I found myself in an isolated part of the coast of
Maine without access to a monitor and keyboard. Although I had to drive 45 minutes to a Radio
Shack, I was able to pick-up a RJ45 cable and USB SD Card reader and implement the connection
instructions you provided.
This approach will be my travelling solution for setting up and running Raspberry Pi based
applications in the future. The SD Card reader, RJ45 cable, Pi and laptop are all going in the travel
bag.
I got great time-lapse photograps of sunsets this time. Not sure what might happen in the future.
Sarge
Reply
meltwater2000 says:
August 15, 2013 at 9:00 am
Thank you for sharing your excellent success! A tiny computer isnt so small if you need a
monitor to use it.
I would love to see the time-lapse you have produced.
Reply
Saravanan says:
August 16, 2013 at 10:16 am
I have a new pi.and I am using Ubuntu in my laptop.And configured the file in memory card and
all.Ubutu is set to automatic DHCP by default for wired connection.I switched on raspberry pi with
ethernet cable plugged in,The status LED is turned on in the pi.but I cannot establish connection
between pi and laptop(Connection fails all the time).I dont have a tv monitor orenything else to
connect with the pi help me.Do you have any video tutorials on youtube?
Reply
meltwater2000 says:
August 16, 2013 at 10:42 am
I did try to record a video, but it was taking too long to sort out.
Perhaps you can try using the .bat files which are in the
http://pihw.wordpress.com/guides/direct-network-connection/super-easy-direct-networkconnection/ post (even if you just use the CMDLINE.TXT file directly).
Unfortunately this will only work with a Raspbian image rather than the NOOBS system.
The common issues are:
1. Not using a linux compatible file editor on CMDLINE.TXT (ends up with extra characters
which shouldnt be in the file).
2. Having Wifi enabled on the Laptop when trying to connect (it tries to ping through that
rather than the LAN)
3. Ensure you wait for your LAN connection to finish detecting the direct connection (check the
status of your network device and that it has an IP given to it).
Reply
F. Janes says:
September 16, 2013 at 9:09 pm
Hi Les,
Since Im very interested in Your project to gather data inside a bee hipe, did You succeed in doing
it?
Thanks
Aloha
Reply
techie009 says:
September 17, 2013 at 12:27 am
where can i find the file cmdline.txt ? I cant find it . i have a file named recovery.cmdline , I treid
editing this file and following the steps you mentioned, but it didnt work.
Reply
meltwater2000 says:
September 18, 2013 at 9:31 am
HI. You are using NOOBS, which makes this trick a little more difficult.
See the note on this page:
http://pihw.wordpress.com/guides/direct-network-connection/super-easy-direct-networkconnection/
Reply
techie009 says:
September 19, 2013 at 5:26 am
Hi, thanks for the reply. I tried doing the same as mentioned in the link, i meant using the
VM,but unfortunately I could not fine the cmdline.txt. Can you please help me with that.
Also yes I am using NOOBS.
meltwater2000 says:
September 19, 2013 at 9:40 am
When I connect it to my Debian VM, it has two mount points, including /media/boot.
Within there you will find the cmdline.txt file (which will get executed after the NOOBS
system has booted).
Hope that helps.
starcow123 says:
September 19, 2013 at 7:23 pm
PuTTY Fatal Error
Network error: Connectio timed out
Windows 8-64bit
Windows 8-64bit
Raspberry Pi Model B
Standard ethernet cable (not crossover)
Using PuTTY and Xming
First boot on Raspberry Pi on Raspbian
in SD root file system I only have cmdline.normal
HELP?
Reply
meltwater2000 says:
September 19, 2013 at 7:31 pm
You need cmdline.txt in there. cmdline.normal / cmdline.direct etc are example files (and used
by the bat script to change cmdline.txt). You want to make cmdline.txt match cmdline.direct for
direct connections.
Reply
Saravanan says:
September 20, 2013 at 8:56 am
Can you write a tutorial on X11 forwarding in ubuntu/linux.I can now access the command line of
pi only.
Reply