8000 I2C pin conflicts · Issue #35 · adafruit/Adafruit_CircuitPython_FeatherWing · GitHub
[go: up one dir, main page]

Skip to content
I2C pin conflicts #35
Closed
Closed
@jerryneedell

Description

@jerryneedell

This is just FYI regardsing some experimentation I have been doing

I was trying to use the an alphanumeric display vi the featherwing library along with some other I2C sesnors. I wanted to get the sensor data and display it on the alphanumeric featherwing. A common use case, I think.

When I tried to create the sensor objects, i got errors indicating that the I2C pins were "in use".

I experimented a bit using the board.I2C() function instead of the busio.I2C() with the sensors and got it working, but then found that if I make the following change, I think shared.py becomes unnecessary.

uit_featherwing$ git diff
diff --git a/adafruit_featherwing/alphanum_featherwing.py b/adafruit_featherwing/alphanum_featherwing.py
index 06b0409..cf445a6 100755
--- a/adafruit_featherwing/alphanum_featherwing.py
+++ b/adafruit_featherwing/alphanum_featherwing.py
@@ -31,8 +31,8 @@ Helper for using the `14-Segment AlphaNumeric FeatherWing <https://www.adafruit.
 __version__ = "0.0.0-auto.0"
 __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git"
 
+import board
 import adafruit_ht16k33.segments as segments
-from adafruit_featherwing import shared
 from adafruit_featherwing.led_segments import Segments
 
 class AlphaNumFeatherWing(Segments):
@@ -42,5 +42,5 @@ class AlphaNumFeatherWing(Segments):
        Automatically uses the feather's I2C bus."""
     def __init__(self, address=0x70):
         super().__init__()
-        self._segments = segments.Seg14x4(shared.I2C_BUS, address)
+        self._segments = segments.Seg14x4(board.I2C(), address)
         self._segments.auto_write = False

here is the test code I am running

import time
import board
import busio
import adafruit_sht31d
import adafruit_veml6070

from adafruit_featherwing import alphanum_featherwing

display = alphanum_featherwing.AlphaNumFeatherWing()
sensor = adafruit_sht31d.SHT31D(board.I2C())
uv = adafruit_veml6070.VEML6070(board.I2C())



loopcount = 0
while True:
    uv_raw = uv.read
    risk_level = uv.get_index(uv_raw)
    print('Reading: {0} | Risk Level: {1}'.format(uv_raw, risk_level))
    display.print(uv_raw)
    time.sleep(2)
    temperature = sensor.temperature
    print("\nTemperature: %0.1f C" % temperature)
    display.print(temperature)
    print("Humidity: %0.1f %%" % sensor.relative_humidity)
    loopcount += 1
    time.sleep(2)
    # every 10 passes turn on the heater for 1 second
    if loopcount == 10:
        loopcount = 0
        sensor.heater = True
        print("Sensor Heater status =", sensor.heater)
        time.sleep(1)
        sensor.heater = False
        print("Sensor Heater status =", sensor.heater)


One issue I an into was that in the current master, board.I2C() is not implemented for the particle boards and I was testing on a particle_argon. I implmented it in a local build and it now is working. It was already implemented in the feather_nrf52840.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0