The Power of Raspberry Pi–the new resurrection

beryl and RPI On Lap Monitor
For background and to start this story at the beginning, go to this post. To go to the previous post in this series, go here. The Raspberry Pi (RPI) on Schooner Mahdee has continued to work well in its primary task–weather and boat data logging to hard drive and serving and displaying that data plus tides and currents as well as performing alarms for anchor position and wind speeds.

The RPI was clearly not good at interactive GUI applications except simple email and very basic web surfing. It was also not working satisfactorily as an Internet gateway and a Wifi access point. The harder we pushed the RPI, the more often it crashed and shutdown. Then the RPI-2 was released with 4-CPU cores and 1G RAM–four times the cores and twice the memory of the RPI–and I thought maybe now I can get everything I want.

The new RPI-2 is designed to use a more advanced ARM architecture which meant that a standard Linux distribution could be used rather than the Raspbian distribution required for the RPI. I like Debian, so I installed Jessie on our new RPI-2. The RPI-2 has a different setup of IO-ports so our woody Ti-Bow case was not usable. That gave me an excuse to keep the RPI in its case and temporarily mount the RPI-2 next to it without a case.

During the extended transition of applications and functionality from the RPI to the RPI-2, I connected the two together with a simple Ethernet cable–no hub needed. The 50W regulated 5V DC power supply we have on Mahdee has more than enough capacity to run both Pi’s, the HDMI monitor, Passport hard drive, along with various other USB accessories and device charging requirements. I describe installing Debian Jessie and setting up the RPI-2 to run the chart plotter OpenCPN here. That article also includes a link to download an installable copy of OpenCPN that I created.

Because we are sometimes without any Internet access, I try to anticipate and install applications before they are needed and while we have good Internet access. Whereas the RPI is well equipped with a 16G SD card, the Sandisk Extreme SD card we purchased for the RPI-2 has a capacity of 64G. More than 6000 packages are now installed on the RPI-2 using over 80 percent of those 64G. SD storage is primarily programs and their documentation because most data is saved on the external Passport USB hard drive. So we have lots and lots of programs. More programs than may ever be used.

There is some stuff (actually a lot) on the SD card that really isn’t needed there. Given our experience driving an SD card to its premature death by writing gigs and gigs of weather data to it, we are sensitive to this. Further, an SD Card with more free space will distribute writes so as to extend its life; a nearly full SD Card can not do this and is more likely to fail prematurely. Since the Passport USB hard drive is always connected (using an entry in /etc/fstab), we can move a few things there. My criteria is to only move things that are not needed to boot the RPI-2 and preferably things that have lots of writes; mostly static files that are primarily read can be left on the SD Card.

I create a directory on the Passport drive such as rpi2_rootdir and in that directory, I create the subdirectory rpi2_rootdir/var/cache. Then I move /var/cache/apt into that subdirectory and create a link to the new location in its place. The only time I really need the apt cache is when updating and upgrading and that subdirectory ends up with lots of data and writes that I would rather have on the Passport. Another file with lots of activity is /var/swap which is used by the package dphys-swap. That file is a swap file for when memory is scarce and therefore (unfortunately) can be heavily used in my setup. One can also move the /var/log directory to the Passport once everything is stable. Further, I create a subdirectory in my user home directory which links to a directory on the Passport drive and I use that directory (on the Passport) for most of my user data–e.g. my email folder, downloads folder, music folder, application data, etc.. With those changes, my usage of the SD card is now less than 50 percent–including a complete copy of NOAA charts on the SD Card as a backup.

