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 -usudo 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-perfsudo apt autoremove -y modem* cups* pulse* avahi* triggerhappy*sudo apt-get install blueman pi-bluetooth minicom bluez bluez-toolssudo 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-devsudo 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 -usudo nano /boot/firmware/config.txtdtparam=act_led_trigger=mmc0dtparam=act_led_activelow=on#dtparam=audio=onarm_freq=1300over_voltage=4sudo nano /boot/firmware/cmdline.txtisolcpus=2,3 hinzufügen sudo dphys-swapfile swapoff/etc/dphys-swapfile and modify the variable CONF_SWAPSIZE : CONF_SWAPSIZE=1024 sudo nano /etc/dphys-swapfilesudo dphys-swapfile swaponsudo rebootsudo mkdir /mnt/ramdisksudo mount -t tmpfs -o size=50M tmpfs /mnt/ramdiskdf -hsudo nano /etc/fstabtmpfs /mnt/ramdisk tmpfs defaults,size=50M 0 0systemctl list-timerssudo systemctl stop apt-daily.timer && sudo systemctl disable apt-daily.timersudo systemctl stop apt-daily-upgrade.timer && sudo systemctl disable apt-daily-upgrade.timersudo systemctl stop man-db.timer && sudo systemctl disable man-db.timersudo systemctl stop dpkg-db-backup.timer && sudo systemctl disable dpkg-db-backup.timersudo apt autoremove -y modem* cups* pulse* avahi* triggerhappy*sudo passwd -d pisudo nano /etc/ssh/sshd_configPermitEmptyPasswords yes einfügensudo rebootEs 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 offsudo 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>&1iwconfig → Power Management:offsudo nmcli device connect wlan0 sudo ip link set wlan0 upBluetooth wird für zwei Dinge verwendet:
sudo systemctl status bluetoothsudo systemctl enable hciuart.service sudo systemctl enable bluetooth.serviceZiel 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.serviceExecStart=/usr/lib/bluetooth/bluetoothd -CExecStartPost=/usr/bin/sdptool add SPsudo systemctl daemon-reloadsudo systemctl restart bluetooth.servicesudo systemctl status bluetooth Jun 27 04:05:43 Make-seKwaI sdptool[16038]: Serial Port service registeredbluetoothctldiscoverable 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.servicesudo systemctl start rfcomm.servicesudo systemctl status rfcomm.serviceHinweis:
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-devtar -xzf mpdecimal-4.0.1.tar.gz && cd mpdecimal-4.0.1./configure && make -j3 && sudo make install && sudo ldconfigtar 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-optimizationsmake -j2sudo 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 sekwaipython -m venv --copies _envRsource _envR/bin/activatepython -m pip install --upgrade pippip install spidev build psutil fastapi “uvicorn[standard]” jinja2Damit 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.13python3.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