Wednesday, May 28, 2014

XBMC project - Post 7 - Interfacing IR Remote to Raspberry Pi

Story Board:
Post 1http://blog.karthiksunil.com/2013/07/installing-home-media-centre-dyi-xbmc.html
Post 2http://blog.karthiksunil.com/2013/07/xbmc-project-what-you-need.html
Post 3http://blog.karthiksunil.com/2013/07/xbmc-project-post-3-operating-systems.html
Post 4http://blog.karthiksunil.com/2013/07/xbmc-project-post-4-installing-openelec.html
Post 5http://blog.karthiksunil.com/2013/07/xbmc-project-post-5-updating-to-latest.html
Post 6http://blog.karthiksunil.com/2014/01/xbmc-project-post-6-installing-nas.html

Background:
Raspberry Pi as XBMC media device without a remote control... !!! Something is wrong. Of course we can use Android and iPhone apps to control using Wi-Fi. But after using for a while, it feels very awkward to look for phone, unlock it, search for the app, launch it, press desired button .. may be to pause the movie ?? Uff not a good idea. How about having our TV or any other existing IR remote to control our XBMC. This post explains how

What you need:
If you having completed installation of XBMC on Raspberry Pi, you just need one Hardware for IR remote to work..I bought IR module from ebay - http://www.ebay.in/itm/181394100511

It looks something as below. It works directly with Raspberry Pi, no soldering etc required




Connections:
Very straight forward connections, VCC will get 3.3V pin, that is first pin on left lane on GPIO stack. GND will goto any of ground pin. Data pin goes to any of GPIO pins, I selected pin 18. 6th on right stack. As shown below




Settings to be done on OpenElec
Step 1: Update and Upgrade your OpenElec
This is the way you can keep your system upto date. You can do it from XBMC user interface itself.
check this link http://wiki.openelec.tv/index.php?title=Updating_OpenELEC#Update_Methods

Step 2: Install LIRC

Log into OpenElec from a computer using SSH. You can use PuTTy from windows. Default user name and password - root / openelec

Execute following command to install LIRC

sudo apt-get install lirc

This will install LIRC. 

Step 2: Configure LIRC
For IR receiver to work properly you need to configure few settings..

First off OpenElec needs to be know which remote you are going to use and which buttons means what. This information is obtained from a config file called lircd.conf. This file needs to be placed in /storage/.config/lircd.conf

For this to be achieved there is a Utility called irreccord as part of LIRC which can be used.

first all kill all running LIRC services.

killall lircd

Now start the utility

irrecord /storage/.config/lircd.conf

The instructions are straight forward. However you need to name the keys in a specific format.

You can use following names as it explains:
KEY_PLAY
KEY_PAUSE
KEY_STOP
KEY_FORWARD
KEY_REWIND
KEY_HOME
KEY_LEFT
KEY_RIGHT
KEY_UP
KEY_DOWN
KEY_OK
KEY_MUTE
KEY_MENU
KEY_EXIT
KEY_BACK
KEY_NEXT
KEY_PREVIOUS

Step 3: Start the LIRC services
Following command starts the LIRC services. Make sure you have attached data wire to pin 18 as shown above

modprobe lirc_rpi gpio_in_pin=18 gpio_out_pin=1

You can also start the service automatically every time the OpenElec boots, by creating a file /storage/.config/autostart.sh with below content

#!/bin/sh
modprobe lirc_rpi gpio_in_pin=18 gpio_out_pin=1

Make the above file executable
chmod ugo+x  /storage/.config/autostart.sh


Now you are all set. Reboot the system and try using the remote


Watch below video for full explanation .. Don't worry about initial circuit design he has given, you would not need those additional resistors and capacitors..


Thursday, May 15, 2014

Home automaton - RPI - Software Needs - Post 3

Story board
Post 1 - Synopsys
Post 2 - Hwardware Requirements

Status: Just yesterday (14th May 2014), I completed this project and it is working liker a charm :) ... #feeling_achieved

Software design: 
Idea is to control the electrical switch (Relay) from anywhere.. So, we need to softwares in 2 parts

  1. One which triggers relay from Raspberry Pi
  2. The other which manages the web part of it. 

Software program in Raspberry Pi
One of most fascinating features of Pi board is that it has got GPIO (General Purpose Input Output) pins. We have got GPIO libraries, that can be imported into programs to work with GPIO pins in a very easy fashion. Most common programming language used in RPi is Python. The same is used in my project as well. 

Setting up GPIO pins and passing the commands to them. 
As the name suggests, we can set GPIO pins either as input or outputs. For our case we need to set one pin as Output pin. Following code snippet would do that

