Quantcast
Viewing latest article 2
Browse Latest Browse All 4305

Python • PWM output problem after upgrade OS.

Test on Raspberry Pi 5B, I use this code works fine:

Code:

from rpi_hardware_pwm import HardwarePWMpwm0 = HardwarePWM(pwm_channel = 0, hz = 1000, chip = 2)
after run:

Code:

sudo apt upgrade
rise exception below:
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
pwm0 = HardwarePWM(pwm_channel = 0, hz = 1000, chip = 2)
File "/home/mc3/.local/lib/python3.13/site-packages/rpi_hardware_pwm/__init__.py", line 52, in __init__
raise HardwarePWMException(
"Need to add 'dtoverlay=pwm-2chan' to /boot/config.txt and reboot"
)
rpi_hardware_pwm.HardwarePWMException: Need to add 'dtoverlay=pwm-2chan' to /boot/config.txt and reboot

I try change to:

Code:

pwm0 = HardwarePWM(pwm_channel = 0, hz = 1000, chip = 0)
works fine, refer 'rpi-hardware-pwm' document:
https://pypi.org/project/rpi-hardware-pwm/
For Rpi 1,2,3,4, use chip=0; For Rpi 5, use chip=2
which something changed in the OS packages upgrade?

Statistics: Posted by water_5 — Fri Apr 04, 2025 8:32 pm — Replies 0 — Views 34



Viewing latest article 2
Browse Latest Browse All 4305

Trending Articles