Raspberry Pi
Contents
Pi4B needs about 1.5A under load. If you plan to connect USB devices, more is better.
Prepare SD card with Raspbian
Download Raspberry Pi OS Lite and write it with balenaEtcher to the SD-card.
Alternative: DD img file to SD card
|
|
Enable SSH server
After you copied Raspbian onto the SD card you have to create a file called ssh on the volume.
touch /Volumes/boot/ssh
Prepare SD card for Wi-Fi
Create a text file /boot/wpa_supplicant.conf
with your Wi-Fi settings.
|
|
Log into Raspberry Pi
The easiest way to find your Raspberry Pi is by logging into your router (usually 192.168.1.1) and finding there the DHCP IP address assigned to the device.
ssh pi@[IP_ADDRESS]
with password raspberry
Headless Setup
There are a few steps you have to do on your first login:
- Change the default password with
passwd
- Change hostname with
sudo raspi-config
-> 1 -> S4 - Change local to
us_US.UTF-8
sudo raspi-config
-> 5 -> L1 - Change timezone in
sudo raspi-config
-> 5 -> L2 - Update raspberry
sudo apt-get update && sudo apt-get upgrade -y
- (optional on lite) Reduce GPU memory to 16MB in
sudo raspi-config
- (optional) Upgrade distro
sudo apt-get update && sudo apt-get dist-upgrade
- Setup password less login
ssh-copy-id pi@[IP_ADDRESS]
After reboot you have to connect to new hostname. sudo reboot
Configure Static IP
You can reserve the IP in the router, but I prefer the devices to be configured with a fix IP, so that in case of a poweroutage they don’t have to wait for the router.
sudo nano /etc/dhcpcd.conf
- inside you will find an example.
|
|
Backup and Restore SD on a Macbook
This will create a backup of all the blocks so you can only restore it to a stick of the same size.
|
|
Advertise SSH in mDNS (bonjour)
mDNS allows you to find your device easier in the network, you can connect to it with ssh pi@hostname.local
.
sudo nano /etc/avahi/services/ssh.service
|
|
Discovery - DNS-SD Browser for macOS
Installing node.js on Raspberry Pi
I recommend using the Node Version Manager
Install LTS version nvm install --lts
or latest nvm install node
.
Test it with node -v
and learn where nvm put it with which node
.
Alternative: Installing node.js directly into /usr/local
Visit the node.js download page and get the download link for ARM.
|
|
Installing Go on Raspberry Pi
Visit Go download page and copy the ARM download link.
|
|
Common Problems
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
-> your Terminal locale settings are different from the Pi. Change the local on the Pi.- Time/Timezone is not working or problem with NTP -> run
sudo raspi-config
and setup timezone. - How can I extend the life of my SD card?
- Print serial:
cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2
- Print MAC:
cat /sys/class/net/eth0/address
- Print Pi Model:
cat /proc/device-tree/model
- The Wi-Fi can fail to reconnect http://raspberrypi.stackexchange.com/a/28047/52917
Misc tools
|
|
How to configure 7" touchscreen display
If you use the official raspbian software it should work out of the box. Just connect the display cable and power/gnd.
Benchmark SD card
Its just good to have a feeling how fast you can read and write to the SD card. This allows you to judge what applications to run on the Raspberry Pi.
Downlaod sd_card_speed_test.sh
|
|
Blink system LED
When you need to identify a Raspberry Pi, because you have so many :)
- Turn off all triggers (I think per default it blinks on disk writes) for the LED
echo none >/sys/class/leds/led0/trigger
- Set brightness to full
echo 1 >/sys/class/leds/led0/brightness
- Turn off LED
echo 1 >/sys/class/leds/led0/brightness
- Set a trigger for the LED
echo timer >/sys/class/leds/led0/trigger
Hardware and Software
- Audio: do not use the built in audio out, it has background nose. Use a bluetooth speaker or an audio HAT.
- Keyboard: I used the Logitech K400 Plus a lot.
- Raspberry Pi App Store