Monday, February 25, 2013

Getting to your pi from the outside

So now that you're familiar with the Pi, and clearly love playing with the Pi, and are busy programming the pi loads.
Now comes the problem of what happens when you need to leave the house. but still want to get to some stuff, (say you store some files on the device and want to get at them using SCP), or you want to run programs via SSH.

Allowing Access
The first thing that you're going to do is called Network Address Translation, Otherwise known as port forwarding.

First connect to your router, To find your routers address open up the command prompt and type
ipconfig, you'll fine a line that says gateway address, this is your internet router.

(probably on address 192.168.0.1 or 192.168.1.1 or 192.168.1.254)

Connect to this address in a web browser, and enter the username and password that's listed on the sticker on the bottom of the router, or in the instruction manual that came with the router.

Look at the internet settings, for the firewall that runs on the router. you'll need to look for a section marked NAT or Port forwarding.

In here you'll find a section that says, Outside port, inside port, and local address.

You need to put the port that you want to connect to your SSH server in the outside port box, (the default port for SSH is port 22, but you might want to put say port 66, or port 93 something that you can remember, but is not standard (so ideally people won't try to connect to it).

For the inside port you need to write 22.

In the address box you need to write the address of your raspberry pi.

you find this out by typing

ifconfig in the command prompt


Getting there
There are two ways of getting to your Raspberry pi.

Either you visit www.whatismyip.com before you leave the house all the time. and connect via IP address.
Or you sign up to a dynamic DNS provider like no-ip.com

I've signed up with no IP.com so the rest of this article will be giving instructions on how to install the client.

On a windows machine you can install the client just by running an executable.
On a Linux machine however there is no pre-made executable.

So to get this working you need to do the following.

First go to www.no-ip.com and create an account. chose either free or paid for dynamic DNS services. (depends what you want).

Now come back to your Raspberry Pi.

You need to be at a command prompt, (either not using x at all, or using the console shell within x.)

First start in your home directory, (which should be /home/pi)

You can find out where you are in the directory structure by printing the working directory.
pwd

If the output is anything other than /home/pi
Then type cd /home/pi

Now you need to create a new directory to put your download into

mkdir noip

And go into that directory

cd noip

Now you need to download the linux client files from the no-ip website.

wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz

Then you need to extract and unzip the files from the archive that you downloaded.
To do that use the following command:

tar vzxf noip-duc-linux.tar.gz

Then you need to browse into the folder that was just created.
So type ls to see what it's called:

pi@raspberrypi ~/noip $ ls
noip-2.1.9-1  noip-duc-linux.tar.gz


Then use the change directory command to move into that directory.

cd noip-2.1.9-1

Now you need to make the software only superusers can make software so you'll need to use the sudo command.

sudo make

then you need to install so type
sudo make install


when this set up runs you'll be asked for the user name and password to login to the service.

The trouble is, at least when I ran this, the configuration wasn't saved.

so in order to generate a configuration file type:
sudo /usr/local/bin/noip2 -C

then enter the user name and password details again.

this creates a configuration file in the /usr/local/etc directory called no-ip2.conf

now you can run the client
sudo /usr/local/bin/noip2

you probably want the client to run each time the machine reboots (so that you always have an up to date assignment of address to your host-name)

so you should add the no-ip client to a start up script.

To do this:
type
sudo nano /etc/rc.local

then use the arrow keys to go to the bottom of this file

then go up a few lines so your cursor is just above the line that says exit 0
then type the path and executable name

/usr/local/bin/noip2

to exit the editor hold down control and press X it'll ask you if you want to save, so press Y, then press enter to confirm the file name

now reboot your Raspberry Pi with the command
sudo reboot



You can check that the client is running by typing
ps -ef | grep noip

Monday, February 18, 2013

Introduction to the Raspberry Pi

Last week I mentioned that I got a raspberry pi for Christmas.

Now I'm going to take a closer look at the device.

The first thing that immediately springs to notice is that it's really small.

There appears to be nothing to it.

there is a series of pins sticking up labelled P1, these are the GPIO pins, There is a yellow composite video connector next to this, then a 1/8" jack socket, then you see a stack of 2 USB sockets, then a network port.

moving round another corner there is an HDMI socket, in the final corner of the board is a micro USB socket that's where the power for the device is provided.





Flipping the board over and looking at the back shows you where the SD card socket is:



The first picture of the front of the board shows that I've already started attaching small aluminium heat sinks to the device.


So, the Raspberry pi comes literally as a board.
to actually use this you;re going to need:

A USB keyboard (at least for the first time you turn it on)
A USB mouse, (you can forget this if you never use a mouse)
A power supply (a 2A 5v supply with a USB micro socket, (perhaps an IPad supply is a good idea!)
A video lead, either HDMI or a yellow RCA lead, (and possible an RCA - Scart adapter if your TV does not have RCA inputs.
Probably a network cable, or a wireless adapter, (but only if you want to go on-line or have connectivity from any other device in your house etc.)

When you've got your Blank SD card you're going to need to figure out how to write to it.

Assuming that you're using windows, you need to down lad the win32Diskimager program.
insert the SD card into an SD reader.
download an image or the current supported distribution from the raspberry pi foundations website.
Write the image to the card, pop it into the SD slot on the Raspberry pi.
plug the Pi into the TV, switch it all on...


The first screen that you're faced with is a screen for customising the Raspberry pi, and overclock options.

I highly recommend to just quit this now.

Use the device for a bit first, and then figure out what you need to change.


When you've exited from this configuration thing you're going to be left at a text prompt.

the user name that you need to login with is pi.
the default password is raspberry.

Given that everyone now knows your password the first thing that you should do is type:
 passwd
to set a new password!

Now you're going to be looking at a text screen, this is how I prefer to work with Linux, since I don't use it as a desktop OS.

There are a few commands that you can type now.

pi@raspberrypi ~ $ cat /proc/cpuinfo
Processor       : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 697.95
Features        : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2708
Revision        : 000f
Serial          : 00000000e80c5a57

The first thing that you should take a look at is what board you have. (and where it was made)

the revision describes what model of Raspberry pi you have:
'0002' => 'Model B Revision 1.0',
'0003' => 'Model B Revision 1.0 + Fuses mod and D14 removed',
'0004' => 'Model B Revision 2.0 256MB', (Sony)
'0005' => 'Model B Revision 2.0 256MB', (Qisda)
'0006' => 'Model B Revision 2.0 256MB', (Egoman)
'0007' => 'Model A Revision 2.0 256MB', (Egoman)
'0008' => 'Model A Revision 2.0 256MB', (Sony)
'0009' => 'Model A Revision 2.0 256MB', (Qisda)
'000d' => 'Model B Revision 2.0 512MB', (Egoman)
'000e' => 'Model B Revision 2.0 512MB', (Sony)
'000f' => 'Model B Revision 2.0 512MB', (Qisda)

 Mine was made by Qisda, in china, exactly like the Made in china label says.

you can also have a look at the firmware version by using the vcgencmd utility
 vcgencmd version
Oct 25 2012 16:37:21
Copyright (c) 2012 Broadcom
version 346337 (release)

or we can use the uname command:

 uname -a
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux

Next we want to be able to know a few more things about the Raspberry pi.

By default this thing comes without any heat sink. just bare chips soldered to a board.
we can see the temperature of the main processor by using another vcgencmd command

vcgencmd measure_temp
temp=44.4'C

There are a few other commands that can be used with this utility, have a look here
http://www.elinux.org/RPI_vcgencmd_usage


Having gotten our firmware version (346337)
we might want to upgrade our firmware,

To do this I assume that you have a working internet connection.
(when I say working I found that the name resolution was a bit buggy so had to add DNS servers to /etc/resolve.conf (I added nameserver 8.8.8.8 and 8.8.4.4)

so we want to use the command:

sudo apt-get update && sudo apt-get install raspi-config libraspberrypi*

That's 3 commands really, the first is :

sudo That means do a super user command, (regular users can't run stuff that can break things)
then you say apt-get (which launches a program that can go find and install software for you).

then we say update this means update the list of stuff that can be installed.
then we are telling the program manager to install some stuff.

(I'll come back to this command in a later tutorial I'm sure, or you can go search for it's usage!)


This command updates the firmware.

after it's finished you'll be returned to the login prompt and should type

sudo reboot

(that restarts the device)

Now when you type

vcgencmd version you find that it returns

Feb  7 2013 16:46:17
Copyright (c) 2012 Broadcom
version 367974 (release)


Lastly the command you want to use to upgrade the kernel is

sudo apt-get dist-upgrade


now when I type
uname -a I get a different software version

Linux raspberrypi 3.6.11+ #371 PREEMPT Thu Feb 7 16:31:35 GMT 2013 armv6l GNU/Linux

Monday, February 11, 2013

Craft: A heart shaped box for Valentines day

As I mentioned in the post when I http://ah-screwit.blogspot.co.uk/2012/11/the-solidoodle-has-landed.html got the solidoodle that I'd made a heart shaped box.

I thought that as valentines day is soon that I'd go through the design steps for the box in Creo Elements so that you can make your own.


The first, (and perhaps most important thing) is that there is no grid function in creo elements, there is a snap function, but there doesn't seem to be a way of showing a grid on the work plane that you're currently editing.

This means that I end up drawing construction lines all over the place.
So, your box should start with a line.

20mm long,
Then in the line of this line, draw a line 20mm long perpendicular to this

Next you need to select the 3 point Arc tool


Click at the junction of the 2 construction lines, and then at the end of the first line, now move your mouse away from that line and see where the arc is, since the diameter of my "circle" would be 10mm, I need the radius of my arc to be 5mm











This is then repeated on the other side,


Finally the straight line tool is use to finish the rough heart shape connecting the arc to a point at the bottom.


I then use the pull tool to make the box 10mm deep.




Then start again with the arc tool, this time make the arc start 1mm in from the egde and at leach side, and the arc 3mm in radius.




Then join the two arcs together at the point


Then connect the the new arcs together with a new arc (where the round bit points downwards.

Finally remove the heart on the outside


Now use the pull tool again to sink the top of the box 8 mm into the box.


Finally use the blend tool,


Set the radius to 1mm, and click on every sharp corner to smooth out your model.


Export and print your model as appropriate

I also made a lid for my original box.


You can get the STL from the post I made in this thread of the solidoodle users support forum.

http://www.soliforum.com/topic/468/heart-shaped-box/

Monday, February 04, 2013

Experimenting with printing surfaces

So I decided that I'd experiment a bit with printing surfaces.

I've got my glass printing surface, and that's working great, but I'd still stretching Kapton over the top of it.
The Kapton tapes job is to provide a texture for the ABS plastic to stick to as it's extruded.

There have been many reports that people are not using Kapton, (which tends to get damaged over time) and are instead getting their textured surface from a film of hair spray that can be easily applied and easily cleaned off of the print bed.

Given that the point of both the Kapton and the hairspray is to provide texture I wondered if using a piece of frosted glass would allow me to have a durable print surface that I wouldn't need to keep applying, and that wouldn't wear out.


I used some glass etching cream, and painted it liberally over the surface of the glass, and left it for 15 minutes, the glass plate was then washed.


I secured the glass plate to the print bed with 6mm Kapton tape looped around the bed, and turned the bed on.

I realise that the glass is going to be at a cooler temperature than the aluminium bed that it sits on, so the print bed won't be the same temperature that the aluminium bed normally gets to.

To compensate for this I turned the temperature up in the pronterface print software and measured the glass surface temperature using a thermo couple.

When the glass was at temperature I attempted to print on it.
I found that the ABS did not stick at all.
despite what the common understanding or rumour says, it appears that Kapton tape provides a bit more than texture for the plastic to stick to.