I am trying to setup the Pimoroni Pan Tiolt Hat on a Raspberry Pi 5 running 64 bit Bookworm. After installing the library and examples from //github.com/pimoroni/pantilt-hat in a virtual environment I try to launch pantiltweb.py. The errors I receive complain about python3-smbus, but this is installed.
apt-cache policy python3-smbus
python3-smbus:
Installed: 4.3-2+b3
Candidate: 4.3-2+b3
Version table:
*** 4.3-2+b3 500
500 Index of /debian bookworm/main arm64 Packages
100 /var/lib/dpkg/status
And the errors I receive running the example:
File “/home/steve/pantilt-hat/examples/pantiltweb/pantiltweb.py”, line 29, in api
pantilthat.tilt(angle)
File “/home/steve/venv/lib/python3.11/site-packages/pantilthat/pantilt.py”, line 496, in servo_two
self.setup()
File “/home/steve/venv/lib/python3.11/site-packages/pantilthat/pantilt.py”, line 77, in setup
raise ImportError(“This library requires python3-smbus\nInstall with: sudo apt-get install python3-smbus”)
ImportError: This library requires python3-smbus
and now I have new errors. I get the same errors whether I launch the application with or without sudo rights,
Please advise.
127.0.0.1 - - [01/Dec/2024 13:40:44] “GET /api/tilt/89 HTTP/1.1” 500 -
Traceback (most recent call last):
File “/home/steve/venv/lib/python3.11/site-packages/flask/app.py”, line 1536, in call
return self.wsgi_app(environ, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/steve/venv/lib/python3.11/site-packages/flask/app.py”, line 1514, in wsgi_app
response = self.handle_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/steve/venv/lib/python3.11/site-packages/flask/app.py”, line 1511, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/steve/venv/lib/python3.11/site-packages/flask/app.py”, line 919, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/steve/venv/lib/python3.11/site-packages/flask/app.py”, line 917, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File “/home/steve/venv/lib/python3.11/site-packages/flask/app.py”, line 902, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/steve/pantilt-hat/examples/pantiltweb/pantiltweb.py”, line 29, in api
pantilthat.tilt(angle)
File “/home/steve/venv/lib/python3.11/site-packages/pantilthat/pantilt.py”, line 496, in servo_two
self.setup()
File “/home/steve/venv/lib/python3.11/site-packages/pantilthat/pantilt.py”, line 80, in setup
self._set_config()
File “/home/steve/venv/lib/python3.11/site-packages/pantilthat/pantilt.py”, line 118, in _set_config
self._i2c_write_byte(self.REG_CONFIG, config)
File “/home/steve/venv/lib/python3.11/site-packages/pantilthat/pantilt.py”, line 209, in _i2c_write_byte
raise IOError(“Failed to write byte”)
OSError: Failed to write byte
You can close this issue. The problem was caused by the fact that the hat was not fully engaged in the PI GPIO connector. See this thread: OS error :Failed to write byte