Von English mit KI übersetzt ·
Emilys Hinweis ist ein Teil davon. Der Rest ist das UART-Durcheinander beim Pi 3, das alle erwischt.Der Pi 3/4/Zero W hat zwei UARTs. ttyAMA0 ist der PL011, der gute mit eigenem Takt. ttyS0 ist der Mini-UART, dessen Baudrate aus dem Takt des VPU-Kerns abgeleitet wird. Wenn sich der Kerntakt ändert, driftet die Baudrate, und genau dann bekommst du deine CRC-Fehler im Verhältnis eins zu fünf. Bei diesen Modellen ist der PL011 standardmäßig mit dem integrierten Bluetooth verbunden, und der GPIO-Header bekommt den Mini-UART. /dev/serial0 ist ein Alias, der immer auf denjenigen zeigt, der auf GPIO14/15 liegt.Je nach Konfiguration hast du also entweder mit dem Bluetooth-Chip oder mit dem Mini-UART gesprochen. Gib den PL011 dem Header zurück:
# /boot/firmware/config.txt (Bookworm)
enable_uart=1
dtoverlay=disable-bt
sudo systemctl disable hciuart
# und console=serial0,115200 aus /boot/firmware/cmdline.txt entfernen
sudo reboot
Öffne dann /dev/serial0 in deinem Skript, damit es auch bei einem Wechsel auf ein anderes Modell weiter funktioniert. Du verlierst das integrierte Bluetooth, was du in einer Zählerstand-Box aber nicht vermissen wirst.Falls du Bluetooth brauchst, wäre die andere Option core_freq=250, um den Takt für den Mini-UART festzusetzen, aber ich hätte lieber den PL011.
Emily’s bit is part of it. The rest is the Pi 3 UART shuffle, which catches everyone.
The Pi 3/4/Zero W have two UARTs. ttyAMA0 is the PL011, the good one with its own clock. ttyS0 is the mini UART, whose baud rate is derived from the VPU core clock, so when the core clock moves the baud drifts and you get exactly your one-in-five CRC errors. On those models the PL011 is wired to the onboard Bluetooth by default and the GPIO header gets the mini UART. /dev/serial0 is an alias that always points at whichever one is on GPIO14/15.
So depending on your config you were either talking to the Bluetooth chip or to the mini UART. Give the PL011 back to the header:
# /boot/firmware/config.txt (Bookworm)
enable_uart=1
dtoverlay=disable-bt
sudo systemctl disable hciuart
# and remove console=serial0,115200 from /boot/firmware/cmdline.txt
sudo reboot
Then open /dev/serial0 in your script, so it keeps working if you move to another model. You lose onboard Bluetooth, which on a meter-reading box you don’t miss.
If you need Bluetooth, the other option is core_freq=250 to pin the clock for the mini UART, but I’d rather have the PL011.

