oops.se
September 25, 2024, 19:34

Use the right unit

When communicating in IT it is essential that you uses the correct units. Often people mixes m with M. And a "m" = 0.001 aka milli and a "M" = 1 000 000 aka mega. Another mixup is the usage of "b" or "B". A "b" is a bit and a "B" is a byte and one byte consist of eight bits. Check out SI prefixes here https://en.wikipedia.org/wiki/International_System_of_Units b https://en.wikipedia.org/wiki/Bit B https://en.wikipedia.org/wiki/Byte
oops.se
August 31, 2024, 20:47

Raspberry Pi 1-3 - Power Supply

https://www.raspberrypi.com/products/micro-usb-power-supply/ The official and recommended micro USB power supply for all micro USB-powered Raspberry Pi computers - 5.1V / 2.5A DC output - 96-264Vac operating input range - Short circuit and overcurrent protection - 1.5m 18AWG captive cable with micro USB output connector - Available in different variants to suit different international power sockets https://datasheets.raspberrypi.com/power-supply/micro-usb-power-supply-product-brief.pdf Obsolescence Statement Raspberry Pi 12.5W Micro USB Power Supply will remain in production until at least January 2030
oops.se
August 1, 2024, 16:29

Bookworm - SPI display devices

## SPI (Serial Peripheral Interface) display devices There are a plethora of small displays that hasn't a standard HDMI interface but a SPI interface. The SPI display devices have their own "display drivers". SPI is an electrical interface. ## Bookworm Changes When the Raspberry Pi OS, Bookworm was released, one of the large changes was the change of display server from the old and sturdy X.org aka X/X.11 to Wayland. This has caused a lot of graphic drivers to cease working as they are not compatible with Wayland. ## Recommendation Contact the seller and ask for a Wayland compatible driver. Ref.: SPI (Serial Peripheral Interface) - https://en.wikipedia.org/wiki/Serial_Peripheral_Interface - https://www.analog.com/en/resources/analog-dialogue/articles/introduction-to-spi-interface.html Ref.: Wayland & X - https://en.wikipedia.org/wiki/Wayland_(protocol) - https://en.wikipedia.org/wiki/X_window_manager
oops.se
July 14, 2024, 20:34

Raspberry Pi 5 - Fan

The Raspberry Pi 5 automatically switches on the fan when the temperature rises and speeds it up or slows it down depending on the temperature: - Below 50°C, the fan is switched off completely - From 50°C it turns moderately at 30% speed - At 60°C it goes up to 50% speed - 67.5°C increases to 80% speed - 75°C ensures full (= maximum) speed Contributed by <@1187039958561726494> ## Connector 4pin JST SH connected (aka Qwiic)
Pin 1 - Red wire      +5 volt
Pin 2 - Blue wire     PWM
Pin 3 - Black wire    GND
Pin 4 - Yellow wire   Tach

oops.se
July 14, 2024, 20:46

PiHole install and use

## PiHole Requirements Raspberry Pi OS installed and updated - Check the FAQ section for how to install Raspberry Pi OS https://discord.com/channels/818384379197784084/1193923435789824050 Static IP (Optional but highly recommended) - Check the FAQ section for static IP configuration Note! There is a difference between "Raspberry Pi OS Bullseye" and "Raspberry Pi OS Bookworm" ## PiHole Install curl -sSL https://install.pi-hole.net | bash ## PiHole Post Install Configure PiHole "forwarder DNS", where should PiHole send DNS queries? - http://<PiHole>/admin Where <PiHole> is the hostname or IP address you have given your PiHole Configure "PiHole" as DNS for the host OS. ## Clients/Devices Configure "PiHole" as DNS for your devices (Computers, mobiles and such). - Change it in your current DHCP server, probably your "home router". - Disable your "home router" DHCP service and configure and activate the DHCP service in PiHole. - Change it in your device OS manually (IMHO Not recommended). Remember to force an update on all your devices, reboot or use command like: - Linux: sudo dhclient -r to release the IP adr. and then sudo dhclient to require a IP address. - Windows: ipconfig /release and then ipconfig /renew ## Test Web test page: https://d3ward.github.io/toolz/adblock.html If you test with other web pages remember that the web browser caches data and you need to force a reload of the web page in your browser, ex with ctrl + F5, but this varies between web browsers.
oops.se
July 14, 2024, 20:49

Troubleshooting

