sudo apt update && sudo apt upgrade -y && sudo apt install -y git git-lfs silversearcher-ag wavemon hexedit sudoku tcpdump iptraf mc htop dcfldd nano usbutils openvpn ranger tldr ncdu can-utils multitail fd-find lsof x11vnc terminator minicom cutecom joystick jstest-gtk i2c-tools speedtest-cli iotop fio ir-keytable curl inxi stress-ng && mkdir -p ~/.local/share && tldr -u
sudo apt install -y thonny cutecom sqlitebrowser build-essential pkg-config libusb-1.0-0-dev cmake make gcc python3-dev libhidapi-dev python3-virtualenv python3-tk lm-sensors libopenblas-dev linux-perf
sudo apt autoremove -y modem* cups* pulse* avahi* triggerhappy*
sudo apt-get install blueman pi-bluetooth minicom bluez bluez-tools
sudo apt update && sudo apt install -y build-essential zlib1g-dev libexpat1-dev libxml2-dev libxslt1-dev libpq-dev libjpeg-dev libpng-dev libfreetype6-dev pkg-config checkinstall python3-dev libssl-dev libbz2-dev libffi-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev liblzma-dev libgdbm-dev libdb5.3-dev uuid-dev tk-dev libzstd-dev
sudo apt update && sudo apt upgrade -y && sudo apt install -y git git-lfs silversearcher-ag wavemon hexedit sudoku tcpdump iptraf mc htop dcfldd nano usbutils ranger tldr ncdu can-utils multitail fd-find lsof minicom cutecom joystick i2c-tools speedtest-cli iotop fio ir-keytable curl inxi stress-ng build-essential pkg-config libusb-1.0-0-dev cmake make gcc python3-dev libhidapi-dev python3-virtualenv python3-tk lm-sensors libopenblas-dev linux-perf pi-bluetooth bluez bluez-tools zlib1g-dev libexpat1-dev libxml2-dev libxslt1-dev libzstd-dev libpq-dev libjpeg-dev libpng-dev libfreetype6-dev checkinstall libssl-dev libbz2-dev libffi-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev liblzma-dev libgdbm-dev libdb5.3-dev uuid-dev tk-dev && sudo apt autoremove -y modem* cups* pulse* avahi* triggerhappy* && mkdir -p ~/.local/share && tldr -u
sudo nano /boot/firmware/config.txt
dtparam=act_led_trigger=mmc0
dtparam=act_led_activelow=on
#dtparam=audio=on
arm_freq=1300
over_voltage=4
sudo nano /boot/firmware/cmdline.txt
isolcpus=2,3
hinzufügen sudo dphys-swapfile swapoff
/etc/dphys-swapfile
and modify the variable CONF_SWAPSIZE : CONF_SWAPSIZE=1024
sudo nano /etc/dphys-swapfile
sudo dphys-swapfile swapon
sudo reboot
sudo mkdir /mnt/ramdisk
sudo mount -t tmpfs -o size=50M tmpfs /mnt/ramdisk
df -h
sudo nano /etc/fstab
tmpfs /mnt/ramdisk tmpfs defaults,size=50M 0 0
systemctl list-timers
sudo systemctl stop apt-daily.timer && sudo systemctl disable apt-daily.timer
sudo systemctl stop apt-daily-upgrade.timer && sudo systemctl disable apt-daily-upgrade.timer
sudo systemctl stop man-db.timer && sudo systemctl disable man-db.timer
sudo systemctl stop dpkg-db-backup.timer && sudo systemctl disable dpkg-db-backup.timer
sudo apt autoremove -y modem* cups* pulse* avahi* triggerhappy*
sudo passwd -d pi
sudo nano /etc/ssh/sshd_config
PermitEmptyPasswords yes
einfügensudo reboot
Es kommt beim Raspberry Pi Zero 2W öfter vor, dass das WLAN einfach aus geht. Scheinbar ein Problem mit dem Powermanagement …
sudo iw dev wlan0 set power_save off
sudo nmcli con mod preconfigured wifi.powersave disable
oder …sudo crontab -e
@reboot /usr/sbin/iw wlan0 set power_save off > /home/<user>/power_save_log.txt 2>&1
iwconfig
→ Power Management:offsudo nmcli device connect wlan0
sudo ip link set wlan0 up
Bluetooth wird für zwei Dinge verwendet:
sudo systemctl status bluetooth
sudo systemctl enable hciuart.service
sudo systemctl enable bluetooth.service
Ziel ist es auf dem Raspberry Pi eine serielle Schnittstelle zu haben auf die man sich von einem anderen Rechner aus verbinden kann
sudo nano /etc/systemd/system/dbus-org.bluez.service
ExecStart=/usr/lib/bluetooth/bluetoothd -C
ExecStartPost=/usr/bin/sdptool add SP
sudo systemctl daemon-reload
sudo systemctl restart bluetooth.service
sudo systemctl status bluetooth
Jun 27 04:05:43 Make-seKwaI sdptool[16038]: Serial Port service registered
bluetoothctl
discoverable on
[CHG] Device XX:XX:XX:XX:XX:XX Paired: yes
Damit wir eine Verbindung vom Windows zum Pi aufbauen können muss der Pi auf eine eingehende SPP Verbindung horchen. Das geht manuell mittels
sudo rfcomm watch hci0
Das Device /dev/rfcomm0
wird dann erstellt wenn eine Verbindung von Windows aufgebaut wird. Damit das aber autoamtisch geht muss man einen extra Dienst einrichten:
sudo nano /etc/bluetooth/rfcomm.conf
rfcomm0 { bind yes; channel 1; comment "Serial Port for Windows Connection";
sudo nano /etc/systemd/system/rfcomm.service
[Unit] Description=RFCOMM Service After=bluetooth.service Requires=bluetooth.service [Service] ExecStart=/usr/bin/rfcomm watch hci0 1 Restart=always [Install] WantedBy=multi-user.target
sudo systemctl enable rfcomm.service
sudo systemctl start rfcomm.service
sudo systemctl status rfcomm.service
Hinweis:
Scheinbar gibt es Probleme mit .Net Anwendungen. Die Verbindung wird aufgebaut, aber sofort wieder geschlossen. Mit MobaXTerm, Putty oder auch Python passiert das nicht.
* minicom -b 9600 -o -D /dev/rfcomm0
auf dem Pi starten
import serial import time from datetime import datetime def send_serial_messages(port): try: # Serielle Verbindung öffnen ser = serial.Serial( port=port, baudrate=9600, # Standard-Baudrate, anpassen falls nötig timeout=1 ) # Kurze Pause, um die Verbindung zu stabilisieren time.sleep(2) print(f"Connected to {port}. Sending time and 'Hallo' every 2 seconds...") while True: # Aktuelle Zeit holen current_time = datetime.now().strftime("%H:%M:%S") # Zeit und "Hallo" als Nachricht zusammenstellen message = f"{current_time} Hallo\n" # Nachricht senden ser.write(message.encode('utf-8')) print(f"Sent: {message.strip()}") # 2 Sekunden warten time.sleep(2) except serial.SerialException as e: print(f"Error: Could not open port {port}: {e}") except KeyboardInterrupt: print("\nStopped by user.") ser.close() print("Serial connection closed.") except Exception as e: print(f"An error occurred: {e}") if 'ser' in locals(): ser.close() if __name__ == "__main__": # Port definieren port = "COM16" # Funktion aufrufen send_serial_messages(port)
sudo apt update && sudo apt install -y build-essential zlib1g-dev libexpat1-dev libxml2-dev libxslt1-dev libpq-dev libjpeg-dev libpng-dev libfreetype6-dev pkg-config checkinstall python3-dev libssl-dev libbz2-dev libffi-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev liblzma-dev libgdbm-dev libdb5.3-dev uuid-dev tk-dev
tar -xzf mpdecimal-4.0.1.tar.gz && cd mpdecimal-4.0.1
./configure && make -j3 && sudo make install && sudo ldconfig
tar zxvf Python-3.13.5.tgz && tar zxvf Python-3.14.0b4.tgz
cd ~/build/Python-3.13.5
cd ~/build/Python-3.14.0b4
./configure --enable-optimizations --disable-gil
./configure --enable-optimizations
make -j2
sudo make altinstall
3.13 GIL real 52m1.280s user 134m52.093s sys 4m6.572s
3.13 NO GIL real 71m22.295s user 153m6.204s sys 4m10.737s
3.14 NO GIL real 77m10.570s user 174m21.493s sys 5m35.768s
cd ~ && mkdor sekwai && cd sekwai
python -m venv --copies _envR
source _envR/bin/activate
python -m pip install --upgrade pip
pip install spidev build psutil fastapi “uvicorn[standard]” jinja2
Damit der Pi User die Rechte hat die Prozess Prio neu zu definieren braucht es folgendes:
sudo apt-get install libcap2-bin
--copies
sonst hat man nur Links auf Python !sudo setcap cap_sys_nice+ep _envR/bin/python3
sudo setcap cap_sys_nice+ep _envR/bin/python && sudo setcap cap_sys_nice+ep _envR/bin/python3 && sudo setcap cap_sys_nice+ep _envR/bin/python3.13
run with PYTHON_GIL=0
or -Xgil=0
PYTHON_GIL=1 python3.13
python3.13 -Xgil=1
(_envR) pi@Make-seKwaI:~/test $ python -Xgil=0 Python 3.13.5 experimental free-threading build (main, Jul 9 2025, 07:28:07) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> exit