Menu

Category Archives: Music

SongNet: Building a Wireless Private LAN with a Raspberry Pi and a pocket router

By Gene Wilburn

Overview

There are times when you meet with a group and want to share documents in common, but your meeting place doesn’t have WiFi Internet access. It could be an informal classroom situation, a regular meetup group, or, as in my case, two music-jam/singing groups.

In one of my groups we use Dropbox for sharing electronic versions of lyric and chord sheets. In the other we use Google Drive. These work well enough when there is Internet access, but often the places we meet to set up and play don’t have WiFi available.

Dropbox and Google Drive also have two disadvantages: every time a new member joins the group, we have to set them up with Dropbox or Google Drive and Google Docs apps for sharing. Even worse is helping them make local copies of the lyric sheets on their tablets for offline access.

This was technically challenging for some members, not to mention that it requires each member to personally update their local storage regularly. In order to create a more user-friendly experience I put together a solution that I’ve dubbed SongNet.

It occurred to me, as I’m certain it must have occurred to many others, that a nifty solution would be to create a small private wireless LAN, or Intranet, that could be set up in the meetup venue room, creating a private hotspot that could be accessed by any device that members preferred, whether it was a smartphone, tablet computer, or laptop. The only required app is a web browser.

Equipment Needed

The gear needed to set up a private local wireless LAN has been around for some time and you might even have some of this in your parts bin.

A router that also serves DCHP addresses

A Raspberry Pi computer or equivalent

I focused on small size and portability by selecting the following three pieces of hardware:

Raspberry Pi Zero W Linux computer

TP-Link TL-WR802N Wireless N300 Travel Router

High-performance 32GB MicroSD card

Any Raspberry Pi model with a built-in or external USB WiFi adapter would work. I acquired the TP-Link travel router from Amazon for around $35 Canadian. Because the MicroSD card holds the operating system, the web server, and the web contents, I wanted one with plenty of storage and one that is as fast as possible. I selected a Samsung EVO Select 32GB microSDHC UHS-I U1 Memory Card with Adapter from Amazon for around $12 Canadian.

Setting up Raspberry Pi

The first order of business with the new MicroSD card is to set it up so it can boot the Raspberry Pi. Using the SD adapter that comes with the MicroSD card, put the card into an ordinary SD slot of a Windows, Macintosh, or Linux computer download NOOBS and add the NOOBS files to the MicroSD card, following these instructions and the ones that come with the download.

This done, remove the MicroSD card from the adapter and insert it into the Raspberry Pi and boot it, connected to a monitor, external keyboard, and mouse. When it boots, choose to install which version of Raspbian you prefer. I selected Raspbian (not Raspbian Complete or Raspbian Minimal). When that’s done, reboot the Raspberry Pi and follow the prompts for resetting the password to one of your choice and selecting an active WiFi network. More prompts will follow for updating the files. This takes awhile.

The Raspberry Pi Zero has so little RAM (512MB) it strains to run the graphical desktop environment and the GUI is a significant drain on system resources, so we want to eliminate it from regular use once we’re set up. We also want to activate the SSH server in order to log into the Raspberry Pi when it’s “headless” — that is, unattached to an external monitor or keyboard.

To so this, open a Terminal application and type the following:

$ sudo raspi-config

This brings up an easy-to-follow, character-based menu.

Select 3 Boot Options and press Enter.

Next Select B1 Desktop / CLI and press Enter.

Then select B2 Console Autologin hit the TAB key and press OK.

What this does is deactivate the GUI desktop environment from loading automatically, presenting you instead with a console screen with user pi already logged in. Should you need to boot up the GUI for any reason, when you’re attached to an external monitor, type the following at the Command-Line prompt:

$ startx

The next step is to activate the Raspberry Pi’s SSH server so you can log in from other machines using an SSH client:

Put the cursor line on P2 SSH then tab to Select and press Enter.

On the next screen tab the cursor to “Yes” and press Enter.

Setting up the web server

Next, in a Terminal window or at the console, type the following commands to set up the directories to prepare for installing the web server.

Because the Raspberry Pi Zero W is a minimalist Linux computer, I elected not to use the fully-featured Apache2 web server. Instead I opted for the simpler Webfs, a lightweight web server that is more than sufficient for serving static pages such as song lyrics.

