APDS9960
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- usrnsf_ted
- Posts: 25
- Joined: Sun Dec 15, 2024 5:02 pm
APDS9960
Okay First Hi, I'm Ted, Im new to everything, R-Pi, Adafruit, these forums, linux, you name it I'm new to it. Except breathing I've been doing that for 60 years.
Now lets get to it.
Raspberry Pi 5
trying unsuccessfully to use virtual environment but I tried
goal - make function and explore features of the APDS9960
Actions taken:
in the virtual environment executed pip3 install adafruit-circuitpython-lis3dh
in the virtual environment executed pip3 install adafruit-circuitpython-apds9960
copied and tryed to run the example code in thonny
received errors
searched errors
executed commands above with sudo pip3 install ... --break-system-packages
tryed to run example code in thonny
------
------
example code
------
import board
import digitalio
from adafruit_apds9960.apds9960 import APDS9960
i2c = board.I2C()
int_pin = digitalio.DigitalInOut(board.D5)
int_pin.switch_to_input(pull=digitalio.Pull.UP)
apds = APDS9960(i2c)
apds.enable_proximity_interrupt = True
apds.proximity_interrupt_threshold = (0, 175)
apds.enable_proximity = True
while True:
if not int_pin.value:
print(apds.proximity)
apds.clear_interrupt()
------
current errors -
>>> %Run 9960.py
Traceback (most recent call last):
File "/home/Computer/Documents/Py_Programs/9960.py", line 6, in <module>
int_pin = digitalio.DigitalInOut(board.D5)
File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 197, in __init__
self.direction = Direction.INPUT
File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 227, in direction
self._pin.init(mode=Pin.IN)
File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/bcm283x/pin.py", line 40, in init
GPIO.setup(self.id, GPIO.IN)
RuntimeError: Cannot determine SOC peripheral base address
>>>
Any help would be most appreciated.
Now lets get to it.
Raspberry Pi 5
trying unsuccessfully to use virtual environment but I tried
goal - make function and explore features of the APDS9960
Actions taken:
in the virtual environment executed pip3 install adafruit-circuitpython-lis3dh
in the virtual environment executed pip3 install adafruit-circuitpython-apds9960
copied and tryed to run the example code in thonny
received errors
searched errors
executed commands above with sudo pip3 install ... --break-system-packages
tryed to run example code in thonny
------
------
example code
------
import board
import digitalio
from adafruit_apds9960.apds9960 import APDS9960
i2c = board.I2C()
int_pin = digitalio.DigitalInOut(board.D5)
int_pin.switch_to_input(pull=digitalio.Pull.UP)
apds = APDS9960(i2c)
apds.enable_proximity_interrupt = True
apds.proximity_interrupt_threshold = (0, 175)
apds.enable_proximity = True
while True:
if not int_pin.value:
print(apds.proximity)
apds.clear_interrupt()
------
current errors -
>>> %Run 9960.py
Traceback (most recent call last):
File "/home/Computer/Documents/Py_Programs/9960.py", line 6, in <module>
int_pin = digitalio.DigitalInOut(board.D5)
File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 197, in __init__
self.direction = Direction.INPUT
File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 227, in direction
self._pin.init(mode=Pin.IN)
File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/bcm283x/pin.py", line 40, in init
GPIO.setup(self.id, GPIO.IN)
RuntimeError: Cannot determine SOC peripheral base address
>>>
Any help would be most appreciated.
- adafruit_support_mike
- Posts: 68385
- Joined: Thu Feb 11, 2010 2:51 pm
Re: APDS9960
Just to check, have you also installed Blinka?
https://learn.adafruit.com/circuitpytho ... spberry-pi
That's our compatibility library for getting CircuitPython code to work on a RasPi.
https://learn.adafruit.com/circuitpytho ... spberry-pi
That's our compatibility library for getting CircuitPython code to work on a RasPi.
- usrnsf_ted
- Posts: 25
- Joined: Sun Dec 15, 2024 5:02 pm
Re: APDS9960
Went thru all the install instructions at the link both globally with the --break options. and in the virtual environment. then ran the hello blinka test code after a reboot.
This is the code and result.
---
---
Code
---
import board
import digitalio
import busio
print("Hello, blinka!")
# Try to create a Digital input
pin = digitalio.DigitalInOut(board.D4)
print("Digital IO ok!")
# Try to create an I2C device
i2c = busio.I2C(board.SCL, board.SDA)
print("I2C ok!")
# Try to create an SPI device
spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)
print("SPI ok!")
print("done!")
-------------
results
-------------
Hello, blinka!
Traceback (most recent call last):
File "/home/Computer/Documents/Py_Programs/blinkatest.py", line 8, in <module>
pin = digitalio.DigitalInOut(board.D4)
File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 197, in __init__
self.direction = Direction.INPUT
File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 227, in direction
self._pin.init(mode=Pin.IN)
File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/bcm283x/pin.py", line 40, in init
GPIO.setup(self.id, GPIO.IN)
RuntimeError: Cannot determine SOC peripheral base address
>>>
This is the code and result.
---
---
Code
---
import board
import digitalio
import busio
print("Hello, blinka!")
# Try to create a Digital input
pin = digitalio.DigitalInOut(board.D4)
print("Digital IO ok!")
# Try to create an I2C device
i2c = busio.I2C(board.SCL, board.SDA)
print("I2C ok!")
# Try to create an SPI device
spi = busio.SPI(board.SCLK, board.MOSI, board.MISO)
print("SPI ok!")
print("done!")
-------------
results
-------------
Hello, blinka!
Traceback (most recent call last):
File "/home/Computer/Documents/Py_Programs/blinkatest.py", line 8, in <module>
pin = digitalio.DigitalInOut(board.D4)
File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 197, in __init__
self.direction = Direction.INPUT
File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 227, in direction
self._pin.init(mode=Pin.IN)
File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/bcm283x/pin.py", line 40, in init
GPIO.setup(self.id, GPIO.IN)
RuntimeError: Cannot determine SOC peripheral base address
>>>
- usrnsf_ted
- Posts: 25
- Joined: Sun Dec 15, 2024 5:02 pm
Re: APDS9960
i2cdetect -y 1 returns a 39 at x=9, y=30
- usrnsf_ted
- Posts: 25
- Joined: Sun Dec 15, 2024 5:02 pm
Re: APDS9960
Here's a question - Am I creating my own issues?
I have read that some of these issues may be related to using a Pi 5.
It is not a deal breaker for me. I don't have to use a Pi 5.
If these problems would go away if I changed to some other version of Pi. I can do that.
Hell if I have to I can change to Arduino I've not used it before but I'm game to learn.
Im just trying to make a simple gadget that senses a colored light and presses a button when the light is anything but green. This should be a simple thing. And It has been anything but.
In fairness yes I have had to learn a lot of stuff and my current knowledge is apparently not up to the challenge. But gosh this seems harder than it should be...LOL
I have read that some of these issues may be related to using a Pi 5.
It is not a deal breaker for me. I don't have to use a Pi 5.
If these problems would go away if I changed to some other version of Pi. I can do that.
Hell if I have to I can change to Arduino I've not used it before but I'm game to learn.
Im just trying to make a simple gadget that senses a colored light and presses a button when the light is anything but green. This should be a simple thing. And It has been anything but.
In fairness yes I have had to learn a lot of stuff and my current knowledge is apparently not up to the challenge. But gosh this seems harder than it should be...LOL
- usrnsf_ted
- Posts: 25
- Joined: Sun Dec 15, 2024 5:02 pm
Re: APDS9960
Okay, searching the web, this seems to be an issue specifically with R-PI 5 and hardware changes relating to it. Has there been a reliable fix to make blinka work with R-PI 5 or do I need to shelf the pi-5 and move down to a pi-4b
- adafruit_support_mike
- Posts: 68385
- Joined: Thu Feb 11, 2010 2:51 pm
Re: APDS9960
We know Blinka works on the Pi5 though, so it isn't a flat-out incompatibility. The Pi5 does require some extra steps to get GPIO working though.
What output do you get from the command:
What output do you get from the command:
Code: Select all
ls /dev/i2c* /dev/spi*
- usrnsf_ted
- Posts: 25
- Joined: Sun Dec 15, 2024 5:02 pm
Re: APDS9960
First thank you thank you thank you for your help and responding.
Second, I have changed course slightly. I shelved the raspberry pi 5 and switched to a 4b
Fresh os install enabled all interfaces except VNC and 1wire
updated and upgraded
then went thru the blinka install in the virt env
got the no module named board error when running the blinka test code
so I ran the blinka install under sudo with the --break-system-packages option
BANG -
Blinka test code responds
----------
Hello, blinka!
Digital IO ok!
I2C ok!
SPI ok!
done!
-----------
so that's the farthest I have gotten so far --- Whoopi!!!
Now back to the 9960 and see if I can get it responding - I will let ya know
Second, I have changed course slightly. I shelved the raspberry pi 5 and switched to a 4b
Fresh os install enabled all interfaces except VNC and 1wire
updated and upgraded
then went thru the blinka install in the virt env
got the no module named board error when running the blinka test code
so I ran the blinka install under sudo with the --break-system-packages option
BANG -
Blinka test code responds
----------
Hello, blinka!
Digital IO ok!
I2C ok!
SPI ok!
done!
-----------
so that's the farthest I have gotten so far --- Whoopi!!!
Now back to the 9960 and see if I can get it responding - I will let ya know
- adafruit_support_mike
- Posts: 68385
- Joined: Thu Feb 11, 2010 2:51 pm
Re: APDS9960
Swapping to another board is a good choice if you have one handy. Glad to hear it's working for you so far.
- usrnsf_ted
- Posts: 25
- Joined: Sun Dec 15, 2024 5:02 pm
Re: APDS9960
/dev/i2c-1 /dev/i2c-20 /dev/i2c-21 /dev/spidev0.0 /dev/spidev0.1
- adafruit_support_mike
- Posts: 68385
- Joined: Thu Feb 11, 2010 2:51 pm
Re: APDS9960
Okay, that means the device files are present.
Try walking through the manual installation steps and see if any of those give a result other than "already did that".
I'm going to check with the folks who handle the Blinka code and see if there are any issues with the most recent versions of the Pi5 that I haven't seen yet.
Try walking through the manual installation steps and see if any of those give a result other than "already did that".
I'm going to check with the folks who handle the Blinka code and see if there are any issues with the most recent versions of the Pi5 that I haven't seen yet.
- usrnsf_ted
- Posts: 25
- Joined: Sun Dec 15, 2024 5:02 pm
Re: APDS9960
I have the apds9960 up and running on the pi 4
Thank you for all your help! You have been amazing.
I am sure I will need more help before this project is complete.
But thank you for your help so far.
Thank you for all your help! You have been amazing.
I am sure I will need more help before this project is complete.
But thank you for your help so far.
- adafruit_support_mike
- Posts: 68385
- Joined: Thu Feb 11, 2010 2:51 pm
Re: APDS9960
No worries. Feel free to post again if you run into a problem, or just an interesting discovery you'd like to explore further.
- adafruit_support_carter
- Posts: 31653
- Joined: Tue Nov 29, 2016 2:45 pm
Re: APDS9960
I think you ran into a known issue that is Pi5 specific. The current instructions for the initial install of Blinka should have worked. However, as soon as any additional Circuitpython library gets pip installed, it will break again. This error is the main indicator of running into this issue:
Here is the related issue that has been opened for this:
https://github.com/adafruit/Adafruit_Blinka/issues/907
One potential fix is to manually pip uninstall the library module that is causing the issue:
(run that with the Blinka virtual environment active)
Code: Select all
RuntimeError: Cannot determine SOC peripheral base address
https://github.com/adafruit/Adafruit_Blinka/issues/907
One potential fix is to manually pip uninstall the library module that is causing the issue:
Code: Select all
pip3 uninstall -y RPi.GPIO
- usrnsf_ted
- Posts: 25
- Joined: Sun Dec 15, 2024 5:02 pm
Re: APDS9960
Okay, got the 9960 working on the pi 4b servos responding well but I have jitter and I've tried several different methods for changing the pin factory and nothing seems to work. Anybody have pointers on changing the pin factory? And then using pig pio to control the servo?
Please be positive and constructive with your questions and comments.