Saturday, August 17, 2013

Deluxe Raspberry Pi

In this post I'll give you some quick tips and tricks that make Wheezy even better.

In my last post I walked through installing and configuring Raspbian Wheezy. Now that you're up and running, I'd like to show you some cool tricks and provide a couple of scripts to make Wheezy even more useful.

Silly Putty
If you read my previous post you might recall that I recommended enabling an ssh connection to your Pi using the configuration menu. If you did this, now might be a good time to install an ssh client so you can remotely connect to your Pi from another PC. This is also quite useful if you'd like to run your Pi without the need to view it's display. For example, I'm writing this post on a laptop, while my Pi is running in another room. But, that doesn't prevent me from accessing it. I'm simply using the free Putty ssh client for Windows to remotely connect to my Pi and run all of the terminal commands. Setting up Putty is straightforward, you simply need to find your Pi's address to connect, which you can do either from your router's admin page or by running the ifconfig command in the Pi's terminal window and getting the IP address in the inet addr line. Next you'll want to enter this IP address in the Host Name (or IP address) field, as shown below. Press Open and you should see a terminal window where you can enter the user id pi and the password you setup previously during configuration.

Hot Off The Press
Now that you can connect to the Pi (both remotely or directly) it's a good time to make sure the software and firmware are up to date. You can update the Wheezy distribution, along with associated Pi utilities by running the following command in the terminal window. 

      sudo apt-get update && sudo apt-get install raspberrypi* raspi-config

Enter Y when you're prompted to continue. This process will take several minutes or more to complete, depending on the number of updates downloaded.

Next you can update the Pi's firmware by installing a very handy utility called rpi-update. Type the following terminal commands to install the utility and run it:

     sudo apt-get install rpi-update
     sudo rpi-update
     sudo reboot     (if all looks well)

Share And Share Alike
My home setup has a shared network (NAS) drive. I thought it would be handy to connect the Pi to this drive so I could display photos, videos and exchange files between other networked PCs. If you'd like to do something similar you can do so by adding an entry to the fstab configuration file to mount the drive and make it visible to the Pi's file system. The steps below describe how to do this, where the example IP address of the drive is and default directory is /Public. Also, this example mounts the drive at the /mnt/n mount point in the filesystem. Obviously you can use any drive name or letter in place of n, but you should place this under the standard /mnt directory.

Enter the commands below in a terminal window:
      sudo mkdir /mnt/n
      sudo nano /etc/fstab 

Add something similar to this line in fstab, where the IP address and default directory refer to your network, or shared drive:  // /mnt/n cifs auto,password= 0 0

Press Ctrl-o to save the file, then Ctrl-x to exit
Enter this command: sudo reboot

Once you're rebooted enter the df command in a terminal window and you should see output similar to this:

     // 968428672 290909184 677519488  31% /mnt/n

Information, Please
Perhaps you've wanted to find out information about your Pi's configuration, such as the current firmware version, speed settings, temperature and so forth. Below I've provided a handy script sysinfo that displays all of this useful information. 

In a terminal window enter this command: sudo nano

Then enter each of the following lines:

echo === Current freq / max / min ===
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
echo === Temp ===
vcgencmd measure_temp
echo === Version ===
vcgencmd version
echo === CPU Info ===
cat /proc/cpuinfo

Once you've entered the lines press Ctrl-o  and enter the name /usr/bin/sysinfo, then press Ctrl-x to exit
In the terminal window enter: sudo chmod 777 /usr/bin/sysinfo
Now you can run the command sysinfo at the terminal window any time you'd like and you'll see output similar to the following:

=== Current freq / max / min ===

=== Temp ===

=== Version ===
Feb  7 2013 16:46:17
Copyright (c) 2012 Broadcom
version 367974 (release)

=== CPU Info ===
Processor       : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 464.48
Features        : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2708
Revision        : 000f
Serial          : 00000000xxxxxxxx

Just Chilling
If you'd just like to quickly check the system temperature you can do so using the temp script I've provided below.

In a terminal window enter: sudo nano

Then add the following lines:

/opt/vc/bin/vcgencmd measure_temp

Then press Ctrl-o and name the file /usr/bin/temp, then press Ctrl-x to exit
Then enter the following command: sudo chmod 777 /usr/bin/temp

Now you can simply run the command temp in a terminal window and see the current system temperature as below:


Install Some Paneling
Maybe you'd prefer to see the system temperature all of the time, rather than simply when you run a command. This is especially useful if you're overclocking and using the Pi to do processor intensive activities. Fortunately, this is easy to do. You simply need to add the Temperature Monitor to the status panel at the bottom of the screen. You can do this by right-clicking on an empty area of the status bar. This brings up a menu where you can choose Add/Remove Panel Items. Next, choose the Panel Applets tab and press the Add button. Scroll through the list and find the Temperature Monitor applet then press Add. You can also set the location of the temperature indicator by using the Up and Down buttons. I'd recommend pressing the Up button at least once so the temperature display is to the left of the Shutdown button. You should see something similar to this status bar below:

Time At Last
You may have noticed the clock in my status bar screen shot above shows 12-hour time. If you're like most of us, you're probably used to saying it's 2PM rather for 1400 hours. But, whatever floats your boat. If you fall into the former category then you might find this tip very useful. The panel's clock applet displays the current time using the strftime format string. You can look up the details if you'd like, but here's a handy format string that changes the time and date to a standard US format. Just right-click on the clock in the panel and choose Digital Clock Settings. Enter %l:%M%P (note the first sequence is %lower-case L, case matters) in Clock Format and %D in Tooltip Format (mm/dd/yy). You might also want to select Bold checkbox. Press Close and presto! you can now tell night from day.

In my next post I'll talk about how to remotely connect to the Pi's graphical desktop using VNC. Until then, happy baking!

No comments:

Post a Comment