To install webfs on the Raspberry Pi, type the following commands in a Terminal or at the Console and follow the prompts:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install webfs

In order to add content, we need to know the IP address of the Raspberry Pi. To find this out, type the following:

$ ifconfig

And look at the IP address for wlan0, the WiFi adapter. The IP address is the set of numbers just to the right of inet, in this case 10.0.0.10.

We can first test this by opening a Terminal on a Macintosh, Linux, or Windows Subsystem for Linux (WSL2) computer and typing:

$ ssh -l pi 10.0.0.10

or whatever your IP address is for the Raspberry Pi. Answer yes to accept the security credentials and if all is well you should now be logged into the RPi.

To populate the Raspberry Pi’s web site, we turn to another command-line utility called rsync. Go to the directory where your lyric sheets are stored on your Mac or PC and type the following in a Terminal window:

You should see an alphabetical listing of your song sheets. Webfs by default allows directory listing, which, if you don’t mind scrolling, may be all that’s needed for your site. The web listing will look something like this and you simply scroll and click on the song you want to see:

If you know some HTML and want to create your own index.html page for the site, log into the Raspberry Pi and type the following:

$ sudo nano /etc/webfsd.conf

Go to the line that reads

web_index=""

And change it to

web_index="index.html"

Because Webfs defaults to port 8000, it’s also preferable to set the port to the standard 80. This too is located in the webfsd.conf file. Go to the line that reads

web_port=""

And change it to

web_port="80"

Save the changes and reboot.

$ sudo shutdown -r now

Because my groups have accumulated a very large number of files, I wrote a Perl script called buildIndex.pl that pretties this up by putting an Alphabet Selector at the top of the lyrics page and Anchors within the listing for quicker access. It also looks nice.

Setting Up the Router

Following the instructions that come with your router, log into the router using a browser. The first thing to do is to set the IP address of the LAN (Local Area Network). Choose a network IP range that is different from the one you have at home to assign what is called a “non-routable IP” range, which is a set of numbers set aside for LANs that are not connected directly to the Internet. To make typing the addresses easy, I set my router to a 10.0.0.0 network, subnet 255.255.0.0.

It’s important that the Raspberry Pi have a fixed IP address or the system won’t work. You can do this in one of two ways. One is to use the RPi’s graphical interface to log onto the portable router hotspot and follow the menus to manually assign a fixed, or static, IP address. Another way to do this is, if your router permits it, is to put the MAC address of the Raspberry Pi’s WiFi adapter in the router itself and have it automatically assigned by the router:

Users of SongNet need to type this IP address into their browsers to access the songs, so I chose to assign the address 10.0.0.10 for ease of entry.

DHCP

One of the critical functions of the router is that of a DHCP server that serves dynamic IP addresses to the users of the network. When they log into SongNet they get a 10.0.0.X address that connects them to the system. This is handled in the router’s DHCP section where you set aside the range of IP addresses that are available. In this case the addresses from 10.0.0.100-199 (100 addresses) have been made available.

Test Out the System

Now that it’s all put together, it’s time for a test. Disconnect the travel router from the Internet by removing its ethernet cable, disconnect the Raspberry Pi from its external monitor and keyboard, and put the router and RPi together in a room and plug them in.

At this point it’s necessary to use your tablet or computer’s WiFi setting to join SongNet. I assigned the password singalong for joining SongNet.

Now open a browser and enter:

http://10.0.0.10

This should show you (and everyone logged in) your songs and allow you to select them for display.

Finally, before you unplug the local WiFi network to carry it or put it away, you should shut down the Raspberry Pi properly. To do this SSH into the Pi and type the following:

$ sudo shutdown -h now

Give it a minute to finish closing all its files then it’s ready to tote to the next gig.

A Musical Interlude

By Gene Wilburn

I once described myself as “a loner with friends” — an introvert with broadband connectivity. Through Internet forums and special-interest groups, some of the friends I’ve made have been local enough to meet in person. Nowhere has this been more evident than on the Rangefinder Forum. As we discussed rangefinder cameras and film shooting (frequently trading and buying and selling cameras and lenses to each other), we revelled in the glorious sunset of the film-photography era. As more people began to embrace digital, used film cameras got cheaper and cheaper and even I got to experience the beauty and joy of shooting with a Leica M2 with a Hexanon 50/2, and a Leica CL with Summicron 40/2, not to mention a fine bevy of Bessas.

