-
Notifications
You must be signed in to change notification settings - Fork 18
Raspberry Pi Zero W
Use the Raspberry Pi Imager tool to create a bootable SD card
- Install https://raspberrypi.org/downloads/ (MacOS, Windows, Linux)
- Select the Raspberry Pi Zero as your device (which is a Pi Zero W)
- Select the Raspberry Pi OS (other) > (Legacy, 32-bit) Lite image
- Chose the SD card as your storage and click Next > Edit Settings
- On the General tab, set a hostname (e.g. raspberrypi.local)
- Then, create a username (e.g. pi) and set a password
- Also configure the wireless LAN SSID and password
- Keep the default GB as your wireless LAN country
- On the Services tab, enable SSH and Save
- Say Yes, to apply OS customization
- Wait for the SD card to be ready
- Eject the SD card from your computer
- Insert it into the Pi, power it up and wait
- After ~5 minutes, try to access your Pi.
Legacy instructions to configure and access a Pi via USB.
Use the Raspberry Pi Imager tool to create a bootable SD card
- Install https://raspberrypi.org/downloads/ (MacOS, Windows, Linux)
- Select the Raspberry Pi OS (other) > (Legacy, 32-bit) Lite image
Create an ssh marker file on the SD card
- The following file will enable sshd, the SSH daemon, on the Raspberry Pi
- Navigate to the disk drive named boot and create an empty file named ssh with
$ cd /Volumes/boot $ touch ssh
or on Windows, assuming the boot drive is E:C:> E: E:> type nul > ssh
- Note: once sshd is enabled, the Raspberry Pi will remove the ssh file
Edit configuration files on the SD card
- The following edits convert the Raspberry into a RNDIS USB device
- Open config.txt and append dtoverlay=dwc2
$ cd /Volumes/boot $ open config.txt $ cat config.txt … dtoverlay=dwc2
- Open cmdline.txt and add modules-load=dwc2,g_ether after rootwait
$ open cmdline.txt $ cat cmdline.txt … rootwait modules-load=dwc2,g_ether …
- On the disk drive named boot, create a file named wpa_supplicant.conf
$ cd /Volumes/boot $ nano wpa_supplicant.conf
- For file content and options, see Configure Wi-Fi
- Insert the SD card into the Raspberry Pi (it is the Pi's "hard disk")
- Connect the USB cable, use the left USB connector on the Raspberry Pi
- Download http://web1.moddevices.com/shared/mod-duo-rndis.zip
(see https://forum.moddevices.com/t/rndis-driver-for-windows-10/299 or https://modclouddownloadprod.blob.core.windows.net/shared/mod-duo-rndis.zip) - Open device management (WINDOWS-R, type cmd, RETURN, type devmgmt.msc, RETURN)
- Find the new USB device in the device tree (e.g. COM3, usually showing a warning)
- Right click the USB device, click Update driver software...
- Choose Install from disk, select the mod-duo-rndis.zip downloaded above (or follow https://www.circuitbasics.com/raspberry-pi-zero-ethernet-gadget/)
- The USB device should now show up as an RNDIS device
- Download iTunes installer https://www.apple.com/itunes/download/win64
- Unpack the installer EXE/ZIP, find the Bonjour64.msi installer inside
- Run Bonjour64.msi, select Bonjour uninstall old version
- Run Bonjour64.msi, select Bonjour install 3.0
- Wi-Fi > Properties > Sharing > [✓] Allow
- System Preferences > Sharing > [✓] Internet
- Sharing > Share your connection from: Wi-Fi to computers using RNDIS Ethernet Gadget
To find your Pi Zero via USB (if Internet Sharing is enabled), type
$ dns-sd -G v4 raspberrypi.local
Or, use ifconfig (or ipconfig on Windows) you find the local IP prefix, e.g. 192.168.0.
$ ifconfig
en0: flags…
ether…
inet6…
inet 192.168.0.23
…
Then use nmap to scan the subnet, e.g.
Note: make sure port scanning is fine with the local network admin, e.g. at FHNW it's not allowed.
$ nmap 192.168.0.0-255 -p22
Nmap scan report for 192.168.0.42
…
22/tcp open ssh
With ssh (or PuTTY on Windows) and the user (e.g. pi), hostname (e.g. raspberrypi) and password you set above:
$ ssh [email protected]
Or, if you know the local IP address of the device, e.g. 192.168.0.42:
$ ssh [email protected]
Or via FTDI Serial (up to Pi 2, or with this fix for Pi 3).
3V3 (!), Pin 6 = GND, 8 = TX, 10 = RX
Use a relay service like Ngrok, Pagekite or Yaler.net.
https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md
Open the Wi-Fi config file wpa_supplicant.conf (or create it on the SD card)
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
The file should contain the following content (using your credentials)
country=UK
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="MY_SSID"
psk="MY_PASSWORD"
key_mgmt=WPA-PSK
}
Consider using the hashed version of psk, see output of
$ sudo wpa_passphrase 'MY_SSID' 'MY_PASSWORD'
To activate the new config, type
$ sudo ifconfig wlan0 up
To display the priority metric, use
$ route -n
To change the priority metric (here wlan0 before usb0), type
$ sudo nano /etc/dhcpcd.conf
interface wlan0
metric 200
interface usb0
metric 300
$ cat /sys/class/net/wlan0/address
$ sudo apt-get update
$ sudo apt-get install git
$ git
$ git config --global user.email "USER_EMAIL"
$ git config --global user.name "USER_NAME"
$ ssh-keygen -t rsa -b 4096 -C "USER_EMAIL"
$ eval "$(ssh-agent -s)"
$ cat ~/.ssh/id_rsa.pub
- Go to https://github.com/settings/keys
User Icon > Settings > SSH and GPG keys > New SSH key > {Paste SSH key}
$ sudo apt-get install keychain
$ keychain ~/.ssh/id_rsa
$ . ~/.keychain/$HOSTNAME-sh
(Until next reboot)
$ scp -P 22 LOCAL_FILE pi@RASPI_IP:RASPI_PATH
$ scp -P 22 pi@RASPI_IP:RASPI_FILE LOCAL_PATH
-
https://www.raspberrypi.org/blog/oracle-java-on-raspberry-pi/
$ sudo apt-get update && sudo apt-get install oracle-java7-jdk
- Optional:
$ sudo apt-get install maven
-
http://pi4j.com/ (wiringPi wrapper in Java)
$ curl -s get.pi4j.com | sudo bash
- http://pi4j.com/example/serial.html
- http://pi4j.com/example/control.html
- Get the latest LTS (long term support) version from https://nodejs.org/en/download/ e.g. v20.18.0
- Or use a previous version from https://nodejs.org/en/download/releases/ (for compatibility)
- Use the following commands with the selected version
$ wget https://unofficial-builds.nodejs.org/download/release/v20.18.0/node-v20.18.0-linux-armv6l.tar.gz $ tar -xzf node-v20.18.0-linux-armv6l.tar.gz $ cd node-v20.18.0-linux-armv6l $ sudo cp -R * /usr/local $ node -v
- Update apt-get with
$ sudo apt-get update
- Install prerequisites with
$ sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
- Install the abandonware fork of noble with
$ npm install @abandonware/noble
- https://www.npmjs.com/package/rpi-gpio
- https://nodejs.org/api/stream.html
- https://github.com/abandonware/noble (BLE Central)
- https://github.com/abandonware/bleno (BLE Peripheral)