- 1GHz, single-core CPU
- 512MB RAM
- 802.11 b/g/n wireless LAN
- Bluetooth 4.1
- Bluetooth Low Energy (BLE)
Case
The Raspberry Pi Zero W V1.1 by far not the most powerful, but my favorite Raspberry Pi board, because it’s so very most and still capable enough. After putting the tiny board, weighing only 9.3g / 0.3oz into a nice case like this one maybe, it is time to bring it to life.
Linux OS
- Download this minimal image, based on Debian Stretch.
- Uncompressing the ZIP will create the image file, e.g. 2018-11-13-raspbian-stretch-lite.img
- Download balenaEtcher, a tool for conveniently flashing an SD cards
- Insert a MicroSD Card (8Gb or larger) into your computer or card reader and use Etcher to copy the downloaded image onto the SD Card.
Before removing the SDCard, let’s add a few files to allow for a headless setup later:
For instance, if a wpa_supplicant.conf file is available in the /boot partition, it will be moved automatically into the right place (/etc/wpa_supplicant/) during the boot process:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev country=US update_config=1 network={ ssid="YOUR_SSID" psk="YOUR_PASSWORD" key_mgmt=WPA-PSK }
Creating an empty ssh file will enable Secure Shell (SSH) when the Raspberry Pi boots up.
touch /Volumes/boot/ssh
SSH over USB
The previous step should put the Raspberry Pi on the configured Wifi network, but in case that fails, let’s also enable the option to ssh into the Raspberry Pi Zero over a USB connection:
Append dtoverlay=dwc2 to this file: /Volumes/boot/config.txt like so:
echo 'dtoverlay=dwc2'>>/Volumes/boot/config.txt
Using your preferred editor, append ‘ modules-load=dwc2,g_ether
‘ to /Volumes/boot/cmdline.txt (mind to spaces) after rootwait
1st Boot
At this point, the SDCard is ready to be inserted into the Raspberry Pi Zero. Connecting the device with another computer, using the center-most micro-USB socket, not only powers the Zero, but also allows to ssh into it. By default, the host name of the Zero is raspberrypi, the username is pi and by default the password is raspberry. Therefore:
Using ifconfig should now result in something like this:
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 169.254.63.5 netmask 255.255.0.0 broadcast 169.254.255.255 inet6 fe80::9e85:8498:1cb4:f79f prefixlen 64 scopeid 0x20 ether 6a:b4:b4:34:8c:2d txqueuelen 1000 (Ethernet) RX packets 121 bytes 31254 (30.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 73 bytes 12835 (12.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.200.221 netmask 255.255.255.0 broadcast 192.168.200.255 inet6 fe80::d398:59e8:27be:5fd4 prefixlen 64 scopeid 0x20 ether b8:27:eb:64:d1:40 txqueuelen 1000 (Ethernet) RX packets 107 bytes 40086 (39.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 43 bytes 6761 (6.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Setting a hostname, adjusting the local and timezone, and since the devices runs mostly headless, the GPU memory can be reduced to 16MB, which is the minimum.
sudo raspi-config
- Network Options / N1 Hostname …
- Localization Options / Change Locale: us.UTF and Change Timezone: US/Pacific
- Advanced Options / Memory Split
Adding a user
sudo su
adduser wolf
usermod -aG sudo wolf
mkdir /home/wolf/.ssh
cat >> /home/wolf/.ssh/authorized_keys …
cp /root/.ssh/authorized_keys /home/wolf/.ssh/
chown -R wolf:wolf /home/wolf
//using visudo .. add this at the bottom:L
wolf ALL=(ALL) NOPASSWD: ALL
Updating the OS
apt-get upgrade apt-get upgrade
which also brings Python to 3.5.3 but pip3 is still missing. Therefore:
sudo apt-get install python3-pip
followed by:
pip3 install websockets webcolors magicblue
Deploying the app
mkdir /etc/moola
copy source files into /etc/moola
copy config file (lamp.json) into /boot
Launching the app on boot
Append something like this to /etc/rc.local
/etc/moola/moolalamp.sh