Pre release # Common causes for failures. In priority order. - SD card broken - SD card faulty image - SD card corruption - Under sized power supply - Under sized USB cables - Faulty Raspberry Pi - Corrupt firmware/EEPROM # Intro Raspberry Pi 1-4, Zero and Zero 2 models there is a blink pattern on the green LED that can indicate what is faulty. Raspberry Pi 5 error messages can also been shown on HDMI 0. ## Raspberry Pi Act LED (green LED) Error Patterns https://support.pishop.ca/article/33-raspberry-pi-act-led-error-patterns ## My Pi Won't Boot https://support.pishop.ca/article/11-my-pi-wont-boot-red-light-only ## https://support.pishop.ca/category/10-raspberry-pi-troubleshooting ## Corrupt firmware/EEPROM Follow the "Updating the bootloader" instructions, https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#bootloader_update_stable
illegitimate_egg
July 14, 2024, 20:49

Pi 5 Fan Temps and Speed Modification

The Pi 5 fan speeds can be modified through a simple parameter to the main dtoverlay. Open up config.txt and use one of these options [1]
fan_temp0               Temperature threshold (in millicelcius) for
                        1st cooling level (default 50000). Pi5 only.
fan_temp0_hyst          Temperature hysteresis (in millicelcius) for
                        1st cooling level (default 5000). Pi5 only.
fan_temp0_speed         Fan PWM setting for 1st cooling level (0-255,
                        default 75). Pi5 only.
fan_temp1               Temperature threshold (in millicelcius) for
                        2nd cooling level (default 60000). Pi5 only.
fan_temp1_hyst          Temperature hysteresis (in millicelcius) for
                        2nd cooling level (default 5000). Pi5 only.
fan_temp1_speed         Fan PWM setting for 2nd cooling level (0-255,
                        default 125). Pi5 only.
fan_temp2               Temperature threshold (in millicelcius) for
                        3rd cooling level (default 67500). Pi5 only.
fan_temp2_hyst          Temperature hysteresis (in millicelcius) for
                        3rd cooling level (default 5000). Pi5 only.
fan_temp2_speed         Fan PWM setting for 3rd cooling level (0-255,
                        default 175). Pi5 only.
fan_temp3               Temperature threshold (in millicelcius) for
                        4th cooling level (default 75000). Pi5 only.
fan_temp3_hyst          Temperature hysteresis (in millicelcius) for
                        4th cooling level (default 5000). Pi5 only.
fan_temp3_speed         Fan PWM setting for 4th cooling level (0-255,
                        default 250). Pi5 only.
## Example Add this to the bottom of your config.txt to drop the fan activation temperatures by 10 degrees
# Lowered by 10 degrees
dtparam=fan_temp0=40000
dtparam=fan_temp1=50000
dtparam=fan_temp2=57500
dtparam=fan_temp3=65000
k9t33n
July 14, 2024, 20:50

Which Pi should I get?

This all depends on two questions you must ask yourself. - For one what do you plan to do with your Pi? - and secondly how much are you willing to spend is the obvious one. # what do you plan to do with your pi? If you just want to learn Linux and have fun programming then I can happily say any Pi (apart from the Pico) will serve you very well. If you are absolutely sure you just want to program or do something like [feeding your dogs for you](https://www.raspberrypi.com/news/raspberry-pi-pico-feeds-pikita-the-chihuahua-twice-a-day/ ), nothing to do with Linux and you are sure about it then a Pico is just fine for you. If you want to use your Pi as your own home server then you might want a newer model with more performance, maybe a pi 3b or above since those are the models with ethernet. ### TLDR: - Any pi is good if you just want to learn Linux and program - pi Pico is good if you just want to program, that's it, nothing more.
oops.se
July 14, 2024, 20:50

Adding On/Off kind off feature to Raspberry Pis before Pi 5

In the latest model of Raspberry Pi (Pi 5) is an on/off switch finally a reality. An firmware change a couple years ago has an shutdown features been added, but that has passed under the radar for many. ## Shut down button The shutdown button, not really a off button but close enough can be added between GPIO3 and GND or GPIO on the old Raspberry Pi 1 B ). The default GPIO3 can be changed by adding a row to /boot/config.txt and that is dtoverlay=gpio-shutdown,gpio_pin=XX where XX is the number on the GPIO ping you wish to change to. ## Restart/On button An also quite unknown feature is the reset feature (RUN) that can be used to start the Raspberry Pi from a shutdown (halted) state. This is a 2 hole jumper (or 3 on Raspberry Pi 4) and by adding a button here will by resetting the Pi get it to boot from the previous halted state. This can't be changed or reprogrammed to another GPIO pin!* ## Conclusion By adding two push buttons, a Raspberry Pi can get a "kind of" on/off feature. And the reason for "kind of" is that a shut down will not turn off the power, just place the Raspberry Pi in a HALT state.
oops.se
July 14, 2024, 20:50

