Saturday, October 19, 2013

Using Raspberry Pi as IRC Client

I wanted to be continually logged into IRC and also use it as a logging client for message on the #doothings IRC channel.
What better way than to use Raspberry Pi?

Steps for using Raspberry Pi as IRC Client

  1. We will use IRSSI, whici is a terminal based IRC client.
  2. Install it by running sudo apt-get install irssi
  3. Also install screen by running sudo apt-get install screen
  4. screen and then press Enter
  5. IRSSI irssi
  6. /server
  7. /join #doothings
  8. Now you have logged-in to the #doothings IRC Channel.
  9. To Detach from the Client. Press Ctrl + a and then d
  10. You should be back to the terminal window.
  11. To rejoin the IRC window run screen -r

Settings for irssi

  1. To ignore joins / quits / nicks changes on a specific channel.
    /ignore -channels #chan1,#chan2,#chan3 * JOINS PARTS QUITS NICKS
  2. Auto Connect to a Server on startup
    /SERVER ADD -auto -network IRCnet 6667
  3. Auto Join to Specificed channels
    /CHANNEL ADD -auto #doothings IRCnet
  4. To Keep logging all these conversations
  5. To set Nicks and Real Name etc.
    /SET -> This should show all existing configured parameters.
    To change these just say
    /SET param-name value like /SET nick nism-pi
  6. /SAVE to save the entire configuration.
    All these steps if you think need to be improved, you can send in a pull request here

Thursday, October 10, 2013

Using Raspberry Pi as a torrent client.

Using Raspberry Pi as a torrent client

Advantage of using raspberry pi as a torrent client is that it uses very less power. For a comparison,

Power consumption of Raspberry Pi device is very less. (5V, 500 mA (2.5W) without any devices connected).

So obviously, its a better solution for downloads that take a long time. and better to keep raspberry pi always on over a desktop / laptop.


  1. sudo apt-get update
    sudo apt-get upgrade
  2. sudo apt-get install deluged
    sudo apt-get install deluge-console
  3. Start the deluge daemon by running deluged
    It creates the necessary files that we can now edit.
    Stop this after some time (5-10 seconds) by running sudo pkill deluged
  4. Now edit the auth file. But first create a backup.
    cp ~/.config/deluge/auth ~/.config/deluge/auth.copy`
    Editing the auth file. nano ~/.config/deluge/auth
    Add a line at the bottom of the configuration file with the following convention: user:password:level
    Example : pi:pi:10 (10 is full-access/administrative level for the daemon)
  5. Now let's update the settings for allowing remote connections.
    config -s allow_remote True
    config allow_remote
  6. Restart deluged for this configuration to take effect.
    sudo pkill deluged
  7. Intall deluge-web to be able to access it from remote.
    sudo apt-get install python-mako
    sudo apt-get install deluge-web
  8. Access deluge-web from a remote machine on the same network.
    Navigate to http://<rasberrypi-ip>:8112/ .
    You have a torrent server at your service!
    Enter the password as deluge and immediately change it.
  9. In addition to accessing the web-gui from you can also access it from an Android application like Torrent Manager.
    While using this app just provide the password which was changed in step 8.

    You can take a look at the RaspberryPi code repository of IOT-Pune

Wednesday, October 2, 2013

Home Automation with RaspberryPi Python - Django

Home Automation with RaspberryPi Python - Django

So after attending the 2 meet-ups for IOT-Pune. I got a Raspberry Pi and decided to play around with it a little bit. The following post will walk you through the steps needed to turn on/off a light bulb.

Things needed
1. Raspberry Pi
2. Relay switch
3. light bulb with wire to plug into main power supply

Lets us start!!!

  • sudo apt-get install python-dev python-setuptools
  • sudo pip install django
  • startproject mysite
  • cd mysite/
  • startapp ledblink
  • cd mysite
  • open file named and add the ledblink app in the INSTALLED_APPS so that it looks like this
    # Uncomment the next line to enable the admin:
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
  • add this to the templates dir make sure you  add import os at the top of the page
     os.path.join(os.path.dirname(__file__), 'templates').replace('\\','/'),
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
  • cd ledblink
  • open the file and change it to this
from django.shortcuts import render
from django.http import HttpResponse
import RPi.GPIO as GPIO
import time


def blinker(request):
    if 'on' in request.POST:
    elif 'off' in request.POST:
    return render(request,'control_page.html')
  • Let us add the template control pages so go ahead and create a templates directory in your ledblink app and add the following html code and name it control_page.html
<!DOCTYPE html>


<form action="" method="post">{% csrf_token %}
<input type="submit" name="on" value="on" />
<input type="submit" name="off" value="off" />

  • now let us create a url that links to this view. Goto the file in mysite directory cd ../mysite
from django.conf.urls import patterns, include, url
from ledblink.views import blinker
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'mysite.views.home', name='home'),
    # url(r'^mysite/', include('')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(,
  • Goto main folder of the project where the file is located and run the following command
sudo python runserver

open up a web browser and type in the address bar and you should have the following result

now lets get to the part where we connect every thing to the raspberry pi.

  • Sorry I couldn't get a better picture even though Nishant suggested to take the book out. :P But yoy connect the 5V out of the Pi that is pin 2 to the positive on the relay . The ground pin 6 to the regative of the relay and finaly GPIO18 to the corresponding pin on the relay board.

  • Plug the bulb in the main power supply. Go ahead and try turning on the bulb from the web Browser