|
3 | 3 | **Raspberry Pi Zero W**
|
4 | 4 |
|
5 | 5 | ( Raspberry Pi 0 Wireless, Wi-Fi / Bluetooth )
|
6 |
| - |
7 | 6 | ( Tested on v1.1 2016 )
|
8 | 7 |
|
9 | 8 | 
|
| 9 | +## Demonstration |
| 10 | +[YouTube link](https://www.youtube.com/watch?v=9JegZhkDhrw&t=13s) |
10 | 11 |
|
11 |
| -## Setting up Pi Zero |
12 |
| - |
13 |
| -### HEADLESS |
14 |
| -#### (No USB keyboard, mouse, HDMI monitor or adapters needed) |
| 12 | +## Setting up Pi Zero - HEADLESS |
| 13 | +(No USB keyboard, mouse, HDMI monitor or adapters needed) |
15 | 14 |
|
16 | 15 | **More details** - [http://blog.gbaman.info/?p=791](http://blog.gbaman.info/?p=791)
|
17 | 16 |
|
18 | 17 | For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required. **Make sure your USB cable works**. I used 2 faulty cables and wasted about 4 hours going down a dead-end rabbit hole. You should use a USB cable that transfers data, and isn't used just for charging. After flashing the microSD card and connecting the Pi via USB, running `dmesg` on the host computer can help diagnose the cable.
|
19 | 18 |
|
20 | 19 | Windows computers must be running [Bonjour](https://support.apple.com/kb/DL999) (should be installed if iTunes or Quicktime is installed). Mac OS has Bonjour installed by default. Linux uses the Avahi Daemon. Ubuntu has it built-in, but you can check that it's running with: `sudo service avahi-daemon status`. This will let you use the `raspberrypi.local` address out-of-the-box.
|
21 | 20 |
|
22 |
| -#### **1. Flash the microSD** |
| 21 | +### **1. Flash the microSD** |
23 | 22 | You'll need a microSD card reader or adapter. Plug it in. Use the [Raspberry Pi Imager](https://www.raspberrypi.org/software/) to install RaspberryPi OS onto the microSD card.
|
24 | 23 |
|
25 | 24 | The RPi Imager can be installed on Ubuntu 20.04 with:
|
26 | 25 | `sudo apt-get install rpi-imager`
|
27 | 26 |
|
28 |
| -#### **2. Edit `config.txt`** |
| 27 | +### **2. Edit `config.txt`** |
29 | 28 | Once Raspberry Pi OS is flashed, open up the boot partition (in Windows Explorer, Finder, Terminal Emulator, etc.) and add to the bottom of the `config.txt` file `dtoverlay=dwc2` on a new line, then save the file.
|
30 | 29 |
|
31 | 30 | On Ubuntu 20.04, the config.txt file would be located at `/media/$USER/boot/config.txt`
|
32 | 31 |
|
33 |
| -#### **3. Enable SSH** |
| 32 | +### **3. Enable SSH** |
34 | 33 | If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called `ssh` in the SD card as well. On Ubuntu 20.04: `sudo touch /media/$USER/boot/ssh`. By default SSH is now disabled so this is required to enable it. **Remember** - Make sure your file doesn't have an extension (like .txt etc)!
|
35 | 34 |
|
36 |
| -#### **4. Edit `modules`** |
| 35 | +### **4. Edit `modules`** |
37 | 36 | Add `dwc2` and `libcomposite` to the `modules` file. On Ubuntu 20.04, the file is at `/media/$USER/rootfs/etc/modules`. You can run:
|
38 | 37 |
|
39 |
| -#### **5. Boot up the Pi** That's it, eject the SD card from your computer, put it in your Raspberry Pi Zero and connect it via USB to your computer. It will take up to 90s to boot up (shorter on subsequent boots). |
| 38 | +### **5. Boot up the Pi** That's it, eject the SD card from your computer, put it in your Raspberry Pi Zero and connect it via USB to your computer. It will take up to 90s to boot up (shorter on subsequent boots). |
| 39 | + |
| 40 | +I didn't add `g_ether`, so it won't appear as a USB Ethernet device. We'll use `ssh [email protected]` to SSH into the Pi on the local network instead. With the microSD back in the computer, edit the file rootfs: `/etc/wpa_supplicant/wpa_supplicant.conf`: |
| 41 | + |
| 42 | +``` |
| 43 | +country=US |
| 44 | +network={ |
| 45 | + ssid="ChanceTheRouter" |
| 46 | + psk="CocoaButterKisses" |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +Additionally, create a file called `ssh` on the boot partition. Change into the root of the boot directory and run: |
| 51 | + |
| 52 | +``` |
| 53 | +touch ssh |
| 54 | +``` |
40 | 55 |
|
41 |
| -We didn't add `g_ether`, so is won't appear as a USB Ethernet device. Use `ssh [email protected]` to SSH into the Pi on your network. If you have multiple Pi's on the network, rename the existing hosts or use [Fing ](https://www.fing.com/products/development-toolkit) to discover the Pi's IP address. |
| 56 | +If you have multiple Pi's on the network, rename the existing hosts or use [Fing](https://www.fing.com/products/development-toolkit) to discover the Pi's IP address. If you know the Pi's MAC address, you can also use the helper script included in the repo, `rpi.sh`. Replace the "<pi mac address lowercase and colons>" with your Pi's MAC address. You might have to play with the range of the IP address included in the script. |
42 | 57 |
|
43 |
| -#### **6. Configure the Pi as an HID** |
| 58 | +### **6. Configure the Pi as an HID** |
44 | 59 | Configure the Pi as a _human interface device_ (the same device type of a generic USB keyboard) by adding the following script to `/usr/bin/vimclutch_usb`
|
45 | 60 |
|
46 | 61 | ```
|
@@ -76,22 +91,22 @@ Make the script executable:
|
76 | 91 | Add the script to `/etc/rc.local` before `exit 0`:
|
77 | 92 | `/usr/bin/vimclutch_usb #setup USB gadget`
|
78 | 93 |
|
79 |
| -#### **6. Install script requirements** |
| 94 | +### **6. Install script requirements** |
80 | 95 | Install python3-pip on your Raspberry Pi:
|
81 | 96 | `sudo apt-get install python3-pip`
|
82 | 97 |
|
83 | 98 | Install python requirements:
|
84 | 99 | `sudo pip3 install -r requirements.txt`
|
85 | 100 |
|
86 |
| -#### **7. Execute script on boot** |
| 101 | +### **7. Execute script on boot** |
87 | 102 | Add the Python script to `rc.local` so that the pedal will work immediately upon power-up:
|
88 | 103 |
|
89 | 104 | `sudo vim /etc/rc.local`
|
90 | 105 |
|
91 | 106 | Then add the following line before the end of the file:
|
92 | 107 | `python3 /home/pi/vim-clutch/vim-clutch.py`
|
93 | 108 |
|
94 |
| -#### **8. Tweak the settings** |
| 109 | +### **8. Tweak the settings** |
95 | 110 | Adjust the `sleep()` times for best results.
|
96 | 111 |
|
97 | 112 | ---
|
|
0 commit comments