Close

First Boot

A project log for Pi Zero PC by Bay Networks (The Pikelet)

I acquired a great little EN104 Bay Networks 'Netgear Hub'. I decided to re-purpose it to house a little Pi Zer0.

tinkerzonetinkerzone 01/23/2017 at 03:180 Comments

The Pikelet is currently running a fresh install of Raspbian Jessie with Pixel version 2017-01-11 on a sandisk 80Mbps 32gb micro sd card. The latest version of Raspbian cna be downloaded from: https://www.raspberrypi.org/downloads/raspbian/

A few minor tweaks were made on the first boot.

The first step was to console in I consoled in via the USB port connected to the Uart module. My settings were:

Serial Line: Com19 (yours will be different)

Speed: 115200
Connection type: Serial

After entering the username and password I was presented with the PiKelet's command line.

Using sudo raspi-config I expanded the file system.

I also used the advanced option to change the device name to PiKelet.
WiFi was setup with the help of the guide produced by Adafruit: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/setting-up-wifi-with-occidentalis

At some point I may choose to change the settings to give a fixed IP address, rather than assigning via DHCP. This is useful if you ssh into the pi zero via WiFi as you will always know the IP address (provided you write it down) of the PiKelet.

The next step was to setup the RGB indicator LED. During hardware setup I connected the RGB segments to Raspberry GPIO Pins 19, 20, 21 respectively (BCM numbering). On first boot they shined a very light aqua colour cause by a small amount of current leakage through the pi. I decided that (for now) i simply want the indicator LED to shine green once the pi has booted. The following steps were made:

a new folder was created at ~ called Scripts and we moved to that folder:

cd ~
mkdir Scripts

cd Scripts

Then a new python file was created:

sudo nano bootscript.py

A few lines of code were added to set GPIO pins 19,20, and 21 pins as outputs, turn 19 and 21 High (i.e. off for a common Anode led) and setting pin 20 low (Green on).

#####################
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

GPIO.setwarnings(False)

GPIO.setup(19, GPIO.OUT)
GPIO.setup(20, GPIO.OUT)

GPIO.setup(21, GPIO.OUT)
GPIO.output(19, True) ##As it's a common ANODE LED this turns the R segment off

GPIO.output(20, False) ##As it's a common ANODE LED this turns the G segment on
GPIO.output(11, True) ##As it's a common ANODE LED this turns the B segment off
#######################


ctrl x to exit hitting save.

Then we moved to /etc to edit rc.local:

cd /etc

And open rc.local for edit:

sudo nano rc.local

A pair of lines were added to rc.local to run bootscript.py on startup:

cd /home/pi/Scripts

sudo python bootscript.py

ctrl x to exit hitting save

The result is that the status indicator will turn green once bootscript.py runs.

Future edits will modify it to turn green once WiFi is connected, or red if WiFi isn't able to be connected. (If anyone would like to suggest a code snippet for this, it would be msot welcome).





Discussions