Added commented out board.stemma_i2c()
This commit is contained in:
parent
36a27be58c
commit
4c24224338
20 changed files with 61 additions and 28 deletions
|
|
@ -12,7 +12,8 @@ import time
|
||||||
import board
|
import board
|
||||||
|
|
||||||
# To use default I2C bus (most boards)
|
# To use default I2C bus (most boards)
|
||||||
i2c = board.I2C()
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
|
||||||
# To create I2C bus on specific pins
|
# To create I2C bus on specific pins
|
||||||
# import busio
|
# import busio
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@ import time
|
||||||
import board
|
import board
|
||||||
import adafruit_tsl2591
|
import adafruit_tsl2591
|
||||||
|
|
||||||
i2c = board.I2C()
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
|
||||||
# Lock the I2C device before we try to scan
|
# Lock the I2C device before we try to scan
|
||||||
while not i2c.try_lock():
|
while not i2c.try_lock():
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,8 @@ displayio.release_displays()
|
||||||
# oled_reset = board.D9
|
# oled_reset = board.D9
|
||||||
|
|
||||||
# Use for I2C
|
# Use for I2C
|
||||||
i2c = board.I2C()
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)
|
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)
|
||||||
|
|
||||||
# SH1107 is vertically oriented 64x128
|
# SH1107 is vertically oriented 64x128
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,16 @@ import matrixsand
|
||||||
|
|
||||||
DELAY = 0.00 # add some delay if you want
|
DELAY = 0.00 # add some delay if you want
|
||||||
|
|
||||||
|
# setup i2c
|
||||||
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
|
||||||
# the accelo
|
# the accelo
|
||||||
accelo = adafruit_lsm6ds.lsm6ds33.LSM6DS33(board.I2C())
|
accelo = adafruit_lsm6ds.lsm6ds33.LSM6DS33(i2c)
|
||||||
|
|
||||||
# the matrix
|
# the matrix
|
||||||
matrix1 = matrix.Matrix8x8(board.I2C(), 0x70)
|
matrix1 = matrix.Matrix8x8(i2c, 0x70)
|
||||||
matrix2 = matrix.Matrix8x8(board.I2C(), 0x71)
|
matrix2 = matrix.Matrix8x8(i2c, 0x71)
|
||||||
|
|
||||||
# the sand
|
# the sand
|
||||||
sand = matrixsand.MatrixSand(8, 16)
|
sand = matrixsand.MatrixSand(8, 16)
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,16 @@ import matrixsand
|
||||||
|
|
||||||
DELAY = 0.05 # overall update rate
|
DELAY = 0.05 # overall update rate
|
||||||
|
|
||||||
|
# setup i2c
|
||||||
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
|
||||||
# the accelo
|
# the accelo
|
||||||
accelo = adafruit_lsm6ds.lsm6ds33.LSM6DS33(board.I2C())
|
accelo = adafruit_lsm6ds.lsm6ds33.LSM6DS33(i2c)
|
||||||
|
|
||||||
# the matrices
|
# the matrices
|
||||||
m1 = matrix.Matrix8x8(board.I2C(), 0x70)
|
m1 = matrix.Matrix8x8(i2c, 0x70)
|
||||||
m2 = matrix.Matrix8x8(board.I2C(), 0x71)
|
m2 = matrix.Matrix8x8(i2c, 0x71)
|
||||||
|
|
||||||
# the sand
|
# the sand
|
||||||
sand1 = matrixsand.MatrixSand(8, 8)
|
sand1 = matrixsand.MatrixSand(8, 8)
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,15 @@ import matrixsand
|
||||||
|
|
||||||
DELAY = 0.00 # add some delay if you want
|
DELAY = 0.00 # add some delay if you want
|
||||||
|
|
||||||
|
# setup i2c
|
||||||
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
|
||||||
# the accelo
|
# the accelo
|
||||||
accelo = adafruit_lsm6ds.lsm6ds33.LSM6DS33(board.I2C())
|
accelo = adafruit_lsm6ds.lsm6ds33.LSM6DS33(i2c)
|
||||||
|
|
||||||
# the matrix
|
# the matrix
|
||||||
matrix = matrix.Matrix8x8(board.I2C(), 0x70)
|
matrix = matrix.Matrix8x8(i2c, 0x70)
|
||||||
|
|
||||||
# the sand
|
# the sand
|
||||||
sand = matrixsand.MatrixSand(8, 8)
|
sand = matrixsand.MatrixSand(8, 8)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ font = terminalio.FONT
|
||||||
|
|
||||||
displayio.release_displays()
|
displayio.release_displays()
|
||||||
|
|
||||||
i2c = board.I2C()
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)
|
display_bus = displayio.I2CDisplay(i2c, device_address=0x3c)
|
||||||
oled = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
|
oled = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import board
|
||||||
import adafruit_mcp9808
|
import adafruit_mcp9808
|
||||||
|
|
||||||
i2c = board.I2C() # uses board.SCL and board.SDA
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
# import busio
|
# import busio
|
||||||
# i2c = busio.I2C(board.SCL1, board.SDA1) # For QT Py RP2040, QT Py ESP32-S2
|
# i2c = busio.I2C(board.SCL1, board.SDA1) # For QT Py RP2040, QT Py ESP32-S2
|
||||||
mcp9808 = adafruit_mcp9808.MCP9808(i2c)
|
mcp9808 = adafruit_mcp9808.MCP9808(i2c)
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,8 @@
|
||||||
import time
|
import time
|
||||||
import board
|
import board
|
||||||
|
|
||||||
# To use default I2C bus (most boards)
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
i2c = board.I2C()
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
|
||||||
# To use the STEMMA QT connector (most boards)
|
|
||||||
# i2c = board.STEMMA_I2C()
|
|
||||||
|
|
||||||
# To create I2C bus on specific pins
|
# To create I2C bus on specific pins
|
||||||
# import busio
|
# import busio
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@ import board
|
||||||
from adafruit_lc709203f import LC709203F, PackSize
|
from adafruit_lc709203f import LC709203F, PackSize
|
||||||
|
|
||||||
# Create sensor object, using the board's default I2C bus.
|
# Create sensor object, using the board's default I2C bus.
|
||||||
battery_monitor = LC709203F(board.I2C())
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
battery_monitor = LC709203F(i2c)
|
||||||
|
|
||||||
# Update to match the mAh of your battery for more accurate readings.
|
# Update to match the mAh of your battery for more accurate readings.
|
||||||
# Can be MAH100, MAH200, MAH400, MAH500, MAH1000, MAH2000, MAH3000.
|
# Can be MAH100, MAH200, MAH400, MAH500, MAH1000, MAH2000, MAH3000.
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,9 @@ SAMPLE_AVG = 500 # Number of sample values to average
|
||||||
DEFAULT_GAIN = 128 # Default gain for internal PGA
|
DEFAULT_GAIN = 128 # Default gain for internal PGA
|
||||||
|
|
||||||
# Instantiate 24-bit load sensor ADC
|
# Instantiate 24-bit load sensor ADC
|
||||||
nau7802 = NAU7802(board.I2C(), address=0x2A, active_channels=1)
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
nau7802 = NAU7802(i2c, address=0x2A, active_channels=1)
|
||||||
|
|
||||||
|
|
||||||
def zero_channel():
|
def zero_channel():
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,9 @@ FYI: A US dime coin weighs 2.268 grams or 0.079 ounces."""
|
||||||
CALIB_RATIO = 100 / 215300 # load cell serial#4540-02
|
CALIB_RATIO = 100 / 215300 # load cell serial#4540-02
|
||||||
|
|
||||||
# Instantiate the Sensor and Display
|
# Instantiate the Sensor and Display
|
||||||
nau7802 = NAU7802(board.I2C(), address=0x2A, active_channels=1)
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
nau7802 = NAU7802(i2c, address=0x2A, active_channels=1)
|
||||||
|
|
||||||
display = board.DISPLAY
|
display = board.DISPLAY
|
||||||
scale_group = displayio.Group()
|
scale_group = displayio.Group()
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,9 @@ from adafruit_seesaw import seesaw, rotaryio, digitalio
|
||||||
|
|
||||||
num_faders = 3
|
num_faders = 3
|
||||||
|
|
||||||
motorwing = MotorKit(i2c=board.I2C())
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
motorwing = MotorKit(i2c=i2c)
|
||||||
motorwing.frequency = 122 # tune this 50 - 200 range
|
motorwing.frequency = 122 # tune this 50 - 200 range
|
||||||
max_throttle = 0.18 # tune this 0.2 - 1 range
|
max_throttle = 0.18 # tune this 0.2 - 1 range
|
||||||
|
|
||||||
|
|
@ -32,7 +34,7 @@ for i in range(num_faders):
|
||||||
motors[i].throttle = None
|
motors[i].throttle = None
|
||||||
|
|
||||||
# STEMMA QT Rotary encoder setup
|
# STEMMA QT Rotary encoder setup
|
||||||
seesaw = seesaw.Seesaw(board.I2C(), addr=0x36) # default address is 0x36
|
seesaw = seesaw.Seesaw(i2c, addr=0x36) # default address is 0x36
|
||||||
seesaw.pin_mode(24, seesaw.INPUT_PULLUP)
|
seesaw.pin_mode(24, seesaw.INPUT_PULLUP)
|
||||||
button_in = digitalio.DigitalIO(seesaw, 24)
|
button_in = digitalio.DigitalIO(seesaw, 24)
|
||||||
button = Debouncer(button_in)
|
button = Debouncer(button_in)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import adafruit_am2320
|
||||||
vbat_voltage = analogio.AnalogIn(board.D9)
|
vbat_voltage = analogio.AnalogIn(board.D9)
|
||||||
|
|
||||||
i2c = board.I2C() # uses board.SCL and board.SDA
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
am2320 = adafruit_am2320.AM2320(i2c)
|
am2320 = adafruit_am2320.AM2320(i2c)
|
||||||
|
|
||||||
SD_CS = board.D10
|
SD_CS = board.D10
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ import storage
|
||||||
import adafruit_pcf8523
|
import adafruit_pcf8523
|
||||||
|
|
||||||
# setup for I2C
|
# setup for I2C
|
||||||
i2c = board.I2C()
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
# setup for SCD40
|
# setup for SCD40
|
||||||
scd4x = adafruit_scd4x.SCD4X(i2c)
|
scd4x = adafruit_scd4x.SCD4X(i2c)
|
||||||
# setup for RTC
|
# setup for RTC
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,9 @@ import adafruit_lis3dh
|
||||||
import adafruit_is31fl3741
|
import adafruit_is31fl3741
|
||||||
from adafruit_is31fl3741.adafruit_ledglasses import LED_Glasses
|
from adafruit_is31fl3741.adafruit_ledglasses import LED_Glasses
|
||||||
|
|
||||||
i2c = board.I2C() # Shared by both the accelerometer and LED controller
|
# Shared by both the accelerometer and LED controller
|
||||||
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
|
||||||
# Initialize the accelerometer and enable single-tap detection
|
# Initialize the accelerometer and enable single-tap detection
|
||||||
int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
|
int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,9 @@ from adafruit_is31fl3741.adafruit_ledglasses import LED_Glasses
|
||||||
|
|
||||||
# HARDWARE SETUP ----
|
# HARDWARE SETUP ----
|
||||||
|
|
||||||
i2c = board.I2C() # Shared by both the accelerometer and LED controller
|
# Shared by both the accelerometer and LED controller
|
||||||
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
|
||||||
# Initialize the accelerometer
|
# Initialize the accelerometer
|
||||||
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c)
|
lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c)
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,10 @@ minute = cal[4]
|
||||||
# (https://github.com/adafruit/Adafruit_CircuitPython_Bundle):
|
# (https://github.com/adafruit/Adafruit_CircuitPython_Bundle):
|
||||||
# * adafruit-circuitpython-minimqtt
|
# * adafruit-circuitpython-minimqtt
|
||||||
# * adafruit-circuitpython-requests
|
# * adafruit-circuitpython-requests
|
||||||
|
|
||||||
# Create sensor object, communicating over the board's default I2C bus
|
# Create sensor object, communicating over the board's default I2C bus
|
||||||
i2c = board.I2C() # uses board.SCL and board.SDA
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
bme680 = adafruit_bme680.Adafruit_BME680_I2C(i2c, debug=False)
|
bme680 = adafruit_bme680.Adafruit_BME680_I2C(i2c, debug=False)
|
||||||
|
|
||||||
# change this to match the location's pressure (hPa) at sea level
|
# change this to match the location's pressure (hPa) at sea level
|
||||||
|
|
@ -106,7 +108,7 @@ print("Connected to Azure IoT Central!")
|
||||||
temperature_offset = -5
|
temperature_offset = -5
|
||||||
|
|
||||||
# Create sensor object, using the board's default I2C bus.
|
# Create sensor object, using the board's default I2C bus.
|
||||||
battery_monitor = LC709203F(board.I2C())
|
battery_monitor = LC709203F(i2c)
|
||||||
|
|
||||||
# Update to match the mAh of your battery for more accurate readings.
|
# Update to match the mAh of your battery for more accurate readings.
|
||||||
# Can be MAH100, MAH200, MAH400, MAH500, MAH1000, MAH2000, MAH3000.
|
# Can be MAH100, MAH200, MAH400, MAH500, MAH1000, MAH2000, MAH3000.
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ import adafruit_imageload
|
||||||
from adafruit_emc2101 import EMC2101
|
from adafruit_emc2101 import EMC2101
|
||||||
from adafruit_funhouse import FunHouse
|
from adafruit_funhouse import FunHouse
|
||||||
|
|
||||||
i2c = board.I2C()
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
|
||||||
# setup for SGP30 sensor
|
# setup for SGP30 sensor
|
||||||
sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c)
|
sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c)
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,9 @@ io.on_message = message
|
||||||
print("Connecting to Adafruit IO...")
|
print("Connecting to Adafruit IO...")
|
||||||
io.connect()
|
io.connect()
|
||||||
|
|
||||||
display_bus = displayio.I2CDisplay(board.I2C(), device_address=0x3C)
|
i2c = board.I2C() # uses board.SCL and board.SDA
|
||||||
|
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
|
||||||
|
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)
|
||||||
|
|
||||||
WIDTH = 128
|
WIDTH = 128
|
||||||
HEIGHT = 32
|
HEIGHT = 32
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue