Showing posts with label RaspberryPi. Show all posts
Showing posts with label RaspberryPi. Show all posts

Friday, March 22, 2013

The Pi Series 3: Accessing Pi from Android

Assuming you have completed Step 2, you are now ready to access your Pi from an Android Device. In Step 2, you installed x11vnc in Pi in order to access the desktop of Pi. Now we will see how you can access the desktop from an Android Tablet. I used a Rooted Nexus 7 running CM 10.1 M2 for this experiment. However it should work on other devices as well.

The Process
1. Install following apps In your Android device.
2. Launch the Terminal Emulator and SSH to Pi using ssh pi@IP_ADDRESS command. Once you are logged into Pi, run x11vnc.


3. Once you get command prompt of Pi, start VNC Server by running the command x11vnc

4. Launch the Android VNC Viewer, fill in the details and hit the 'Connect' button at the top.


5. You should see the desktop of Pi on you screen.


Thursday, March 14, 2013

The Pi Edition and Conversion to HTML5

Last few days were quite, for lack of a better word, Eventful. Continuing the experiments with Raspberry Pi, I was able to host a special 'Pi Edition' version of my site in it (More on that in another post). Content wise, the site is almost a clone of the original site with some minor modifications in elements to distinguish the Pi edition from the original Site. It’s published in HTML 5 and hence should be accessible from almost all devices. However, the 'Games' section is still in Flash. So if you want to try out any of the games, you may be asked to install the flash player Brower plugin.

Site
(Screenshot of My Site)

When I launched my site almost 3 years back, it was based on Adobe Flash. For 3 years, it continued to be a Flash based site. Anyways, recently I had a calling to convert the site to HTML 5; considering the increasing number of mobile devices and the ever declining popularity of 'Flash' platform. The main problem was complete lack of knowledge in HTML 5 and the lack of motivation to learn the new language. But, the experiments with the Pi gave me enough rush to overcome these. So I goggled about converting flash files to HTML 5 and landed on Google Swiffy. It’s a handy little extension that can export a flash file to HTML 5 (with all the actionscript). It’s basically a single click procedure and Swiffy did an excellent job of converting my site to HTML 5 within seconds. After that, I needed to edit the exported page to add some custom scripts (Social Networks buttons etc.) and the new site was ready to be uploaded to the server.

In the coming days, as I learn more of PHP and Flash, I intend to tweak the site to make it more efficient.

Tuesday, March 12, 2013

The Pi Series: 2. Remote Access

So you are one of those unlucky people without a keyboard and mouse to connect to the newly setup Raspberry Pi. Well, if its any consolation, you are not alone and the world is not going to end. The beauty of Linux is that there seems to be a workaround for everything. Anyways, lemme tell you how to remotely control the pi from a Linux machine (one with a regular keyboard and mouse attached to it) or from an Android tablet for that matter. In this edition, I will stick to humble desktop/laptop.

Requirements 
  1. Raspberry Pi running Raspbian
  2. A linux machine - running a Debian based distro (I had an Ubuntu machine).
  3. LAN (I connected the pi using Ethernet cable and the laptop via WiFi)
If you want to access to Desktop of Pi, you need to have these two packages installed.
  1. A VNC Server in Pi - I used x11vnc
  2. A VNC Viewer in Linux machine - I used gtkvncviewer