Python libraries installation and the "this environment is externally managed."

The reason for the error message "this environment is externally managed." is that you can install python libraries only from the package library (apt). One way is with Debian's packages manager "apt" and the other way is with Pythons installer "pip" and this can cause conflicts. To solve this has the Python foundation written an Python Enhancement Proposals [PEP 668 – Marking Python base environments as “externally managed”](https://peps.python.org/pep-0668/) So you have 4 options: 1. Use apt as is recommended, but if the package/library isn't available in apt... 2. Use venv, check [stack overflow](https://stackoverflow.com/questions/75602063/pip-install-r-requirements-txt-is-failing-this-environment-is-externally-mana/75696359#75696359) for an guide how to implement a virtual environment. 3. Use pip's argument --break-system-packages, this is NOT recommended! 4. Disable the "externally-managed-environment" feature and you guessed correct this is also NOT recommended. sudo rm /usr/lib/python3.11/EXTERNALLY-MANAGED Resources: [PEP 668 – Marking Python base environments as “externally managed”](https://peps.python.org/pep-0668/) https://docs.python.org/3/library/venv.html [pip install -r requirements.txt is failing: "This environment is externally managed"](https://stackoverflow.com/questions/75602063/pip-install-r-requirements-txt-is-failing-this-environment-is-externally-mana/75696359#75696359)
oops.se
July 14, 2024, 20:50

Raspberry Pi power consumption

There is a difference between a "Charger" and a "Power supply" and the recommendation is to use Power Supplies. One of the reasons is that a power supply is design for constant usage a Charger is not. Be aware that some USB cables uses less copper (less area) and can cause problems as the voltage drop can exceed the one that is allowed. ## Recommended power supply
Model                      Recommended PSU current capacity
-----                      --------------------------------
Raspberry Pi 1 Model A     700mA
Raspberry Pi 1 Model B     1.2A
Raspberry Pi 1 Model A+    700mA
Raspberry Pi 1 Model B+    1.8A (Pi 1.3A ,USB 0.5A)
Raspberry Pi 2 Model B     1.8A (Pi 1.6A ,USB 1.2A)
Raspberry Pi 3 Model B     2.5A (Pi 1.3A ,USB 1.2A)
Raspberry Pi 3 Model A+    2.5A (Pi 1.3A ,USB 1.2A)
Raspberry Pi 3 Model B+    2.5A (Pi 1.3A ,USB 1.2A)
Raspberry Pi 4 Model B     3.0A (Pi 1.8A ,USB 1.2A)
Raspberry Pi 400           3.0A (Pi 1.8A ,USB 1.2A)
Raspberry Pi 5             5.0A (Pi 3.4A ,USB 1.6A) with PD (Power Delivery) 3.1 support
Raspberry Pi Zero          1.2A (Pi 0.7A ,USB 0.5A)
Raspberry Pi Zero W        1.2A (Pi 0.7A ,USB 0.5A)
Raspberry Pi Zero 2 W      2A
Ref.: https://github.com/raspberrypi/documentation/blob/develop/documentation/asciidoc/computers/raspberry-pi/power-supplies.adoc ## USB power And this is approximate numbers.
Model                  Max power output of USB ports
-----                  -----------------------------
Raspberry Pi Zero, 1   500mA per port
Raspberry Pi 2, 3, 4   1200mA total across all ports
Raspberry Pi 5         500mA if using a ~3A supply, 1600mA if using a 5A supply with PD 3.1 support
Ref.: https://github.com/raspberrypi/documentation/blob/develop/documentation/asciidoc/computers/raspberry-pi/usb-bus-on-raspberry-pi.adoc
oops.se
July 14, 2024, 20:50

32-bit or 64-bit OS (Operating System)?

## Hardware support Raspberry Pi 1, 2 and Zero supports ONLY 32 bit Raspberry Pi 3, 4, 5 and Zero 2 WW supports 64 bit and 32 bit ## There are several articles written on this topic. Raspberry Pi OS 64-bit vs 32-bit (Beginner’s perspective) https://techexplorations.com/guides/rpi/begin/rpi-os-32bit-vs-64bit Raspberry Pi OS 64-bit vs 32-bit (Which One To Install?) https://raspberrytips.com/raspberry-pi-os-64-bits-vs-32-bits Raspberry Pi OS 32-bit vs. 64-bit Performance https://www.phoronix.com/review/raspberrypi-32bit-64bit Further Investigating The Raspberry Pi 32-bit vs. 64-bit Performance https://www.phoronix.com/review/raspberrypi-os-64bit
oops.se
July 14, 2024, 20:50

Windows - Read ext4 linux filesystem from the SD card on Windows

If you need to read data from a SD card that has an Raspberry Pi OS on it only one partition is visible for a Windows computer by default. This is because Windows by default only can read NTFS and FAT file systems and Raspberry Pi OS uses ext (extended) file system. To come around this Windows needs something that can understand the ext file system. ### Example of ext file system programs or drivers: - https://www.diskinternals.com/linux-reader/ (Program) Free version can only read ext filesystem. - https://sourceforge.net/projects/ext2read/ (Program) Free - https://sourceforge.net/projects/ext2fsd/ (Driver) Free
oops.se
July 14, 2024, 20:50

Bookworm - Connect to Wi-Fi from CLI

Run sudo raspi-config Select 1. System Options And then S1. Wireless LAN And enter your Wi-Fi credentials, SSID and password. To check if there is a current Wi-Fi connection run nmcli connection show and if you have a row ending with wlan0 that is your current Wi-Fi connection.
oops.se
July 14, 2024, 20:50

First steps after installing the Raspberry Pi OS (Lite)

# Connect to your system remotely (SSH) This guide will cover how to connect to a Raspberry Pi OS Lite remotely after first boot. ## Requirement - SSH software (Only Windows) Example: putty - IP scanner (Only Windows) Example: Angry IP scanner, FING In this guide <> is used to indicate when you need to enter your values that you entered in Raspberry Pi Imager. When you created the Raspberry Pi OS Lite SD card (I assume that you use Raspberry Pi Imager) you also configure a hostname and a user and password. Be sure to enable SSH Service in Raspberry Pi Imager. See https://discord.com/channels/818384379197784084/1193923435789824050 ## Step one Open a "Command Prompt" or "Terminal" on your computer and type ping <hostname of your Pi>. Windows: If you get a reply, open a SSH client (putty or similar) and start a new session of the type SSH and as IP/Host name type in the name you gave your Raspberry Pi and press enter. Linux/MAC: Open a terminal and type ssh <Pi username>@<hostname of your Pi>. ## If step one fails. If you fail to ping your Raspberry Pi there are two choices: 1. Check your router and check for DHCP leases and see if your Raspberry Pi appears in that table. 2. Install a IP scanner and scan your network for your Raspberry Pi ## If above also fails If that doesn't work, connect a display and keyboard to your Raspberry Pi.
oops.se
July 14, 2024, 20:50

`motd` with some essential info

# Neofetch as motd (Message of the day) Install neofetch sudo apt install neofetch Update Neofetch to version Neofetch 7.2.8 that has CPU temp feature that works on Raspberry Pi.
wget https://raw.githubusercontent.com/LanikSJ/neofetch/master/neofetch
chmod +x neofetch
sudo chown root:root /usr/bin/neofetch
sudo mv neofetch /usr/bin/neofetch
## Delete the default motd sudo mv /etc/motd /etc/motd.org ## Create a neofetch.sh in /etc/profile.d Edit sudo nano /etc/profile.d/neofetch.sh An past the text below into /etc/profile.d/neofetch.sh
# neofetch as Message Of The Day (motd)
export TEXTDOMAIN=Linux-PAM
. gettext.sh
neofetch
## Change ownership of neofetch.sh to root sudo chown root:root /etc/profile.d/neofetch.sh ## Change SSH Server config In /etc/ssh/sshd_config replace or add the string #PrintLastLog yes with PrintLastLog no ## Tweaking the neofetch config file First you need to run neofetch, neofetch to create a default configuration file. Then edit to your liking, nano /home/<user>/.config/neofetch/config.conf ## CPU temperature Change cpu_temp="off" to cpu_temp="C". This needs Neofetch 7.2.8 ## Insert this to show the outdoor temperature:
   # Replace "Stockholm" with your city
   prin "Weather" "$(curl wttr.in/Sstockholm?0?q?T | awk '/°(C|F)/ {printf $(NF-1) $(NF) " ("a")"} /,/ {a=$0}')"
## Replace automatic with Raspbian as Raspberry Pi OS (64-bit) is detected as "Debian".
ascii_distro="Raspbian"
When you log in with SSH the next time you will be grated with a nice "Raspberry Pi" info.
k9t33n
July 14, 2024, 20:51

Installing an OS

# The imager The imager is what we usually use to install an OS to our Raspberry Pi's. firstly make sure that you have the most up to date imager, if you are unsure simply uninstall and reinstall it from the [official download site](https://www.raspberrypi.com/software/). then continue with the step by step guide below.
oops.se
July 14, 2024, 20:51

Raspberry Pi 4 - Power supply

The Raspberry Pi 15W USB-C Power Supply is designed to power Raspberry Pi 4 and Raspberry Pi 400 computers. https://www.raspberrypi.com/products/type-c-power-supply/ ## Specification Input: 96-264V AC Output: 5.1V 3.0A DC Connector: USB-C Cable: 1.5m 18 AWG An in-depth article about Power supply vs Chargers https://thepihut.com/blogs/raspberry-pi-tutorials/how-do-i-power-my-raspberry-pi
oops.se
July 14, 2024, 20:52

Raspberry Pi 5 - Power supply

The Raspberry Pi 5 is a 27 Watt and 5 volt power supply with PD (Power Delivery) support. https://www.raspberrypi.com/products/27w-power-supply/ ## Specification Input: 100 – 240Vac Output: 5.1V, 5A; 9V, 3A; 12V, 2.25A; 15V, 1.8A (Power Delivery) Connector: USB-C Cable: 1.2m 17AWG
oops.se
July 14, 2024, 20:49

CLI tips

## TAB completion. tab - Press tab to complete a command or directory tab tab tab - If there are several commands that begins with the same letters then by pressing tab a couple of times will show a list of the similar commands/directories To test this press t and then tab tab tab and you get a list, press i and tab tab tab, see how the list get shorter, press m and tab tab tab it will now change the text to time but after the second and third tab you will see the other matches for time ## Clear the screen crtl + l - Clear screen ## Get back to your home directory cd - Just cd without options or cd ~ will get you home ## Is the command available or do I need to install it? which <command> - It will show if the command is available and where it is in the directory structure whereis <command> - An alternative to which
oops.se
July 14, 2024, 20:52

Measure USB devices power consumption

This command will monitor USB devices power consumption continuously and refresh every second. To stop monitoring press ctrl + c sudo watch -n1 'lsusb -v|egrep "^Bus|MaxPower"' If you just wish to show the values use: sudo lsusb -v|egrep "^Bus|MaxPower"
oops.se
July 14, 2024, 20:52

Bookworm - Configure a Wi-Fi connection to a Wi-Fi network from CLI

To complete a command or show values press the TAB key twice and that is showed as [TAB][TAB]. To indicate where you need to input your Wi-Fi network credentials is indicated with <>, ex.: <wifi-ssid>. Replace the text <wifi-ssid> with your Wi-Fi network name (SSID) and <network-password> with your WiFis password. sudo nmcli radio wifi on sudo nmcli device wifi connect up <wifi-ssid> password "<network-password>" To view if a network is already configured type: sudo nmcli device wifi connect[TAB][TAB] or sudo nmcli device wifi list
oops.se
July 14, 2024, 20:52

Bookworm - Static IP address from CLI

## Static IP in Raspberry Pi OS "BookWorm" There is two ways to change the IP to static in Raspberry Pi OS "BookWorm", with CLI (nmcli) or a text GUI app (nmtui). This guide will only cover nmcli ## The nmcli way To get the current values, and write them down before proceeding: ip a - Shows the current IP adress. route -n - Shows the default gateway. nmcli device show | grep 'IP4.DNS' - Shows the current DNS Server. ## 1. To get the UUID for the connection you want to set a static IP to sudo nmcli con show ## 2. Replace <UUID> with the UUID from the command above in the following command:
sudo nmcli con mod <UUID> ipv4.addresses <Static IP>/<Subnet mask>
sudo nmcli con mod <UUID> ipv4.gateway <IP to gateway>
sudo nmcli con mod <UUID> ipv4.dns "<IP to DNS server>"
sudo nmcli con mod <UUID> ipv4.method manual

sudo nmcli con up <UUID>
And enter the values where there is a text enclosed in <>. ### Example:
sudo nmcli con mod 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e ipv4.addresses 192.168.111.21/24
sudo nmcli con mod 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e ipv4.gateway 192.168.111.1
sudo nmcli con mod 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e ipv4.dns "192.168.111.1"
sudo nmcli con mod 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e ipv4.method manual

sudo nmcli con up 911ac370-dc51-3d5d-a92e-d9bb1eafcb9e