Getting your (Pi) dev on

Update and install some things, this is of course biased to how I like things to be setup ;-)

$ sudo apt-get update && sudo apt-get upgrade -y
$ sudo apt-get install -y vim-nox git zsh python3-pip python3-smbus i2c-tools python3-envirophat python3-blinkt python3-inkyphat
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
$ mkdir -p ~/.vim/pack/<github_username>/start && $_
$ git clone https://github.com/python-mode/python-mode.git
$ cd python-mode
$ git submodule update --init --recursive

note: just using my github_username above as a handy folder name, probably good if you’re using the dotfiles pattern as well.

And then this guide to configure I2C helped with get the EnviroPhat working

Debugging headless Raspberry Pi Zero W

So of course having posted about setting up a Raspberry Pi Zero W there now follows the inevitable debugging connection problems post ;-)

Without a monitor to use, or a working connection to the Pi debugging was going to be less than simple as I need to look at the logs.

So how do I mount an ext4 volume on a Mac to take a look at the logs?

$ brew cask install osxfuse
$ brew install ext4fuse

So now I can plug the SD card into a reader and mount up the volume which in my case was as simple as:

$ sudo ext4fuse /dev/disk2s2 /Volumes/pi -o allow_other

Then I could navigate into /Volumes/pi and start poking around at the log files to try and find what the issue was.

$ more /var/log/syslog

In my case it was down to user error and not checking the types of WiFi the Zero could support. 5Ghz isn’t supported it would appear, switching to my 2.4Ghz WiFi resolved the problem.

Headless wifi setup on a Raspberry Pi Zero W

So after drawing inspiration from a couple of people and the fact my daughter is now attending the local Coder Dojo. I thought maybe I should get into a bit of hacking and playing around with coding more so I can help answer some of the inevitable questions.

I now have a Pi Zero (W) sitting on my desk with no easy way of setting it up.
Download the latest Raspbian from here. I’m using 2017-11-29-raspbian-stretch-lite in this example which was the latest as of writing.

Oh and because I still can’t solder very well I got the hammer header set to make things a bit easier. (and so I can use a hammer as a soldering iron!)

So this was completed using OSX and serves mainly as a reference for me, but might also be useful for anyone else trying to get Wifi working on a headless Raspberry Pi Zero W

To get the image on to the SD card:

$ brew cask install etcher

And use the simple interface to select the previously downloaded image and your SD card, if the SD card isn’t showing, unplug it from the card reader and plug it back in.

Once etcher has finished writing the image to the card you should be able to use terminal to access the boot volume of the card:

$ cd /Volumes/boot

Create the files you need:

$ touch wpa_supplicant.conf ssh

ssh remains empty and is just there so that SSH is enabled on the Pi at boot time.

** Note: ** If you look at the boot volume of the SD card once it has been used in a Pi you will find that the two files created aren’t present, it’s ok they are moved to the correct location on start up.

You need to configure the wpa_supplicant.conf with your wireless connection(s):

$ vim wpa_supplicant.conf

Add your wifi configuration(s):

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="ESSID"
    psk="Your_wifi_password"
}

Or for multiple connection profiles:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="ESSID1"
    psk="Your_wifi_password"
    priority=100
}
network={
    ssid="ESSID2"
    psk="Your_wifi_password"
    priority=90
}

Save the file

For added winning following this gist you can also set up your Pi Zero W so that you can ssh into it using a USB connection (just plug your USB cable into the right connection, not the power one)

All done? (maybe) unmount the SD card plug into your Pi and power on.

Once you the Pi has successfully booted up you should be able to access it using ssh pi@raspberrypi.local

To get around the inconvenience of having to type your password:

$ scp ~/.ssh/id_rsa.pub pi@raspberrypi.local:~/.ssh/authorized_keys

Don’t forget to still change the default password on the Pi, every time you log in it will be there just above the prompt until you do anyway.

Lego Porsche 911 GT3 RS

So I was fortunate enough to receive an unexpected box of Lego goodness at the end of last week which just happened to contain the Porsche 911 GT3 RS.  Which meant I spent “some” time over the weekend a) building it and b) explaining to the kids that this wasn’t Lego for them.

This should be a longer post about building the Porsche, but I’ll just let the photos of the build do the “talking” instead.