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
$ cd ~/.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

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.

Code School

So before I get started with Code Club one of the things I need to do is learn Scratch, I’ve had a quick play and don’t imagine it will be too hard (he says setting himself up for a fall) and so as part of that it’s time for a proper month of learning, liking movember but without the shit facial hair.  I have a Code School account so I have access to a good resource and have already completed a couple of their courses (GIT, R, Rails for Zombies), but this month I’m going to focus on JavaScript track, I’ve tinkered with and used it in the past, maybe now it’s time to learn it properly.

Day 19

Another day, another language looked at, I must be the master of Hello World by now.

Anyway for the first time in a long time it was Java.  It’s in use where I’m working at the moment (along with some technologies I’m more familiar with) but following my mantra of “learning is fun” it was time to grab a copy of Spring Tool Suite (STS) install, and then find a Spring Hello World tutorial.

One train journey home and the box is ticked, now to try and find some more interesting tutorials to get a fuller flavour of Spring and why people (who like Java) seem to like it and rate it.  Certainly since I last tinkered with java having a more integrated tool like STS makes my life a lot easier.  From nothing to Spring based Hello World in a 10 minute train is quite nice.  In the past I think I’d got bored with playing with Tomcat and trying to get it working at this point ;-)