"ValueError:SCL in use"
For testing I am using two Adafruit I2C devices, the I2C QT Rotary Encoder and the MPRLS Pressure Sensor. When I run "i2cdetect -y 1" from the terminal it shows they have different addresses.
In case it helps, here is the code that I am using:
Code: Select all
import time
import board
import busio
import adafruit_mprls
i2c = busio.I2C(board.SCL, board.SDA)
mpr = adafruit_mprls.MPRLS(i2c, psi_min=0, psi_max=25)
from rainbowio import colorwheel
from adafruit_seesaw import seesaw, neopixel, rotaryio, digitalio
i2c = busio.I2C(board.SCL, board.SDA)
seesaw = seesaw.Seesaw(i2c, 0x36)
encoder = rotaryio.IncrementalEncoder(seesaw)
seesaw.pin_mode(24, seesaw.INPUT_PULLUP)
switch = digitalio.DigitalIO(seesaw, 24)
pixel = neopixel.NeoPixel(seesaw, 6, 1)
pixel.brightness = 0.5
last_position = -1
color = 9 # start at red plus 9
while True:
# negate the position to make clockwise rotation positive
position = -encoder.position
print("Pressure (hPa):", mpr.pressure)
if position != last_position:
print(position)
if switch.value:
# Change the LED color.
if position > last_position: # Advance forward through the colorwheel.
color += 1
else:
color -= 1 # Advance backward through the colorwheel.
color = (color + 256) % 256 # wrap around to 0-256
pixel.fill(colorwheel(color))
else: # If the button is pressed...
# ...change the brightness.
if position > last_position: # Increase the brightness.
pixel.brightness = min(1.0, pixel.brightness + 0.1)
else: # Decrease the brightness.
pixel.brightness = max(0, pixel.brightness - 0.1)
last_position = position
print("Pressure (hPa):", mpr.pressure)
# You can also specify both reset and eoc pins
"""
#import digitalio
#reset = digitalio.DigitalInOut(board.D5)
#eoc = digitalio.DigitalInOut(board.D6)
#mpr = adafruit_mprls.MPRLS(i2c, eoc_pin=eoc, reset_pin=reset,
# psi_min=0, psi_max=25)
"""
while True:
print((mpr.pressure,))
time.sleep(.001)
Any insight would be helpful. Thanks in advance.