Alvin Pastore

One Good Shepherd

AGE

30
and counting..

AREA

Sheffield, UK

INFO

PhD researcher @ The University Of Sheffield

Don’t tell me how educated you are,
tell me how much you traveled.

The Prophet Mohammed

Blog

a good shepherd’s thoughts

Habemus Raspberry PI

Dear all,

I know… last post was aaaages ago. I’ve been – and I am – really busy but I promise I’ll try to write a bit more now that I have a couple of side projects with my brand new Raspberry Pi.

My main ideas are in the area of home automation: remotely switching on/off on mains, wake-up station reusing an old tv and trying to come up with some way of using an otherwise abandoned kinect. I’ll be working on these side projects only during spare time but hopefully I’ll be able to write about every tiny improvement and share some code as well.

RPi Box I bought a RPi starter kit on Amazon for 50£. It includes the Raspberry Pi model 2 B (Quad Core, 1GB RAM), a snazzy box-case, a 5V 2A power supply, Hdmi and Ethernet cables and a Sandisk Ultra Class 10 MicroSD (8GB pre-imaged with NOOBS).

There are several starter kit, some come already with electronic components and a breadboard, but I will get those separately when I have more time.

Installation is really straightforward and for the hardcore noobs there is plenty of videos and guides to follow for this purpose. I recycled a set of monitor, keyboard and mini-mouse and set it up. WiFI Dongle

As I don’t really like the idea of having the RPi continuously wired to the router I got a wifi dongle from Amazon. It is claimed to be specifically manufactured for Raspberry Pi. I have no idea whether this is true but it works out of the box and pretty well (stability and speed).

 

First thing I want to do is make sure that every time my RPi connects to the router it gets the same local IP so that I can SSH into it.

 

To do so, first find the gateway (router address) with

ip route

and take note of the first line address

default via 192.168.0.1 dev wlan0

Now set up the gateway, netmask, broadcast and the local address you want

nano /etc/network/interfaces

I used 192.168.0.44 as local ip address

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static
address 192.168.0.44
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

It is worth rebooting to check if the IP gets assigned properly

An alternative way of setting up a static IP would have been to log in my router and assign 192.168.0.44 to my MAC address. To find the MAC address:

ifconfig wlan0 

wlan0     Link encap:Ethernet  HWaddr 00:0d:60:05:01:1f  
          inet addr:192.168.0.44  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:41369 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6284 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:14256133 (13.5 MiB)  TX bytes:821759 (802.4 KiB)

Next step is to set up port forwarding on my router. Each router has a different way of setting the firewall rules for this but, again, there are many guides online and you might be lucky and find a specific guide for your router or just work out how to do it. You will need your local ip (192.168.0.44 in my case). And that is why it is a good idea to have it static. Can you imagine setting up a different rule each time your device connects with a different IP?

Now from a different device connected to the same network

ssh -p XX pi@192.168.0.44

where

After setting this up I disconnected my keyboard/mouse/monitor and started accessing the RPi remotely. I can move this tiny piece of hardware around my house and plug it everywhere.

Next step will be accessing remotely over the internet (first step towards boiled remote switch). To do so I’ll have to determine my public IP, which is dynamic. I’ll prepare a python/bash script and write the next mini-guide soon.

Enough for now!

Alvin

Back to all posts
Comments

Leave a Reply

Travel only with thy equals or thy betters;
if there are none, travel alone.

“THE DHAMMAPADA”

BIO

Who is The Shepherd?

My name is Alvin and I am an Italian born learner.

I am interested in a broad variety of topics.

I am currently working on a multi-perspective topic called Neuroeconomics. It involves studying human behaviour in uncertain situations from different points of view. Psychological, Economic and Neuroscientific.

I cannot live without music. It is impossible to give a comprehensive list of genres therefore I will point you to my last.fm tagcloud.

I read a lot, mostly scientific papers, but I don’t dislike a good novel once in a while.

I love movies. I have a discrete collection (~140 titles), but I am always looking for new – or old – pearls to add.

I enjoy football, a lot. The company, the competition, learning tricks, using tricks, the passion, the commitment, the hits taken, the hits given, the victories, the defeats.

I had many teachers in my life. Some were in school, in university. Others were somewhere else, along my path. Some are still there and some are not anymore. Some are yet to be met. To all of them I say thank you.

Social Shepherd

The real thing is not reaching,
the real thing is the journey.

OSHO