Comments Off on Raspberry Pi Print Server With AirPrint (iOS) Compatibility

Raspberry Pi Print Server With AirPrint (iOS) Compatibility

I was looking for a low cost way for my family to print from their iPhones, iPods and iPads when I realized that this would be a good job for my Raspberry Pi. The web is littered with instructions for this project. I mostly followed Lynsay Shepherd’s tutorial but not exactly. The steps I followed are below.

  1. First update and upgrade to be sure Raspbian is fully up to date. From the command line type the following and hit enter:
    sudo apt-get update
  2. From the command line type the following and hit enter:
    sudo apt-get upgrade
    For both of these steps if you’re prompted to continue just say yes.
  3. Next install the packages needed for this project. From the command line type the following and hit enter:
    sudo apt-get install avahi-discover cups cups-pdf python-cups
    When prompted to continue just say yes. It may take a while for all of these packages to install so be patient.
  4. Add our username to the CUPS server so we’ll be able to administer the server. From the command line type the following and hit enter:
    sudo usermod -aG lpadmin pi
    This will add the user pi to the list of admins on the CUPS server. If you want to add other users use the same command but replace pi with the username you want to add.
  5. Start the server to be sure it installed correctly. From the command line type the following and hit enter:
    sudo /etc/init.d/cups start
    If all went well you’ll see the following line and then be back at the command line:
    [ ok ] Starting cups (via systemctl): cups.service.
  6. Edit the CUPS configuration. From the command line type the following and hit enter:
    sudo nano /etc/cups/cupsd.conf
  7. Set up the port that CUPS will listen on. Look for the line that says “Listen localhost:631” and put a # in front of it to comment it out and type the following on the next line:
    Port 631
  8. Set up access control. Arrow down in the config file until you see the following:
    # Restrict access to the server...
  9. After the line that says “Order allow,deny” add a new line and type the following:
    Allow @Local
  10. Repeat step 9 for the following sections:
    # Restrict access to the admin pages...
    # Restrict access to configuration files...
  11. Hit CTRL-X to exit nano. When prompted to save be sure to say yes and hit enter to confirm the file name.
  12. Restart the CUPS server to be sure the changes take affect. From the command line type the following and hit enter:
    sudo /etc/init.d/cups restart
    If all went well you’ll see the following line and then be back at the command line:
    [ ok ] Starting cups (via systemctl): cups.service.

The server is now set up. Let’s add a printer. Be sure your printer is attached to the Pi then do the following:

  1. Launch a web browser and go to https://192.168.1.X:631 (Use the IP address of the Pi and go to port 631.) If prompted that the page is unsafe click the option that will allow you to continue to the page.
  2. Click Administration.
  3. Click Add Printer in the Printers section. If prompted for a username and password enter the username and password for the pi account.
  4. In most cases your printer will be listed in the Local Printer section of the next page. Click the radio button next to it and click the Continue button.
  5. On the next page be sure to click the Share This Printer box. Feel free to change the Name, Description and/or Location fields (or not). Then click the Continue button.
  6. On the next page select the appropriate printer driver for your printer. If your printer isn’t listed consult your printer manufacturers website for the Linux driver for your printer. (I had to run ‘sudo apt-get install hplip‘ to add my HP printer to the list.) If your driver is in a separate file then click the Choose File button in CUPS, navigate to the driver and click the Open button.
  7. Click the Add Printer button.

The next page is to set default settings for the printer so we won’t worry about that now. Let’s print a test page to see if this all worked.

  1. Click Printers.
  2. From the Maintenance menu click Print Test Page.
    If all went well your printer will print a test page.

Printing from Mac OSX and iOS should now work with no additional setup. For Windows, however, we need to continue install and configure SAMBA.

  1. From the command line type the following and hit enter:
    sudo apt-get install samba
    When prompted to continue just say yes. It may take a while for all of these packages to install so be patient.
  2. Once SAMBA was installed my Windows machines were able to print. If your Windows machines can’t find the printer then edit the SAMBA configuration. From the command line type the following and hit enter:
    sudo nano /etc/samba/smb.conf
  3. Look for the line that says “[printers]” and add the following above it:
    printing = cups
    printcap name = cups
  4. In the [printers] section change the ‘guest ok‘ setting to yes.
  5. In the [print$] section change ‘path‘ to /usr/share/cups/drivers
  6. Hit CTRL-X to exit nano. When prompted to save be sure to say yes and hit enter to confirm the file name.
  7. Reboot the Pi to be sure all is well.

