I recently upgraded the OS on my pi4b (Latest version of Bookworm) and have been trying to get the lgpio module to control the fan. It works with simple switching on and off but I get no output from the pwm and no error? I have reduced the code to the sample below but still no success.
Any suggestions?
import lgpio
import time
# Configuration
FAN = 12 # pin used to drive PWM fan
FREQ = 100
h = lgpio.gpiochip_open(0)
# Turn the fan on
lgpio.tx_pwm(h, FAN, FREQ, 100)
time.sleep(10)
# Turn the fan off
lgpio.tx_pwm(h, FAN, FREQ, 0)
"Any suggestions?"
https://abyz.me.uk/lg/py_lgpio.html#gpio_claim_output
Code:
import lgpioimport time# ConfigurationFAN = 12 # pin used to drive PWM fanFREQ = 100h = lgpio.gpiochip_open(0)lgpio.gpio_claim_output(h, FAN)# Turn the fan onlgpio.tx_pwm(h, FAN, FREQ, 100)time.sleep(5)lgpio.tx_pwm(h, FAN, FREQ, 40)time.sleep(5)# Turn the fan offlgpio.tx_pwm(h, FAN, FREQ, 0)
Statistics: Posted by B.Goode — Tue Dec 10, 2024 3:45 pm