After email (using Mutt) and general writing using VI/VIM, my most used interactive application is a web browser. In the original RPI, I often tried to use Midori, but it’s development fell behind and it failed to render a lot of sites. Net Surf and some other light browsers don’t work well for me. The new official light browser for the Pi is the Epiphany Browser. I have not been impressed by that browser either. Google Chrome is not available from the Debian ARM repository and I have not found an easy way to get it. My favorite browser, therefore, is Iceweasel (the Debian fork of Firefox). I install the Vimperator add-on which makes the browser usable without a mouse–you just need the keyboard–and then my web browser works much like my VI editor which provides a user interface consistency that is very nice. But, Iceweasel/Firefox is a resource hog! Fortunately, there are several configuration changes that can greatly improve the usability of Iceweasel/Firefox on a resource-limited device like the RPI or RPI-2. I use the modifications described here. Also, I add the following line to my .profile:

export set MOZ_DISABLE_IMAGE_OPTIMIZE=1

Before these changes, Iceweasel would slow down the RPI-2 the more it was used until the RPI-2 was virtually unresponsive. With the changes the RPI-2 works great with Iceweasel. I do try to limit the number of open tabs in Iceweasel, but I currently have 25 tabs, along with about a dozen terminal windows, my QT Weather program, XTide and can even use LibreOffice and have the interface feel responsive! All in all, a very nice computer experience.

The Debian Jessie install went great and the only real hitch for me is not limited to the Raspberry Pi. Jessie uses the new SystemD and that breaks a lot of UDev scripts I wrote to automatically start services such as the Weather data logger when the Airmar USB cord is plugged in, and the GPS position and time servers when the USB puck is plugged in, and the Internet gateway when the Palm is tethered. Jessie has packaged some automatic scripts which work with common new devices, but not our GPS, Palm, or Airmar. For the Airmar, it turns out that my automatic testing and recovery scripts will get the data logging started. The problems with my other old devices may not affect those with newer devices, but my solution for them will be covered in the next post along with some new stuff.

The Power of Raspberry Pi: over reaching and hitting the wall

For background, see the previous post here. At this point, the Raspberry Pi (RPI) has proven itself aboard Schooner Mahdee by reliably logging data from our Airmar weather station plus other boat data and displaying that data on an HDMI monitor, as well as monitoring that data and sounding alarms as required. We built in the capability for more than one computer to read the Airmar weather/boat data from the RPI network port at the same time. To realize that potential, we needed a Wifi access point. A USB Wifi dongle, supporting the access point protocol, with the right software (in our case HostAPD) turned the RPI into an access point for all Mahdee users. A good access point provides some basic network services that were set up on the RPI–such as IP address assignment DHCP server–and is a domain name server (we used Bind9 server) for all the Wifi-connected computers aboard the boat.

Raspberry Pi and Cat

Further adding to the roles for the RPI, I wanted to be able to read email without turning on any other computer, so we needed to set up internet access on the RPI. We set up the RPI to use either a Sprint phone with a data tethering plan using PPP or our Verizon Wifi hotspot using a second USB Wifi dongle. Since Brenda’s Windows 8 machine can’t tether directly to the Sprint phone, we decided to make the RPI Mahdee’s internet gateway that can be switched between either Sprint or Verizon. That also meant a better firewall setup for the RPI.

The RPI doesn’t have a hardware clock (by design it would rely on an internet connection to set the time on boot), so when we rebooted the RPI, sans-internet, in the middle of nowhere in Alaska, the data logger had the wrong time stamps. To fix that, we setup a USB puck GPS as a time source for the RPI. This meant also running a GPS position server on the RPI which is then available on a network port of the RPI for other computers aboard Mahdee. The fast high resolution GPS data was also setup to be used by a Python anchor watch and position alarm which I’d previously written for the Nokia N810. The sound system on the RPI is not very good nor very loud even with our USB powered amplified speakers.  For the alarms we setup a piezo-electric buzzer which is energized by a RPI GPIO port so that we can hear alarms anywhere aboard the boat. The RPI also uses GPS time stamps to provide a network time basis for other computers aboard.

With the 2TB Passport hard drive attached to the RPI, it only made sense to put a copy of our public file archive on it and thereby make it available to us 24-7. The public file archive includes repair manuals in PDF form for most boat systems (nice to have in an emergency), all of our photos as well as digital books and magazines (nice for passage entertainment). This nicety meant putting PDF and e-book readers on the RPI. Then, to enable access to those files from Windows computers, we setup a Samba server which also requires a network time server. Fortunately we already had the GPS-based network time server on the RPI.