import RPi.GPIO as  GPIO
GPIO.cleanup()
GPIO.setmode(GPIO.BCM)
GPIO.setup(22,GPIO.OUT)

Above code initializes GPIO pins and sets pin #22 to Output mode.
Below pic can be used as a reference to GPIO pin layout. Note that the numbers are not in any sequence :) 



















To set a digital HIGH or digital LOW following code would help

GPIO.output(22, False)
GPIO.output(22, True)

The GPIO pin 22, 8th in the left side will be connected to Relay input pin as shown in my previous post.

Now logic can be written when to turn on relay or turn it off...
More on Software related to web control in next post

Tuesday, April 29, 2014

Home automaton - RPI- Hardware setup - Post 2

Story board
Post 1 - Synopsys

Raspberry pi


Of course you will need RPI. The above annotation shows important parts that need. If you want to use Wi-Fi , you would need a dongle also. You can purchase RPI from many online stores, I bought from Crazy pi for 3k

Dongle also from same place

5v relay board

Bought from eBay http://m.ebay.in/itm?itemId=111309959285, for RS450. Works perfectly with RPI.

Connectors
You would need some jumperconnectors to connect pi and ready board...

Wiring
You will need to run wire from trust board to device which you control.

Monday, April 28, 2014

Home Automation Raspberry pi - Synopsis - Post 1

I'm all set for my 3rd raspberry pi project. POC for home automation.

Requirement: When we are outside house and could not reach by evening, my wife keeps feeling bad that she hasn't switched light on.

Idea: Use RPI GPIO pin to trigger the switch on or off. Control RPI settings from my WordPress database.

Hardware needed: Relay board which can take GPIO input directly. RPI of course. Wiring from circuitry to device to switch on/off

Software: Python program to set a GPIO pin as output. High or low value can be fetched from my WordPress site using pycurl. The values in WordPress table can also be set using pycurl

I'll keep you guys updated with this new series

#raspberrypi #home-automation

Saturday, April 19, 2014

Simply Sedan - Post 4 - Engine Running in

Story line
Simply Sedan - Post 3 - First experience
Simply sedan - Post 2 - Prepare to buy


Running in Rules


This is my first experience with diesel engine. I want to maintain it well. Do went through few sites and understood few running in rules. Even though showroom people say no special running in needed few experts suggests to still
After going through few blogs, followhing are the recommendations. And I followed them till 1.5k kms and till first service


  1. Delay engine start
    Start the engine after 10 or 20 seconds of ignition on. Once you on the ignition, oil starts flowing to engine. In few seconds engine is well lubricated and ready to start

  2. Idling engine
    After starting engine. Keep it idle for couple of minutes then Go slow.

  3. Don't rev
    Don't rev the engine during running in period. Don't cross 2.5k rpm. Keep rpm between 1.2 to 2.5k .


  4. Different rpms
    Keep driving in different rpms. Don't fix at the same rpm for long time. This allows engine to be adjusted to all rpms.


  5. Applying brakes
    Don't apply sudden brakes, as much as possible. Let the brake pads ware and tear happen evenly.

  6. Before stopping engine
    Don't switch off engine immediately. Let the engine idle for couple of minutes, before turning engine off



I followed these rules till first service. till 1500 km. Hopefully it has improved the life of my engine

Friday, April 18, 2014

Tuesday, April 15, 2014

Simply Sedan - Post 3 - First experience

Story line
"Simply sedan - Post 2 -
http://blog.karthiksunil.com/2014/04/simply-sedan-post-2-prepare-to-buy.html

"Simply sedan - Post 1 - Research"   http://blog.karthiksunil.com/2014/04/buying-car-post-1-research.html
 

First experience
It was amazing, even though I had driven car many times before, this was my car. Wow good feeling. After celebration, we fixed Ganesha idol to dashboard, did a mini praying session and started from there. Driving was really easy, never felt like driving diesel car, due to no turbo lag. Amazing !

Pooja
Performed pooja at Ganesha temple at KSRTC layout, uttarahalli road. It went very well. Then visited sisters place and in-laws's place. Everyone liked it

    
Initial mods
Seat covers: Got G sports art leather seat covers for 14k in JC road from a known person. Cream and black combination.  It looks good.

Chrome fittings: For handle covers, window garnish, front grille I got chrome fittings.

Handles were compliment with seat covers :). Front grille fitting costed 3600 from snapdeal, but adhesive was not good, window garnish costed 3200, fitted at Konark's Jayanagar.

Auto Cop: Installed autocop security system which uses the stock remote.

Windows 3M film: With 70% visibility.

Under chassis coating and Teflon coating was compliment from showroom.