Tag archive

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

  • XX is the port you opened/forwarded on the router
  • pi is the default username on the RPi
  • 192.168.0.44 is your local (static) IP

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

hello world!

Into the peaks

Here we are, starting a blog *again*.
As you will have noticed, the layout of the entire website changed. The blog is now embedded in a scrolling, colorful template.
This should be a more enjoyable layout for mobile devices users as well as old fashioned desktop/laptop addicted.
I will do my best to make the contents enjoyable as well.
As a prompt start I am suggesting an electronic relaxing track. It fits perfectly a really interesting video about the universe seen as scaled in powers of 10.

 

Music by Gas (Mat Jarvis)
Original Video by Charles and Ray Eames – POWERS OF TEN © 1977 EAMES OFFICE LLC