Setting up Rasberry Pi as a Media Center



Recently got hold of a Raspberry PI as I had heard a lot about this thing. The main thing I wanted to do was set it up as a media center. Now, though a lot of information is there on the net about how to do it, there was sadly a lot of information which was missing. The main aim of this blog post is to help you to get a whole setup running - because getting just the Raspberry Pi will not really work out of the box. The Pi team also assumes that you will have a lot of these things already at home - and while that is mostly correct, it does not really help in a permanent setup.

Parts List

Here are the parts you will need. Basic Assumption - you have a TV with HDMI , and you have access to a laptop/PC and access to the internet. Also you have the media on a USB drive.

This is not mentioned in any one place, and it took me a while to figure out :

  1. The Raspberry Pi : I suggest getting the one which comes with a box cover, as here in India it is quite dusty. Also, get the Model B as it has more RAM, and extra connection ports. 
  2. A HDMI Cable : The Raspberry Pi connects to video via a HDMI port, and although your TV will already have a HDMI cable, you would already be using it. So, order a separate cable to use with the Pi else you will keep swapping the cable between the pi and the other box you use ( in my case the TV reciever box)
  3. A WiFi USB dongle : I suppose there will be a day when the pi will have the wifi inbuilt into the box. But so far, it comes only with an Ethernet connectivity. Since you will normally not have an ethernet cable running all the way into your living room, you will need the WiFi connectivity. Not all USB Wifi Dongles work ! Make sure what you purchase is supported - check the list
  4. A SD Card : The PI does not come with any hard drive. It uses SD cards for booting up. If you have a digital camera ( except the SONY ones), then you will already have a SD Card. You will minimally need a 4GB card - but I would suggest something bigger.
  5. A power source : The PI uses the same power adapter as most phones ( unless you have an iPhone). It is a micro-usb powered devices, so most android phone chargers would fit. What you want is something which can give 5V and 1.2 A . The google Nexus phone charger fits the bill perfectly. Technically, you can have a lower A ( 750 mA is the least power you need), but to power the USB ports, I would say go for something with 1.2A or else get a powered USB hub ( next point)
  6. A powered USB hub. Mostly the USB hubs we have are not powered. They derive the power from the PCs or laptops. But with the low power that the PI uses, if you want to get anything attached to the PI, get this. With the 1.2A adapter I have seen you can power a HDD and a wifi dongle. But nothing more. 
  7. A Keyboard and Mouse : Well, actually the mouse is optional, as you can do most things using the keyboard. Also keyboard will be required just at the start if really needed, else most of the TVs with a CEC remote - you can control the media center through the remote. 
  8. A SD Card reader. The way you will install the OS on the SD card is via a card reader. If you have a laptop with the built in slot - great - you can use that. Else you will need a card reader. 

Cost

Here are some links to get you started off on your purchase : 
  1. Raspberry Pi with clear case at Crazy Pi : Rs 3,490
  2. HDMI cables from Amazon : Rs 399
  3. COMCAST WiFi USB from Amazon : Rs 399
  4. 8 GB SD Card from Amazon : Rs 467
  5. Powered USB hub from Crazy Pi : Rs 750
So, that comes around 5,5k + taxes ( Amazon has taxes included in the price, but Crazy pi has additional tax and shipping fee).

Setting up the SD Card


Now that you have all the hardware, the next step is to install the OS on the SD Card. Head over to raspbian and download the installer. This is a small installer which will be used to install the entire system. 

XBIAN is a media center which is linux based.
RaspBian is an XBIAN build specifically for the Raspberry Pi
Next, connect the SD card to your laptop/PC. Follow the steps given on the installation page. In addition make sure click on the "Manually configure WiFi" which will popup a screen to enter the details of your WiFi Setup. 



Enter the details and let it finish writing to the SD card. 

Starting the Media Center

Now, assemble your PI by putting in the SD card, the WiFi dongle and connecting to the HDMI cable and the USB drive. Plug in the power source only after you have connected everything else. 

As soon as the power is connected this will boot up and you will see onscreen details scroll by. If the WiFi has been setup correctly, you will see the update starting. Wait for it to finish ( it is about 1GB! )

After that you will be in the Xbian interface and can start watching your media!

Raspberry Pi on PI day

Coffee with Pi
Got this... and now wondering what to do with it ! Any suggestions ?

Pressure Sketching

I came across the brush pen in the Comic Con a couple of weeks back. Picked up one to try it out. The pen has a flexible nib, so depending on the amount of pressure you put , the line is either thin or thick. It is quite difficult to get a hang of it.

This is my first sketch with it. As you can see - i suck at this :D


Turning off Autocorrect in Nexus 5

I got this asked a couple of times, so thought it best to blog it :D

The scenario in India is that we use a mix of English and Hindi words written in the Latin script. So you can easily have something like :

I am ok. Tera kya haal hai ? 

The 2nd sentence is Hindi in the Latin characterset. Autocorrect is your enemy here. It will change the Hindi into gibberish. And... you only realize this after having sent the message that it totally killed it. It is quite easy to change this behavior into something that works in a better way - switch off the autocorrect :

1. Go into settings and tap on Language & Input.

2. The keyboard you use is the "Google Keyboard" it is greyed out by default as it is the default keyboard. However, the settings icon is clickable. Go there.
 3. Next scroll down a bit and you will see Auto-Correction. Tap on that.
 4. Turn it off.

That's it. Now you can write whatever you want, and it will not try to be too smart. The words it will think as wrong will be underlined making it easy to see the wrong spellings and what you have typed.


