Test on Raspberry Pi 5B, I use this code works fine:after run:rise exception below:
I try change to:works fine, refer 'rpi-hardware-pwm' document:
https://pypi.org/project/rpi-hardware-pwm/
Code:
from rpi_hardware_pwm import HardwarePWMpwm0 = HardwarePWM(pwm_channel = 0, hz = 1000, chip = 2)
Code:
sudo apt upgrade
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)
https://pypi.org/project/rpi-hardware-pwm/
which something changed in the OS packages upgrade?For Rpi 1,2,3,4, use chip=0; For Rpi 5, use chip=2
Statistics: Posted by water_5 — Fri Apr 04, 2025 8:32 pm — Replies 0 — Views 34