I've been doing a lot of reading but have not found any answers to my question which is.... How can I fix this script? RE: EP-0152
#!/usr/bin/python3
import RPi.GPIO as GPIO
import time
import subprocess
GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.OUT)
pwm = GPIO.PWM(14,100)
print("\nPress Ctrl+C to quit \n")
dc = 0
pwm.start(dc)
try:
while True:
temp = subprocess.getoutput("vcgencmd measure_temp|sed 's/[^0-9.]//g'")
if round(float(temp)) >= 45:
dc = 100
pwm.ChangeDutyCycle(dc)
print("CPU Temp:",float(temp)," Fan duty cycle:",dc)
time.sleep(180.0)
if round(float(temp)) >= 40:
dc = 85
pwm.ChangeDutyCycle(dc)
print("CPU Temp:",float(temp)," Fan duty cycle:",dc)
time.sleep(120.0)
else:
dc = 70
pwm.ChangeDutyCycle(dc)
print("CPU Temp:",float(temp)," Fan duty cycle:",dc)
time.sleep(60.00)
except KeyboardInterrupt:
pwm.stop()
GPIO.cleanup()
print("Ctrl + C pressed -- Ending program")
I receive multiple errors while trying to run this, such as
error: 'GPIO not allocated'
lgpio.py, line 458+
Any help would be very much appreciated.