To enable us to read our email when there is no internet connection available, we setup the RPI with OfflineIMAP to sync mail from our main email server (an off-boat/shore-based virtual private server) whenever we have internet access. I read email using Mutt which can run in a terminal on the RPI. Brenda likes to access email using SquirrelMail webmail via her computer’s web browser, so we added an Apache2 web server to the RPI along with Squirrel Mail and an IMAP server.

In among the public archive data is our music collection, so we setup RPI as a network music player. On those long passages, we thought it would be nice to listen to music, but this is where things start to break down. The poor, now very overloaded, RPI just couldn’t make the music sound even decent. I also setup my Bluetooth stereo headset on RPI, but that was even worse than listening to broken up music through the speakers.

Many boaters want their RPI to run a navigation program like OpenCPN. I had managed to compile a version of OpenCPN on our first RPI, but running OpenCPN required all the resources of the RPI and I was not willing to forego all the other important roles our RPI was needed for–simply to use OpenCPN as a backup chart plotter.  Our real chart plotter is used to display radar and chart data including charts for other countries without free official charts (like Canada). Not needing to run OpenCPN helped a little with our overloaded RPI situation.

From the RPI GUI interface, I found web browsing to be very slow and unproductive. I could get email and read it using Mutt just fine, but there was other trouble lurking. Brenda informed me that basic web access from her computer through the RPI Wifi access point was way too slow. I tried it using my main computer and had trouble too. I had had hopes–fantasies perhaps–that RPI would also run a contact and calendar web service. Most people would just use Google for this, but we are often not near internet access and besides, who really wants to trust the big guys with all of your sensitive contacts and scheduling. But, it was not to be–at least not yet.  Stay tuned for the next installment in this series of posts about the RPI and how we turned the corner towards success.

More Tips From The Ship’s Cat

1

Beryl has decided to share a few more secrets of the highly successful ship’s cat. The next thing she’d like to share is the importance of charts and navigation for the ship’s cat. Command and control is all about keeping on top of the available information. In the case of a boat, that means sitting on top of the chart table when it is closed up with charts inside. There are two approaches. Above, we have the “use-the-table-to-stand-a-lookout-kitty” approach and below, we have the “I’m the cat in charge of the charts and you’re not opening this table until I say so.” approach. Knowing which approach to use is what sets the highly successful ship’s cat apart from the rest. This just can’t be taught; you’ve got to figure it out on your own.

3

When the chart table is open, sitting on key charts or tide tables is a really important thing to do. Don’t just go straight to the largest most obvious looking chart. Watch the human watch stander’s eyes. Make sure that you’re sitting on the thing they’re most interested in looking at. In the photo below, a lesser experienced ship’s cat might have sat on the chart book when the really important bit was the atlas and tide tables next to it.

2

The ship’s cat must be diligent and stand this post as much as possible. Day and night. When a human is standing anchor watch, they may well be doing planning at the chart table. Here, the experienced ship’s cat manages to sit on top of the tourist attraction map while blocking view of the wind speeds on the computer instrument. Since high winds were what was keeping the human watch stander up all night, this is quite an important success for the ship’s cat to stay in-the-way and thus in-control of all the information.

4

And, if the charts happen to move from the table to say…the seat beyond the table? This can happen when the humans begin to think you’re just interested in the chart table itself. Here they’ve moved the chart and left the table completely free for the ship’s cat. Well, move! and sit on top of the charts on the seat! Location is key and it is good to see the human crew realizing that you, as ship’s cat, deserve a high level command-and-control position! We always have to remember though that information is even more key than location. The human crew needs to know that you, the ship’s cat, are on top of all the pertinent information at all times!

Beryl will have more tips for you at a later date. In the interim, practice what you’ve learned.

5

Google Analytics Alternative