At this point everything should work. However I had a Windows 10 machine that wasn’t working quite right. After some searching I found the solution outlined here worked for me.



Comments to this post

Tags: , , , , , ,
Comments Off on Setting Up A Raspberry Pi

Setting Up A Raspberry Pi

Lately I’ve been doing some projects with the Raspberry Pi. The Raspberry Pi is a small computer on a single circuit board using an SD card as it’s hard drive. I decided to share some of the things I’ve done with mine starting in this post with how I set up the operating system.

Note that there are different ways to install an OS on the Raspberry Pi as well as different OSes. I chose to install Raspbian, a variant of Debian Linux. In all cases an SD card is needed as that’s the storage mechanism.

First we’ll set up the SD card:

  1. Format a new SD card (minimum 4GB in size) as FAT. I used the Mac OS X DiskUtility (Erase” with “MS-DOS” format). Windows users can use the SD Association’s Formatting Tool. Be sure to set the “FORMAT SIZE ADJUSTMENT” option in the “Options” menu to “ON”.
  2. Download the latest version of NOOBS.
  3. Unzip the contents of the .zip file.
  4. Copy the contents of the .zip file to the root of the SD card. (This can be done using the dd command on a Mac or Wind32 Disk Imager on Windows.)

Now that our SD card is set up we’re ready to move over to the Pi.

  1. Eject the SD card from the Mac or PC and insert it into the Raspberry Pi.
  2. Set the Raspberry Pi up with an HDMI monitor, keyboard and mouse.
  3. Power up the Raspberry Pi.
  4. Once the Raspberry Pi has completed booting you will be in the NOOBS interface. Click the Raspbian checkbox and click the ‘Install’ button.
  5. When the confirmation pops up click the ‘Yes’ button. (This confirmation is warning you that any existing data on the SD card will be overwritten.)

Raspbian will now install. The progress bar at the bottom of the install dialog will let you know how far along the install process is. It may take a while.

When the install completes a dialog will appear letting you know your OS is installed. Click OK. The Pi will now re-boot, complete some housecleaning for the OS to run and launch the GUI for Raspbian.

Now it’s time to set up our WiFi adapter. This can be done either from the GUI or the command line. We’ll do this via the GUI since we’re already there.

  1. Click the Network icon in the taskbar and select your wireless network from the list that appears.
  2. Type your WiFi password into the dialog that appears and click the ‘OK’ button

Now we will set a few preferences:

  1. From the Menu select Preferences->Raspberry Pi Configuration.
  2. In the System tab change the ‘Boot’ preference from ‘To Desktop’ to ‘To CLI’. This will make the Pi boot to the command line without loading the GUI. (The GUI can always be loaded from the command line by typing ‘startx’.)
  3. Go to the ‘Localisation’ tab.
  4. Click the ‘Set Locale’ button, select your Language and Country and click the ‘OK’ button. A message will appear saying ‘Setting Locale’. Once this completes you can continue.
  5. Click the ‘Set Timezone’ button.
  6. Select your Area and Location then click the ‘OK’ button.
  7. A message will appear saying ‘Setting Timezone’. Once this completes you can continue.
  8. Click the ‘OK’ button in the ‘Raspberry Pi Configuration’ dialog.
  9. In the ‘Reboot needed’ dialog click the ‘Yes’ button to reboot. Upon rebooting you should be at the command line.

If things went correctly you should now have WiFi access. Type the following:
sudo ping 8.8.8.8
If you get a response then you have an internet connection. Hit CTRL-C to end the ping.