How to Remotely Access Terminal of Pi
Before we start, please note that the default user name and password for Pi is 'pi' and 'raspberry' respectively. Now the procedure:
  1. Find out the IP Address of your Router and go to its settings page. To find out the IP address of Router, enter the command route in terminal of your Linux machine. In the output, look for 'Gateway' and the IP number mentioned below it. That is the IP Address of your router. Now, go to your router's settings page by entering the IP address of the router in a browser.
  2. Connect Pi to LAN and find out the IP Address of Pi in your LAN. To find out the IP address of Pi, Look for DHCP/DHCP Client Table (probably under LAN Status) in Routers Settings page. If you cant find out the IP, Google with model number as the procedure varies from router to router.
  3. In your Linux machine, take terminal enter the following command:
    ssh pi@<IP_OF_PI>
    (if the IP address of Pi is 192.168.1.103, command should be 'ssh pi@192.168.1.103')
  4. Some text will flash and it will ask if you want to proceed further. Enter "Yes" and proceed
  5. Then It should prompt for the password for the user 'pi'. The default password is "raspberry". Enter the password.
  6. Now you should see the command prompt of Pi. That means you have logged in to Pi remotely.

How to Remotely Access Desktop.
Now you have access to command prompt of Pi. Lets see how to get the GUI.
  1. Connect to Pi via SSH command mentioned above and once you get the command prompt, install x11vnc by entering following command:
    sudo apt-get install x11vnc
  2. In the terminal of your linux machine, install gtkvncviewer by entering the command:
    sudo apt-get install gtkvncviewer
  3. Once x11vnc is installed, run it by entering x11vnc in the command terminal of Pi

  4. It will ask to setup a password for VNC. Choose a password and press enter (This is a one time exercise)
  5. Once GTK VNC Viewer is installed in your linux machine, run the program my entering the command gtkvncviewer
  6. You should get a dialogue box (like the one given below) asking you to enter the address etc of remote machine.

  7. In 'Server(:port)', Enter the IP address of Pi and port as 5900 (i.e. following the above example, 192.168.1.103:5900)
  8. Give the username as 'pi'
  9. Give the password you setup in step 4 above and press enter.
  10. Another window will appear with the desktop of Pi. 

Now you can use the keybord and mouse of your laptop/desktop to control Pi. Thats it for now.
Next Issue: Accessing Pi from an Android Tablet

Sunday, March 3, 2013

Raspberry Pi - Map

Raspi Connections

A map of ports and connections on a Raspberry Pi. This is intended for a firsttime user. Just to get you familiarise wih what you can expect in a Pi. Click to enlarge the picture.

Thursday, February 21, 2013

The Pi Series: 1. Settiing Up our Raspberry Pi

What is a Raspberry Pi?
Raspberry Pi (Raspi or just Pi) is a mini computer thats small enough to fit in the palm of your hand. It is essentially a small motherboard. Pi is powered by an ARM Processor and 512 MB Ram with HDMI and Analog Video Output. It also has two USB 2.0 ports and one micro USB port for power. It has a SD Card slot. For connectivity it has an Ethernet Port. 

Getting the Pi in India
In India its available online and costs around Rs 3000 plus taxes (Gross price approx Rs 3400)

Setting Up the PI
Although its a capable computer on its own, one needs some essential things to set it up and make it work. To setup our Pi, we had to rely on several online resources in Lifehacker and Raspi Wicki pages. Here is how we did it:

Requirements
    1. Your own Pi.
    2. A Laptop or Desktop running Ubuntu 12.10 (We used Linux because its much more flexible than the standard Windows system)
    3. An HDMI Cable or AV Cable (the one we use to connect DVD Players or Cable STBs to the TV). You may have already figured out that HDMI gives better video output than the analog AV. However, we didnt had a HDMI cable and so had to rely on AV Cable.
    4. SD Card - Minimum 2GB. Recommended is a 4GB Card. We used a 2GB Card for setting up our Pi. Please be noted that, during the process, the card will be formatted. So backup any data in the card beforehand. You will also need a SD Card reader if you dont have a Linux machine to setup the SD card. Since we are not big fans of the Big Brother, we used a Linux machine to setup (So this guide is not applicable for those running Windows. Sorry all Windows FanBoys, You have to google it out. And did anyone say MAC? Seriously?)
    5. USB Keyboard and Mouse. This will make things much easier. But we didnt had these two and so had to rely on a more complex procedure. But it was more fun than plugging in a Keyboard and Mouse :)
    6. A standard Ethernet Cable (Yup, the cable we use in our office to plugin the computer to LAN)
    7. A Micro USB Cable. i.e. USB Cables of most of the phones will do.
    8. Audio Cable (Optional. Since we didnt want to test the audio, we didnt use audio cable), AND
    9. Finally the RASPI OS. We used Raspbian for our setup. Download it from here.
