Link Dump – 2017/10/20

 

grasshopper

I bought the new Raspberry Pi Zero W along with the official Raspberry Pi Zero case. It’s really nice not having to worry about a wireless adapter. The addition brings my Pi family up to 7, which of course means it’s time for the letter G. Not a lot of pies starting with G. I ended up going with grasshopper pie, which is based off the popular drink and happens to be the first drink I ever made with my Mom. We always used to make the ice cream variation during the holidays, which is effectively a mint milkshake.

Blog in a Box Paparazzi

wapi-512Happy Pi Day! I figured I better post something Raspberry Pi related today…

This weekend I played around with Blog in a Box which was recently released by our Tinker team at Automattic.

A quick and easy way of putting WordPress onto a Raspberry Pi.

BIAB ships with modules to use the Raspberry Pi camera and SenseHAT. I hadn’t used my Pi camera yet and had a fun idea to hack around with.

blog-in-a-box-ssh

The camera module allows you to take a photo on a schedule by setting a period of minutes, hours, or days between each photo. I wanted to have a little more fun, so I wired some other electronics up to a Raspberry Pi Zero and wrote a little Python program.

The first electronic element was a simple button. Press it and a picture is taken. Next up was a photocell (light sensor). When the room quickly changes from dark to light, it’ll take a picture. Since the Pi doesn’t have analog inputs, I went with a neat technique of measuring the sensor as a resistor used to ‘fill up’ a capacitor. The last element was an ultrasonic sensor I haven’t used yet either. It measures the distance to an object in front of it, so I’m kind of using it as a motion detector. Walk in front of the sensor and a picture is snapped. Due to mismatched voltages on the PI’s GPIO and the output signal of the rangefinder, I had to use some resistors to create a voltage divider circuit.

To create visual feedback I wired up an LED for each of these 3 components. When one of the components triggers a photo, the associated LED lights up until the process is complete.

I named it Blog in a Box Paparazzi. Of course the code and wiring info are available on GitHub. Should be easy to adjust if you have other sensors, buttons, switches, or whatever you want to trigger photos. Let me know if you try something different.

Pi Tips

I stuffed myself on Raspberry Pi this weekend, making great progress on my Pi 3 project, getting to a usable basic v1. I’ll share more details on this after Thanksgiving. I also decided to rebuild my Pi Zero Homebridge server by installing Raspbian Jessie Lite (previously installed Raspbian via NOOBS) since it’s a headless system. It’s always fun to mess around with linux, though I couldn’t handle it as a full-time operating system.

While it’s fresh in my mind, here are some things that either tripped me up in the past or I found over the weekend.

  1. If you hide your Wi-Fi network, after you install Raspbian you’ll be scratching your head wondering how to connect. There is no UI for it and you might not even be setting up your Pi to launch into a GUI. Might as well dig into the command line right away by editing a couple of files.
  2. Monitor configurations are a pain in the ass. For the longest time I thought the 7″ display was a piece of shit because it was so blurry. Can’t this stuff be plug-n-play? Then then 3″ display I bought for the Pi 3 seems upside down considering where most of the ports are located. I found a little package of scripts called LCD-show linked off a LCD info page. I’m not even sure if my LCDs are close to the ones sold by this company, but these scripts work great. You can easily reboot in different screen orientations too (the rotation didn’t seem to work properly with the mouse on my 7″, but I didn’t try to troubleshoot at the time).
  3. Use Unclutter to hide your mouse cursor when you don’t need it.
  4. Clone and restore SD cards from the command line, because you’re in the linux spirit already.
  5. Since I only access the Pi Zero via SSH, being welcomed by a bit of color with some info about the machine and reminders helps to increase the sugar content. I made a few modifications (my version is below) to a custom MOTD. The colors are set by $(tput setaf 5) and changing the number (color table). You probably want to add this to .bashrc though and not .bash_profile as instructed.

raspberry-pi-custom-motd

    let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
    let secs=$((${upSeconds}%60))
    let mins=$((${upSeconds}/60%60))
    let hours=$((${upSeconds}/3600%24))
    let days=$((${upSeconds}/86400))
    UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`

    # get the load averages
    read one five fifteen rest < /proc/loadavg

    echo "$(tput setaf 5)
    --- Raspberry Pi Zero ---
$(tput setaf 2)
       .~~.   .~~.    `date +"%A, %e %B %Y, %r"`
      '. \ ' ' / .'   `uname -srmo`$(tput setaf 1)
       .~ .~~~..~.
      : .~.'~'.~. :   Uptime.............: ${UPTIME}
     ~ (   ) (   ) ~  Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)
    ( : '~'.~.'~' : ) Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
     ~ .~ (   ) ~. ~  Running Processes..: `ps ax | wc -l | tr -d " "`
      (  : '~' :  )   IP Address.........: `/sbin/ifconfig wlan0 | /bin/grep "inet addr" | /usr/bin/cut -d ":" -f 2 | /usr/bin/cut -d " " -f 1`
       '~ .~~~. ~'    Hostname...........: `hostname --long`.local
           '~'
$(tput setaf 6)
Homebridge Commands
  sudo journalctl -u homebridge -n 300
  sudo systemctl status homebridge (also start/stop)
    $(tput sgr0)"

What are your favorite Raspberry Pi tips?

Raspberry Pi 3 Model B

Almost a year ago I ordered a Raspberry Pi Zero and all kinds of shit to go with it. I messed around with it a little bit but now use it as a Homebridge server, providing HomeKit access to my non-supported devices. Nothing crazy cool.

This weekend I thought of a neat winter project idea and decided to buy the latest and greatest, the Raspberry Pi 3 Model B. I also ordered the 3.5″ touch screen LCD (stylus included) pictured above. Now I need to find a case to hold both. What’s my project? You’ll have to wait and see.

How To Create a Symbolic Link

Every time I want to create a symlink on the command line it seems to take me half an hour. I never get the syntax right as many times as I read the documentation, so I’m posting here with what makes sense to me and my use of Dropbox.

Usually I want to relocate a local folder to Dropbox so that it’s backed up. As an example, I might have a mystuff folder in my user’s home directory.

  1. Move the current mystuff folder to Dropbox.
  2. Run this from the command line.
    ln -s ~/Dropbox/mystuff ~/mystuff
  3. Enjoy the piece of mind that data is automatically backed up.