I am wiring MCP3008 to a voltage divider to get the information of the photoresister. However, I am using resistors to replace photoresister since they are not ready yet. I have fixed Adafruit_MCP3008 AND Adafruit_GPIO.GPIO. However, just as I thought everything will be ok, there is this issue coming up when I was about to run the program. Please let me know what the solution is. I am using Python3 bookworm. pi 4b.
Traceback (most recent call last):
File "/home/ricky/Desktop/moduleç»ä¹ /module3.py", line 62, in <module>
mcp = Adafruit_MCP3008.MCP3008(clk=CLK,cs=CS,miso=MISO,mosi=MOSI,gpio=gpio_adapter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/Adafruit_MCP3008-1.0.2-py3.11.egg/Adafruit_MCP3008/MCP3008.py", line 42, in __init__
File "/usr/local/lib/python3.11/dist-packages/Adafruit_GPIO-1.0.4-py3.11.egg/Adafruit_GPIO/SPI.py", line 165, in __init__
File "/usr/local/lib/python3.11/dist-packages/Adafruit_GPIO-1.0.4-py3.11.egg/Adafruit_GPIO/GPIO.py", line 187, in setup
File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 704, in setup
initial = _check(lgpio.gpio_read(_chip, gpio))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/lgpio.py", line 903, in gpio_read
return _u2i(_lgpio._gpio_read(handle&0xffff, gpio))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i
raise error(error_text(v))
lgpio.error: 'GPIO not allocated'
Statistics: Posted by ricky2777 — Wed Jan 22, 2025 5:19 am