Step 1: Setting UP SD Card and Installing the RASPI OS
  1. Download the lastest version of Raspbian and unzip the .img file inside. (It's almost 500MB so it may take a little while to download.) Put the '.img' file in your home folder for ease of access. Lets rename it to "RaspiOS.img"
  2. Open up your Linux terminal in Ubuntu.
  3. Type this command "df -h". This is the command to list mounted devices.
  4. Insert the SD card in the slot in your Laptop (Note: Not a SD Card Reader)
  5. Repeat Step 3.
  6. Compare the results of Step 3 and 5. The device that wasn't there last time is your SD card. The left column gives the device name of your SD card. Note it down (e.g. /dev/mmcblk0p1). The last part ("p1" or "1") is the partition number, but you want to write to the whole SD card, not just one partition, so you need to remove that part from the name (getting for example "/dev/mmcblk0") as the device for the whole SD card.
  7. Unmount the SD Card so that files can't be read or written to the SD card while you are copying over the SD image. Command to unmount the device is "umount DEVICE_PATH" (e.g. umount /dev/mmcblk0p1)
  8. In the command line, you're going to need to type a single line to copy the contents of the Raspbian .img file to your SD card. It'll look like this:

    sudo dd bs=4M if=PATH_TO_IMG_FILE of=PATH_TO_SD_CARD_MOUNT_POINT

  9. You'll need to replace PATH_TO_IMG_FILE with the path to the .img file and PATH_TO_SD_CARD_MOUNT_POINT with the path to the SD card mount point. When you're done, the command should look something like this:

    sudo dd bs=4M if=~/RaspiOS.img of=/dev/mmcblk0

    It's very important that you do not get this information wrong or you could end up writing Raspbian to the wrong disk and cause serious data loss. Be careful! When you're sure you've got everything right, press enter.

  10. You will be prompted for the root password. Type it and press enter.
  11. It'll take some time for the dd command to copy everything over to your SD card. While that happens, it'll probably look like the Terminal froze up. Don't worry, it's still working and will likely take longer than an average 2GB copy to an SD card (so be patient). In our case, it took approx. 5 minutes to complete the process. Be Patient and get a cup of coffee in the meantime. When it finishes, the command prompt will return and your SD card will be ready. Eject it safely and stick it in your Raspberry Pi.

    Now You have a bootable SD Card and can plugin the Pi to a monitor. We used our standard LCD TV as the monitor.
Step 2: Connecting the Pi to Monitor and First Boot
  1. Since we did not had HDMI Cable, we used the normal AV cable to connect the Video output of Pi to the TV.
  2. We used the LAN Cable to connect the Pi to the Wireless Modem.
  3. Plugin the USB Keyboard and Mouse (If you have)
  4. Our TV had a USB Port. So we used a micro USB cable to connect the Pi to the TV via this USB port. This powers up the Pi. (If your TV doesnot have a Micro USB Cable, use the Laptop as power source)
Now you should see the Pi booting up on the TV Screen (basically a lot of text will flash through.


 (First Boot Screen)

Since you have already seen Ubuntu booting up, you may be familiar with what you see on the screen). Once your Raspberry Pi boots for the first time you'll  see a Raspi-config window with a pretty big list of settings.




(Config Screen)
 
If you have plugged in the Keyboard and Mouse, your trip ends here. But we didn't had these. So we were forced to take a longer route to access the Pi. So those interested in some hardcore Linux Shell adventure, follow us!!

(Contd..)