Tag: raspberry pi

  • The Linux GIS workstation

    Taking a break from the book fodder for a bit to talk about computers, my other love. This is kind of a long one and maybe a little nerdy. Maybe skip it if you’re not big into computers.

    For the last few years I’ve been practicing open source cartography as a little side business over at fernwoodmaps.com. It’s been fun but I’ve been trying to do it with what I had, rather than the appropriate ones for the job. That tool was primarily a Raspberry Pi 5, which powered the bulk of the GIS operation, and much of the vector editing. To be clear, I’m impressed the Pi5 worked for this at all. It’s very much not what it’s for, but it got the job done.

    My early experience trying to use a Pi 4 as a desktop was awful. A lot has changed with Raspberry Pi since then, and the Pi 5 hardware ended up being a perfectly capable machine to demonstrate to myself that GIS was something I was interested in. Also that I might be good enough at it to justify spending money on more suitable hardware. That more suitable hardware is a refurbished 2022 Lenovo ThinkPad T14 with 16 GB of RAM. I can expand to 48 with another stick of RAM if in a couple of years I’ve outgrown the ThinkPad but am not yet ready to shell out for premium hardware. (Support this habit! Buy a map!)

    A real computer is the right one for your task, and your budget

    Apple’s MacBook Neo laptop provoked some decent discourse about what a “real” computer is. Some with a vested interest in getting people to buy more expensive PCs, said it is really only for “content consumption” — not “mainstream notebook usage scenarios.” A fancy way of saying this is a toy. To these bozos, I point to my iBook G4 which in 2004, was among Apple’s lowest-end Macs.

    An iBook G4 plugged in on a desk. It has an Apple Mighty Mouse plugged in beside it and an iPod sitting on top of the case.
    Gotta love that date stamp I thought was really important when I was 18.

    Back then $1200 (>$2000 today) got you 512 MB of RAM, 40 GB of storage, and a 1.33 GHz G4.1 Did those low specs stop me from running Final Cut Pro, ProTools, and editing hours of audio and video with it? No! Did it slow me down? Of course! Did I maybe abuse that computer doing all that? Probably! But I was in college and couldn’t afford a $2500 PowerMac G5, or PowerBook G4.2 I certainly didn’t know if anything I did with it was enough of an interest to justify that price point. (Did I also love using the G5s in the lab, absolutely.)

    My philosophy has always been to buy the best computer I could afford for what I needed to do. To that end, if you need a basic Linux workstation to test out how comfortable you’ll be with it or learn a new hobby, a Raspberry Pi 500+ kit is pretty capable for regular desktop things. If you already have the keyboard, a Raspberry Pi 5 with active cooling is a good option, too. If you have an additional $300 – 400, go for something MacBook Neo range. According to a CPU comparison, the Gen 14 i5 is about the same performance as the MacBook Neo. I paid about $400 for the ThinkPad with twice as much RAM. If MacBook Neo is your price range but you want Linux, you have good options.

    These are the three factors that signaled I’d outgrown it as a daily workstation:

    1. Memory and performance
    2. QGIS support
    3. Portability

    Performance

    First, if the only monitor you’ve attempted to use your Raspberry Pi on is a “retina” or HiDPI display, try using a regular one! I’m confident it’ll immediately feel like a different computer. There’s simply not enough memory available to power that many pixels on the Pi (maybe on the 16GB model there is?). Next, go get an NVMe and convert your Pi to boot from it. You’ll be pleased! Anyway, performance was the biggest factor that led to the upgrade to a proper laptop.

    Last winter, I decided to take on the most ambitious map project I’ve done so far. It’s a detailed map of the Great Lakes and St. Lawrence River watersheds. I think it turned out pretty well but it involves styling five separate rasters (one for each lake), plus an XYZ tile basemap, and millions of vectors for all the lakes, streams, watershed boundaries, urban areas, etc.

    It brought the Pi to its knees. To load the entire map, I’d disable rendering, then uncheck all layers, rëenable rendering, then one-by-one, turn different layers back on. Detailed edits eventually led to long waits or all out crashes—lost work. I ended up moving the whole project to my work Mac to finish it.

    A detailed map of the great lakes and St. Lawrence river watersheds.
    Looks good, right? Go buy it!

    I don’t love using my work machine for personal projects. I’ll log into my personal email and small stuff like that to reference things while I’m at work, but I don’t like going the other way round. With that said, using an M3 MacBookPro immediately revealed the benefits I’d get with upgrading from the Pi: Twice as much memory, high power CPU with more cores, and dedicated graphics memory. It was like using the G5s in the media lab in college over my iBook.

    I learned a lot about how computers work in all of this, in particular how memory is shared and resourced across a system. Take the desktop environment, for example. Raspberry Pi OS ships with a lightweight Wayland desktop environment. It’s designed for low power machines like the Pi and consequently lacks many common features that mattered to me (screen locking, display management, etc.). I installed GNOME for a more full-featured desktop environment but it came at the expense of memory available to the system. That 8GB of memory is all the Pi has for everything. This laptop has a GPU with dedicated memory separate from the system memory.

    A desk with a monitor on an arm, a laptop on an arm-mounted stand, headphones hanging next to the laptop, and a keyboard and trackball mouse.
    Fast forward 22 years and this is the current setup. Yes, I still have the default background for Ubuntu 24.

    Again, all expected and intentional from a low power device like the Pi. It only uses 15W! I was legitimately impressed it managed as well as it did. For my Door County map, I used Affinity on my Mac for pre-production layout but the GIS work was entirely on the Pi. It’s a simpler map: One raster, a few vector layers, but still a big file to export and work with. I bet I’d spend a little less time waiting on rendering if I did it on the T14.

    QGIS Support

    The only way to install QGIS on a Raspberry Pi is with Flatpak, which is pretty neat. It bridges architecture support by compiling every application’s manifest in the Flathub build farm. It means QGIS doesn’t have to support ARM, they just have to tell Flatpak how to build it. I mostly understand it.

    The problem was I’d forget this every time there was a QGIS update. If it weren’t the only Flatpak app I ran, maybe I’d have remembered it sooner, but it was frustrating to think through and rule out all the different possibilities every few months. Plus, I never figured out how to run the long-term release, which, as I’m still learning, I prefer over the most cutting edge.

    The project has an official PPA for QGIS on Ubuntu (and Debian) but only for x86-64 processors. It’s much easier to install and keep updated on the long term release, and feels more predictable right now. It’s possible that running multiple package managers is just part of the Desktop Linux experience, but for now I’ll cross that bridge when I come to it.

    Portability

    The Pi is tiny. The footprint of a credit card, height of a business card, even with an NVME base and case. It’s still a desktop, though, so you can only use it where you have the keyboard, monitor, and mouse all set up. I’d get stuck in my office when I didn’t really need or want to be. I couldn’t bring my GIS projects on the road. I couldn’t go to my co-working space if I needed to without fully shutting down—and I better not forget the mini-HDMI cable. This laptop is, well, a laptop. It has better HiDPI support for when I’m at home, and a decent trackpad and display for when I’m not.

    If Raspberry Pi ever made a laptop, that’d be neat: A good device for many novice to advanced beginner users. If they could come in below the MacBook Neo, it could be a good option for K12 schools to issue to students and classrooms instead of Chromebooks.

    Why not a refurbed Macbook?

    I like Macs; I’ve been an Apple user my entire adult life. Their hardware is world class, but it’s difficult to find a capable M series MacBook with 16GB or more RAM and a 1TB disk on sale for less than $600, and I wasn’t ready to spend that kind of cash. I did not have a great experience with QGIS on an M1 MacBook Air the last time I tried. I could spend about $200 less on an upgrade-able machine if I went PC.

    Plus, I’m trying to do this open source thing as much as possible. The Fernwood Maps website is WordPress and WooCommerce. QGIS is open source. I try to use public domain or open source data sets where possible. I have an Affinity license and a Windows VM but I try to do as much finishing work in Inkscape as I can. I like knowing that I could switch back to Mac some day, but for now I want to try my hand with the FOSS cartography stack all the way down to the OS on my workstation. I also think it’d be good to foster PC skills in case I ever want or need to use ArcGIS some day.

    So far so good

    It’s kind of funny to be using a ThinkPad for the first time in more than two decades. It has a TrackPoint, my dad’s preferred laptop pointer. It’s made by Lenovo, not IBM, but otherwise looks and feels at home with, if considerably less chonky than, the 2002 ThinkPad T30 in my laptop museum (read: A shelf in my office).

    Setup was pretty easy, and the refurbishers did a good job. The first thing I did was swap the 256GB SSD built-in with the 1 TB drive I’d been using on the Pi. Then I installed Ubuntu off an SD Card reader, which was slick. A couple “Linuxy things” came up in the first couple of weeks, but nothing I couldn’t solve with a mix of Claude and the regular internet’s help. One example: The TouchPad would give out on suspend and it turns out it’s because I (intentionally) hadn’t installed the firmware updates.3 Other than that: Smooth sailing.

    I’ve loaded and edited the Great Lakes map project already. It’s still a huge project but my mission to spend less time waiting on and crashing QGIS was a success. Maybe I’ll upgrade the RAM if I ever make any money on this. Now I just have to figure out what’s next.

    Today, the pi is in home server mode. I already put it to work doing other things. It’s a media server, mostly, and on the tailnet so I can access it from anywhere.

    1. The 12″ version started at $999, the default price point for Apple until the Neo. ↩︎
    2. Bring back the late 2004 Powerbook G4’s heavenly keyboard, you cowards. ↩︎
    3. Supposedly some users had their second RAM slot give out on them with the latest T14 firmware. Hopefully I’m not one of them but only time will tell. ↩︎
  • Rescuing a Pi Zero

    I love my Pi Zero. It’s such a tidy micro-server to have in our house for random things. When we first got it, it was a pi-hole. We deployed it for the same purpose in the office we shared with our friend and neighbor. There, with a little display, it also helped our officemate debug network problems by displaying information without color. It’s so small and low, I powered it off the usb port on the back of the wireless router.

    Someone should time-travel back to 2003 and tell my younger self that not only is it possible to have a home server that’s on all the time, it’s also small enough to lose in a junk drawer.

    At some point, though, it stopped working reliably. I’d plug it in, and after a while it would crash mysteriously. I checked the logs and noticed it was kernel panicking, not hanging on any particular application or task. The panics would happen reliably when I ran apt upgrade but I couldn’t work out much more befond that.

    Last weekend, inspired by a friend’s Zero 2, I thought I’d try to figure it out again. I’ve learned a lot about Debian, SD cards, and how to optimize long running pis in the last year or so. Maybe I just didn’t know what to do in the past.

    It turns out the most important thing I had to do was overclock the CPU by a small amount. In /boot/firmware/config.txt I set over_voltage: 2, to give the CPU the ability to use 1.355V instead of the standard 1.35V. (vcgencmd suggests it’s actually 1.400 so ymmv, I guess.)

    I’m not sure why this worked, but it hasn’t panicked since.

    A few other things I did before I started programming the GPIO e-ink display:

    I linked to Chris Dzombak’s blog a few times above. There’s a lot more I could do to help this lil pi keep itself stable in the long term and I’ll probably keep tweaking based on his excellent Raspberry Pi series. Worth checking out before you burn through an SDXC card.

  • The end of the Summer of Desktop Linux

    My sabbatical draws to a close and with it my dependence on computers owned by me and me alone. Since Automattic is, with little exception, a Mac shop going back to work means this is probably the last post I’ll write from my Raspberry Pi for a while. It’s a bittersweet ending because, despite the frustrations of an under-resourced computer, it’s been a joy to use Linux as my main workstation for a while.

    Highlights

    I’ve been pleasantly surprised with how interoperable this computer is with the Apple ecosystem that governs the rest of my life. I managed to make this computer into an AirPlay receiver via ShairPort Sync so I could stream music and radio to the speakers hooked into the headphone jack. I didn’t look much into whether Apple Music’s web player would work on this browser because I’m certain I don’t have the RAM for it even if it does.

    I didn’t try going the other way: sharing from the Pi to an AirPlay device, mostly because I didn’t need to, but also because the more complex motions of AirPlay remain dependent on private APIs. It kinda stinks but I also don’t need things like wireless screen sharing from a desktop that can barely handle the display it’s plugged into.

    The same is true for 1Password.com, which is nearly at feature parity as a web app with it’s desktop counterpart. Some of the more advanced things like the SSH agent and browser extensions require the desktop app (maybe obviously?), but the web client came in quite handy on many occasions. I’m starting to think this world wide web thing might stick around.

    Fortunately, Apple’s iCloud services are pretty extensive and reliable on the web these days, so the occasional file I did need to transfer between devices could be uploaded to iCloud Drive from a web browser and immediately available on other devices.

    Finally, swapping SD cards around to run different computers on the RPI4 base was really nifty. I had to troubleshoot some of the other Pis in our house and each time but didn’t have SSH access. All I did was pull the card, pop the other computer’s card in this one and I had full access with the same monitor, keyboard, mouse and (relatively higher) system resources. Even on a very repairable computer, it’s rarely this easy to swap boot systems.

    Lowlights

    Lack of RAM is a major limiting factor on this device and has been since the start of this experiment. It is really hard to use and especially multitask even with just a web browser with only 1GB of memory. Chromium’s ability to unload the pages not in use helps a lot but is by no means a complete solution. Switching between tabs, loading new pages, all of it is very slow. Task manager reliably shows Chrome as the main offender.

    The raspberry pi OS task manager showing about 81% of system memory in use.
    Chrome also seems to spawn a lot of processes. I’m not enough of a computer scientist to understand why.

    Even with no pages loaded, Chromium and the system use about half the available memory, once I load an interactive page like the post editor for this blog, that jumps to 68% when I’m typing, and more if I’m typing a lot. With 1password.com loaded but in the background, or any additional tabs open, I’ll easily use more than 90% of available memory in an idle state. Facebook would basically crash the computer if a single video loaded (would be fine if you could choose when that happens). It reminds me a lot of what it was like to use web apps in 2007. None of these run well, but some companies have prioritized low resource consumption.

    Too many desktop applications assume you have 2GB of RAM, if not a lot more, in order to function at all. On a machine with only 1GB of RAM, you could maybe run one of these as a standalone single-purpose computer, but the combination of tools you’d need to be productive. Even open source CLI projects like WordPress’s new wp-env tool for local development have a constellation of requirements that add up to a lot more RAM than I have. It’s a bummer, but if I were doing that kind of work, it’d be worth investing in a higher powered machine anyway.

    Overall: Success

    If it weren’t for the performance issues, I could see myself using this machine as a daily driver. I like how it’s compact, transparent, and extensible. I enjoyed getting to know it and learning how it works. The good news is that Raspberry Pi have models up to 8GB so I could upgrade, if I ever find one in stock, and doing so involves nothing more than putting the SD card in a different computer. I might wait and see what the future has in store for the Pi 5, though.

    This might be the end of the summer of desktop Linux, but I’m not done with it yet.

  • Sabbatical prep

    I hit five years with Automattic on January 20th 2023 and with that milestone I became eligible for a special benefit: A sabbatical. It’s a bittersweet timing, a little, because we’re in the middle of an exciting growth opportunity for the public sector, and especially the federal marketplace. Still, I’m extremely excited for June 19th when I get to turn off my work computer, delete Slack and the WordPress.com apps from my phone and log out until September. This will be the last time we have an entire summer off together as a family and we’re not going sleep on that opportunity.

    One thing we’ve been asked a lot is what our plans are. We do indeed have plans, and we’ll blog about them over on the family blog. We flee the country on June 19th for a long overdue international trip with Laszlo and then will spend the remaining time enjoying our summer, doing local travel, and likely visiting friends and family in Minnesota.

    In an effort to fully separate myself from work, and not be tempted to check up on people and see how things are going, I’m not only turning my work computers off, but storing them away. I have an iMac that sits on my desk, it’ll go back in its box. My laptop I plan to charge to 50% and store in the closet. The only things I’ll log into are the government issued machines,to ensure I don’t get permanently locked out of them.

    But I’ve relied heavily on my work computer for personal use the last few years. Certain banking tasks, blogging, the occasional side project, all remain much easier to do on a laptop or desktop with a full featured GUI than attempting to tap things and mash my fingers onto small keys or a touchscreen keyboard.

    Year of the Linux Desktop

    It’s a bit of an experiment, I’ll admit, but my plan is to use a Raspberry Pi for the work better suited to a full computer. I have a few of them on hand including a Raspberry Pi 4B with 1GB of RAM. It’s a bit low-resourced even for a Pi, but the entire thing: cables, 128GB storage, case, HMDI cable, even a little e-ink HAT cost me probably around $100 total and has been in service for the last few years already. So if it doesn’t work out, it can go back to being a Pi-hole, or a media server, or whatever I think of for my next pi project. I’m committed to giving it a shot, though, as a primary desktop workstation. A “daily driver” if you will.

    Pi OS Lite to full desktop

    When I originally put this Pi in service, I used it for running pi-hole, Homebridge, and briefly, Home Assistant. I didn’t have a screen dedicated to it, nor did I need one. Everything I needed to do with it could be done over SSH with auto-login of the pi user. I installed Raspberry Pi OS lite, and since it would always be plugged in to a router, I actually disabled the WiFi radio entirely. The first stage in my journey to a Linux desktop was to convert the OS to full Raspberry Pi OS by installing a GUI and then re-enabling the WiFi and bluetooth radios. It was relatively easy to do and there are good guides for the former online.

    I largely followed the advice from Raspberry Pi Tips for how to install a GUI and configure the Pi to boot from it. I’ve dabbled with Ubuntu in virtual machines here and there but am new enough to desktop Linux to not have a preference when it came to GUI so I went with PIXEL, which is a pared-down and pre-configured version of the already-lightweight LXDE (which I have some experience with). Once I had it all installed and working, I set out to figure out if I could make it work for me.

    A capable browser: Vivaldi

    I haven’t installed a theme yet or added many applications, because at 1GB of memory, this machine is pretty resource constrained as it is. One choice I did make was for a web browser. Raspberry Pi OS comes with Firefox ESR, Dillo, and a basic WebKit browser pre-installed. I also installed Chromium and Vivaldi to test their performance on the Pi. I found all of these to be limited, but all but Vivaldi were unable to reliably run an essential add-on: 1Password. So, for at least the months of my sabbatical when I’m at home, I’ll be a Vivaldi user. So far, I like it but I don’t know if I’ll give up Firefox as my primary for personal use on other platforms anytime soon.

    A decent keyboard

    All the keyboards I have lying around right now are either in use by someone else, or they’re old, big, or broken thanks to cats pushing them off shelves. I have a Keychron K2 that I love to use, so I bought another one just for use with this computer. This will help make the Pi much easier to use, and more pleasing on the fingertips.

    Issues to work through

    Adjusting to desktop Linux is far easier in 2023 than the last time I tried it in, probably, 2008. Pretty much everything works out of the box including printing to the same Brother Printer Everybody Else Has and connecting arbitrary peripherals like an Apple mouse and Logitech keyboard. Still, there’s was some real work to do to get things as I need them; using Raspberry Pi OS for everyday things is an exercise in patience. But the first time I tried to install Ubuntu on my 2007 MacBook, for example, I had to program in support for two finger scrolling on the built in trackpad, comparatively the Pi Just Works.

    One example of this is automatic screen locking and screensavers. I had to edit a configuration file to get a “Lock” item in the main menu bar. I had to install xscreensaver and then configure it to lock the screen after a certain period of time. It’s possible if I hadn’t installed “Lite” OS from the start, these would have been built in, I’m not sure. Regardless, juggling the difference between screen “blanking” “saving” and “locking” was not entirely intuitive and required some manual work.

    Another limitation I’ll have to contend with is the limited RAM. This machine freezes up quickly under intensive load from complex webpages. I may be able to “solve” this by using Dillo for most things and only using Vivaldi when I need to log in or do something highly interactive. Regardless, I’ll have to be really intentional about limiting my open tabs and apps to keep memory usage under 1GB. If this all works out, I may decide to purchase an 8GB version of the same Pi which should be plenty.

    There are a lot of other little things I need to figure out too. Like, how to reliably set display resolution. I have a fairly large screen and while I can make good use of it, the settings don’t always persist between reboots, and a separate application I used to control it seems to have vanished, possibly accidentally. A funny thing is that cursor size doesn’t seem to scale with the rest of the display, so I have a giant mouse pointer relative to the buttons and text I’m selecting. For now it’s equal parts fun and frustrating. I hope it trends more toward equal parts fun and enjoyable.

    Mobile

    With all my laptops stashed away, I only have the iPad I’m using to write this post available for mobile use. Normally, for writing blog posts, I’d use the Jetpack app on my iPad, but were I to do that during my sabbatical, I’d have to find a way to ignore or disable notifications from work that push through that app. I’m not sure that’s possible, so instead I plan to log in with the web browser and saved my sites as progressive web apps. So far, so good on that front.

    I definitely have some work to figure out. Since I self host this site, I have relied pretty heavily on Jetpack for mobile editing and haven’t really tried to upload images or work with content from a tablet. I’m getting a strange error when I try to upload from the Photos Library, and I’m not sure what that’s about. The wp-admin interface is still geared more toward desktop use than the tablet form factor, but so far I’m pleased with how it’s going.

    Beyond blogging there really isn’t much I need to change in order to adapt to my iPad over a laptop. I already prefer the smaller and more portable screen compared to a laptop, and the relatively simple interface. The Magic Keyboard Folio makes it pretty easy to type and navigate webpages on an iPad wherever I am. Once I can get these details sorted out, I should be set.

    What could go wrong?

    Not much really. The down side of all this might be that I just don’t really use a computer much while I’m on sabbatical. I can’t say that’d really be a problem. In fact, it’s kinda the point of going on sabbatical isn’t it? I have a few projects I hope to take on but if I don’t get to them, so what? As long as I can blog while I travel, no big deal.

  • A small act of accessibility

    I keep a small office in a building in my neighborhood. It works out nicely that my employer defrays the cost a bit because unlike apparently everybody else with a remote job I can’t seem to get any work done while sharing a small home office with another person and with wild animals pets, and a child running around. So I have a small office, but one that’s big enough to share. When my neighbor, who is apparently the only other person with this problem, asked if he could use some of the space, I said yes.

    The way I usually tell the internet is for sure out is by looking at my router. If the little globe with a line going around it LED is amber, the incoming signal is out. So I explained all of that to him and learned he is colorblind and wouldn’t have known the light was amber if I hadn’t told him.

    This is a good real-world example of why it’s important to avoid designing with color as the only way information is conveyed. Our internet connection comes from a centrally managed switch elsewhere in the building. Even if we could access it, the indicators there are also green and amber.

    To help my officemate, I used a raspberry pi we keep in the office. On a normal day, it is our pi-hole but I bought this Adafruit Mini Pitft HAT for it a while back. It runs a python script that shows some basic information. If you push one of the buttons you can disable the Pi-hole. It’s similar to Adafruit’s basic tutorial.

    Until today, I struggled to think of how to make it really useful. Then, I had the idea to use it to check if the Pi can reach the internet. This way, my officemate can just check the pi, where it’s written in black and white, to see if the network is down for everybody or just him.

    import socket
    …
    def isConnected():
    try:
      socket.create_connection(("1.1.1.1", "53"))
      return True
    except OSError:
      return False
    …
    connected = isConnected()
    if connected:
          draw.text((x, y), "Internet is connected", font=font, fill="#FFFFFF")
    else:
          draw.text((x, y), "Internet is disconnected", font=font,fill="#FFFFFF")

    Pretty simple, took me about five minutes.

    Now I’m thinking about other ways we could use it to send messages to each other without having to both be in the room. Maybe a little WordPress site with P2 on it. If we notice the internet is down, something broke, or the building management sent a message, we can put up a post that says so and when we notified the support desk. That could be useful. Since it’s running locally we wouldn’t need the actual internet to access it, which would be handy.

    Whatever I do has to be pretty lightweight since the Pi Zero has limited resources.