You should also have SSH functionality. To see if this is working do the following:

  1. From the command line type the following command and hit enter:
    ifconfig
    This will show your current network configuration. Find your wireless connection (it will probably be wlan0) and find the ‘inet addr:’ setting (it’s probably the first setting on the second line).
  2. Now go to a terminal window on another computer (Terminal on Mac, Putty on Windows) and SSH to the IP address found in step 1 using the username pi and password raspberry.
    If you’re connected then you have ssh access to your Pi.

Now you’re ready for whatever else you want to do with your pi.



Comments to this post

Tags: , ,
Comments Off on Toothpicks and Mobile Phone Maintenance

Toothpicks and Mobile Phone Maintenance

A while ago I had a problem with my mobile phone. Most often I’d plug in the charger and the phone would not recognize that it was plugged in. I experimented with different chargers and determined that the problem was not the chargers but the phone. Someone suggested it may have lint in the charging port since it spends so much time in my pocket. So I took a standard round toothpick and gently poked around the inside of the charging port and a large ball of lint came out when I pulled out the toothpick. Afterward the charger worked with no problem.

Flash forward to the other day when I was having problems with my earbuds on the same phone. Sometimes the inline remote would work. Other times not. Likewise the audio and microphone. Needless to say if the remote, audio and mic are not working then the earbuds are worthless.

Since I’m very picky with my earbuds (I don’t like the in-ear type but want the inline remote; I only know of one brand of these still available and they are not being manufactured anymore) and this pair was still working on other devices I decided to see if a toothpick may be helpful again. Sure enough another lint ball appeared when I pulled out the toothpick and the earbuds are working fine again.

Who would have figured that the most important tool in mobile phone maintenance would be a toothpick?



Comments to this post

Tags:
Comments Off on List Differences in Two Cell Ranges in Google Spreadsheet

List Differences in Two Cell Ranges in Google Spreadsheet

Another tip from my recent work in Google Spreadsheets.

I had two columns of data and was looking for a way to display items that appeared in one column that didn’t appear in the other. The combination of the FILTER and MATCH functions is how I accomplished this.

The FILTER function returns items from a source range that meets a specific criteria. The first argument in the FILTER function is the source range. The second argument (and further optional arguments) is the criteria. The example given by Google is as follows:

=FILTER(A2:B26, A2:A26 > 5, D2:D26 < 10)

In this example items from range A2:B26 will appear if their value in column A is greater than 5 and their value in column D is less than 10.

This was only part of my solution. I still needed to compare my two columns as the criteria of the FILTER function. I did this using the MATCH function. MATCH is very similar to FILTER. It returns the position in a range based on a criteria. For example if you have a list of the days of the week days (Sunday, Monday, Tuesday, etc.) and your criteria was "Wednesday" you end up with this:

=MATCH("Wednesday",I8:I16,0)

"Wednesday" is your criteria, A1:A7 is your range, 0 is your search type (exact match when range is unsorted). This will return 4 since Wednesday would be fourth in your list.

Throw in ISERROR to check whether MATCH is returning an error and you have the following:

=FILTER(A1:A7,ISERROR(MATCH(A1:A7,B1:B7,0)))

In this example columns A and B both include a list of the days of the week. If column B is missing a day (or more) this formula will return the missing day(s).

Pretty neat.



Comments to this post

Tags: , , ,
Comments Off on Access Data From Another Spreadsheet in Google Spreadsheets

Access Data From Another Spreadsheet in Google Spreadsheets

I’ve been working with Google Spreadsheets a bit lately and have learned a few tricks. One such trick was learned when I had to find a way to have data in one spreadsheet automatically update based on data that’s in another spreadsheet. This turned out to be quite easy once figured out. Here’s how to do it:

1 – Every spreadsheet has a key. This key can be found by looking at the “key=” parameter of the URL for the spreadsheet. Make a note of the key of the spreadsheet you want to capture data from (your source).
2 – Make a note of the cell range the data you need resides in.
3 – Go to the spreadsheet you want to include the data in (your target) and include the following formula at the location you want the source data to appear:
=IMPORTRANGE("abcd123abcd123", "sheet1!A1:C10")

In this example replace “abcd123abcd123” with the key of your source spreadsheet and “sheet1!A1:C10” with the cell range you want.



Comments to this post

Tags: , , ,