Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

DPS310 Issues with Circuitpython
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

DPS310 Issues with Circuitpython

by jimhill on Sun Jun 06, 2021 5:57 am

Hi,

We're trying to get a DPS310 sensor working on a Raspberry Pico and are having some issues. We have booted the Pico to use circuit python and think we have put all of the relevant libraries in the lib folder. However, when we try to run the code we get an error that we're struggling to understand. Please could anyone help?

The error message is:
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "/lib/adafruit_dps310.py", line 192, in __init__
AttributeError: 'int' object has no attribute 'try_lock'

The code that we've written is:
Code: Select all | TOGGLE FULL SIZE
from adafruit_dps310 import DPS310
from time import sleep
import board

alti = DPS310(0, 1)

while True:
    print("Temperature = %.2f *C" % dps310.temperature)
    print("Pressure = %.2f hPa" % dps310.pressure)
    print("")
    sleep(1)

jimhill
 
Posts: 1
Joined: Sun Jun 06, 2021 5:53 am

Re: DPS310 Issues with Circuitpython

by wildestpixel on Mon Jun 07, 2021 12:59 am

You have to initialise the i2c device, and as the Pico does not have board assignations like a feather for example, you will have to identify the SCL and SDA pins manually :

Would therefore look something like this attached to GP21 and GP20


Code: Select all | TOGGLE FULL SIZE
import time
import busio
import adafruit_dps310

i2c = busio.I2C(board.GP21, board.GP20)
dps310 = adafruit_dps310.DPS310(i2c)



while True:
    print("Temperature = %.2f *C" % dps310.temperature)
    print("Pressure = %.2f hPa" % dps310.pressure)
    print("")
    time.sleep(1.0)


Check also for your sanity - you defined "alti", but didn't call it again (not that it would have made difference) - use the examples and modify from there only to make it work. Above should be a good pointer.

wildestpixel
 
Posts: 64
Joined: Wed Oct 23, 2019 1:14 am

Please be positive and constructive with your questions and comments.