In case there is really an error, you can just tap that word and get a list of words that are relevant. E.g. in the above example, the ok is in small case and you can fix that by tapping as below.

That's all that there is to it. And if you really want to type in Hindi, just get the Google Hindi Input keyboard from the Play Store and you can type it easily.

Jungle Ride

Hey this was fun !

That's what I thought after I had come back from the ride. All during the ride I was like "Oh Shit ! Oh Shit ! I am going to fall... "

The ride plan materialized all of a sudden. Abhimanyu's bike was finally not in the garage and rideable. He wanted an early 6am ride to some place near Sohna Road which got pushed to 7am. Knowing him I targetting 7am to leave from home. ETA given by Abhimanyu moved to 7:30am on the morning.





I reached the gurgaon toll first - and after a few mins which I used for photographing usual stuff - bike, the sun rising etc, these guys turn up. We headed out after a few mins. Felt good to meet them after ages!




We took an internal route through Gurgaon to reach Sohna road - which was pretty pathetic. No matter what the govt says that it is the Millenium city, the city roads are probably worse than a Gaon's road.

Near the BSF camp there is a road which goes off into the jungle. We plunged in. This lead us past the BSF encampment and up a hill, where the road just vanished. After a few mins we headed into the jungle. Saw quite a bit of wildlife here - peacocks, tree pies, bablers, parrots. What a contrast to the cacophony of traffic just an hour back! Lovely!






Sumeet asked to turn on a tracker - so we downloaded one on my phone as it was the one with the most charge. Seriously man - these guys dont even charge their phones or carry water before a ride. And they shrug it of as "we are bulleteers" ! :P

First we went to a babaji's temple - but then the decision was to just go and ride in the jungle first. So we headed away into the jungle.

Damn, this road was ... well... not a road. I was thinking this is more like a road where I would like to treck, but taking a plastic bike - i was sure that today either I will fall or some part of my bike will fall. We pushed on through thorn bushes and clinging grasses.

Finally we reached a place where there was a good view. Also we were a bit skeptical of whether the road goes on or not. Just a few hundred meters back we had met a couple of villagers who assured us that the road does not go on. Stopped and took a few pics. We could see the tall buildings of Gurgaon shrouded in early morning smog. Picturesque to look at. Like Abhimanyu said later "Even Gurgaon looks good from far!".












We decided to check out the road down on foot to see if there was really any road, and soon came up to a dead end. Sumeet and me were talking about what animals would be in this forest, and Sumeet was of the opinion that he would punch a leopard if it comes here. lol !

We headed back and I was told that we would now head to a Shiv mandir and the road was even worse than the one we had been through. "uh-huh" I thought.

However, either I was becoming more experienced on these roads, or maybe because the other road was a bit better, we did not have too many scares on the way. We did get a bit lost in the jungle but the tracker helped us get back on the route after going around in circles - which I suspect was deliberate on Abhimanyu's part.

We reached the mandir after reaching a small open ground ( check the panorama ) and where Sumeet was reluctant to take his bike as there were cows grazing there who seemed to be quite fond of his Bull in the last adventure he had there ! Anyways we headed down towards the temple.





There was a group of families which had come from Gurgaon whom we met there. One of the guys was quite happy to see us there on bikes ( though he was a bulleteer ) . We had a good chat with him and he had got all the kids and families there to the spot as otherwise they all ended up in the malls. Apparently there was a road which ended quite near to the temple and then it was a short hike up.

Time to head back , and the group extended their hospitality to us by giving us some much needed food and water !

We headed back to the open ground an the entrance of the jungle where there was a sutta break and I found out that there is a photoshphere feature in the camera, though I did not really use it for a sphere but for a panorama.








The route back was now a breeze after the initial climb where our bikes wanted to come down and we wanted to go up. Abhimanyu's bike developed a love relation between his front mudguard and the wheel... so he had a bit of problem turning the bike. But all in all, we reached the road safely and then headed to Manesar's McD for breakfast ( though the breakfast menu was over by the time we reached!)

Then I peeled off from the group and headed back as the bulls were doing 60kph and that was a bit too slow for the highway.

Great ride. Thanks to Abhimanyu and Sumeet for springing this on me. If I had known about the road before, I may have had two thoughts, but this worked out well for me !

PGSQL Common Commands

This is my short list of the psql commands I need to use. PgSql is something of black magic for me at this time, and I do not have time enough to go into its nitty gritties so far. So, short steps to log in , drop database , create database etc. I am more used to MySQL and these commands are weird for me.

1. To login :

sudo -u postgres psql

If you get an error like:
psql: FATAL:  role "vibhu" does not exist

It means you are not using the correct psql user. For some reason, here the user is a user named postgres and that has administrative rights on the table.

2. To see the databases:
postgres=# \list

Self explanatory. Instead of show databases; just \list

3. To drop a database
postgres=# drop database somedatabase;

Do not forget the ; at the end. In example above 'somedatabase' is the name of the database.

4. To create a database
postgres=# create database somedatabase with owner vibhu;

Where 'somedatabase' is your database name, and 'vibhu' is the person who has ownership over the database. This I do as I do not want the admin user to be always working on the database.

5. Bonus : To reset the db on heroku ( I am using django on heroku )

heroku pg:reset DATABASE



The Overview Effect

A must watch video of the view from space, and the thoughts of the astronauts who have had the profound experience.


OVERVIEW from Planetary Collective on Vimeo.

Some things to watch out for:

  • The description given by the astronauts
  • Thunderstorms from space
  • Auroras from space


Also check out the music :