Code: Select all
pi@raspberrypi:~ $ ls /dev/i2c* /dev/spi*
ls: cannot access '/dev/spi*': No such file or directory
/dev/i2c-1 /dev/i2c-2
pi@raspberrypi:~ $
Moderators: adafruit_support_bill, adafruit
Code: Select all
pi@raspberrypi:~ $ ls /dev/i2c* /dev/spi*
ls: cannot access '/dev/spi*': No such file or directory
/dev/i2c-1 /dev/i2c-2
pi@raspberrypi:~ $
This should work, if you reboot after.I have tried turning SPI on and off from raspi-config with the same results.
Code: Select all
ls /dev/i2c* /dev/spi*
Code: Select all
Last login: Thu Jan 12 18:52:30 2023 from 192.168.8.178
pi@raspberrypi:~ $ ls /dev/i2c* /dev/spi*
/dev/i2c-1 /dev/i2c-2
/dev/spi:
pi@raspberrypi:~ $
Code: Select all
Last login: Thu Jan 12 20:02:12 2023 from 192.168.8.178
pi@raspberrypi:~ $ python3 blinkatest.py
Hello blinka!
Digital IO ok!
I2C ok!
Traceback (most recent call last):
File "/home/pi/blinkatest.py", line 16, in <module>
spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)
File "/usr/local/lib/python3.9/dist-packages/busio.py", line 301, in __init__
self._spi = _SPI(portId)
File "/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 25, in __init__
self._spi = spi.SPI(device=(portid, 0))
File "/usr/local/lib/python3.9/dist-packages/Adafruit_PureIO/spi.py", line 167, in __init__
raise IOError("{} does not exist".format(device))
OSError: /dev/spidev0.0 does not exist
pi@raspberrypi:~ $
I then created a folder /dev/spi and now I get this.
Code: Select all
cat /boot/config.txt | grep spi
Code: Select all
Last login: Thu Jan 12 21:27:40 2023 from 192.168.8.178
pi@raspberrypi:~ $ cat /boot/config.txt | grep spi
dtparam=spi=on
dtparam=spi=on
dtparam=spi=on
pi@raspberrypi:~ $
Code: Select all
Last login: Thu Jan 12 21:29:43 2023 from 192.168.8.178
pi@raspberrypi:~ $ ls /dev/i2c* /dev/spi*
ls: cannot access '/dev/spi*': No such file or directory
/dev/i2c-1 /dev/i2c-2
pi@raspberrypi:~ $
Code: Select all
pi@raspberrypi:~ $ sudo python3 stats.py
Traceback (most recent call last):
File "stats.py", line 97, in <module>
DNSQUERIES = data['dns_queries_today']
TypeError: list indices must be integers or slices, not str
Code: Select all
import json
import requests
api_url = 'http://localhost/admin/api.php'
r = requests.get(api_url)
data = json.loads(r.text)
print(data)
Code: Select all
pi@raspberrypi:~ $ sudo python3 test3.py
[]
This is a new issue that has recently cropped up due to changes with Pi-Hole now requiring authentication to access the API data (which is used for the stats info). It took a while to figure this out and the stats.py code and guide will need to be updated (this is in works). If you're willing to make some minor changes to the stats.py code, there is a fix you can try here:Pi Hole is running fine but the API to the Pi Hole is not working.