Some of the members of RFF, as the forum is known, began scheduling local meetings of rangefinder enthusiasts. I think the first was in San Francisco, perhaps New York. Not long after, a Toronto meetup took place, and extended to several subsequent meetups as we got to know one another. We found we had more than just cameras in common, and we developed a network of friends around the city that is still thriving.

One of the people I met this way was my friend Guy Steacy, a US draft dodger from San Francisco who came to Canada a short while before I did. We’re about the same age, both tall and white-haired with Swedish ancestry, both with degrees in English, and we were born across the Bay from each other: he in SF, me in Richmond. We both emerged from the era of Flower Power and shared similar tastes in music.

Guy has a good sound system and a discerning collection of LP and CD recordings, and over the past couple of years we’ve begun having meetings of what we call the Bay-Area Boys Listening Society. On a recent Saturday Guy invited me over for some listening and I was delighted to accept.

These interludes are special for me, because I tend to be a hermit and don’t go out often, except for walks to the harbour. Special not just for the music and amiable conversations, which are always a pleasure, but also for the trip into Toronto then the long trip to the east end via the Queen streetcar. I’ve always liked being in Toronto — all my jobs were in the city — and I especially like seeing the parts that are less upscale than the Bay-Bloor area. Another friend of mine, Stan Smith, who was attending the University of Toronto at the same time I was, went back home to Nelson, BC, one time, for Christmas. When he got back he said he just stood on the corner of Yonge and Bloor, “getting off on the traffic.” Some people love cities. I’m one of them, and I’m a boy at heart when it comes to streetcar rides.

Walking up from Union Station to Queen and Yonge, I got on board the 501 to Neville Park and began my journey east sitting in a single window seat where I could gaze out and take some photos. From there Toronto began to reveal itself. The rusty, abstract statue on Victoria St., St. Michaels Hospital, Henrys camera store, Vistek camera store, the armoury, mannequins on the sidewalk, the bridge over the Don Valley, the Riverdale neighbourhood, the Leslieville neighbourhood. Pedestrians bundled up against the cold winter wind, a thin young Asian woman who began singing aloud as her stop approached and continued to sing as she stepped down to the street. Passengers boarding, most of them nodding or saying hi to the driver. Faces that looked lived in.

We passed pubs, convenience stores, meat shops, tatoo parlours, head shops, art design studios, Indian restaurants, coffee shops, cheese shops, more convenience stores, parkettes, a shop that sells whey products, and a gas station. Streetcars passed us headed the other way, filling with passengers even on a Saturday. The 501 line is said to be the longest streetcar ride in North America. Starting at Long Branch, in the far west end of Toronto, you can ride it all the way to the Beach area in the east end, or vice versa. It carries passengers of all ancestral nationalities, many of them conversing in languages other than English or French. All now Canadian, not in the American “melting pot” way, but in the Canadian “cultural mosaic” way.

I got off at my stop and walked the rest of the way to Guy’s place along a narrow, tree-lined street, each house a little different from its neighbour. Some old, some renovated, some newly replaced — most of them two storeys on narrow, deep lots. Cars, mostly compact models, parked on the street. An older neighbourhood, getting more than a whiff of upscaling in the hot Toronto real-estate market.

Guy greeted me at the door, made us a pot of coffee, and we settled in for an afternoon of listening, at significantly loud volume. We both have eclectic tastes, so we started with some Grateful Dead standards, then followed the Dead on an experimental journey through “Playin’ in the Band” which probed the edges of rock music. From there we cut over to Art Pepper and grooved to some “California Jazz.” Since we both like music that is a little unusual, we finished off with the Diga Rhythm Band, a band that included Mickey Hart of the Grateful Dead. An excellent afternoon of music, conversation ranging from Old English to current politics, and the consumption of many cups of coffee.

Then the reverse trip home, streetcar to city centre as dusk fell over the city and the lights of the city switched on. Toronto — beautiful in the twilight. Back to Union Station and the GO-train ride home where Marion greeted me with a kiss and a bowl of hot veggie chili.