-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeError: Unable to enable VEML7700 device #19
Comments
does it work without the TCA, on other channels, or with micropython without blinka |
Thanks for the response. I made no HW config changes between loading the Pico with Circuitpython and Micropython. I'll wire up a new harness to test the sensor on a different channel and without the TCA. I'll run the test later this evening after removing the blinka folder from lib. Below are the photos you requested. In the top photo you see I have the VEML6070 and VEML7700 on a separate PCB connected via a ribbon cable. |
Results of attempting to remove blinka which ended with AttributeError no attribute 'try_lock'. You can see that the I2C scan shows a response from the TCA board, but the initiating TCA9548A doesn't seem to work without blinka. The requirements.txt for TCA9548A also shows Adafruit-Blinka as a requirement. REPL output: Type "help()" for more information.
from machine import Pin, I2C, SoftI2C
import sys
import time
import adafruit_tca9548a
import adafruit_veml7700
import adafruit_veml6070
sample_sec = time.ticks_ms()
i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=400000)
print(i2c.scan())
tca = adafruit_tca9548a.TCA9548A(i2c)
for channel in range(8):
if tca[channel].try_lock():
print("Channel {}:".format(channel), end="")
addresses = tca[channel].scan()
print([hex(address) for address in addresses if address != 0x70])
tca[channel].unlock()
# UV SENSOR
uv = adafruit_veml6070.VEML6070(tca[1])
# Alternative constructors with parameters
# uv = adafruit_veml6070.VEML6070(tca[1], 'VEML6070_1_T')
# uv = adafruit_veml6070.VEML6070(tca[1], 'VEML6070_HALF_T', True)
def UV_DATA():
uv_raw = uv.uv_raw
risk_level = uv.get_index(uv_raw)
print("Reading: {0} | Risk Level: {1}".format(uv_raw, risk_level))
# LUX SENSOR
luxsensor = adafruit_veml7700.VEML7700(tca[0])
print("Light Integration Time:", luxsensor.light_integration_time)
print("Ambient Light:", luxsensor.lux)
def LUX_DATA():
print("Ambient Light:", luxsensor.lux)
# MEASURE SOME DATA!
while True:
if (time.ticks_ms() - sample_sec > 10000):
UV_DATA()
LUX_DATA()
sample_sec = time.ticks_ms() I'll test the a direct connect to the VEML7700 tomorrow afternoon after I can build a wiring harness. |
Trying to isolate and run the sensor directly connected to the I2C pins results in the following REPL Output: MicroPython v1.18 on 2022-01-17; Raspberry Pi Pico with RP2040
from machine import Pin, I2C
import time
import adafruit_veml7700
i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=400000)
veml = adafruit_veml7700.VEML7700(i2c)
while True:
print("Ambient light:", veml7700.light)
time.sleep(1) |
One more test run with the sensor directly connected to the Pico running Micropython and blinka installed import busio
import time
import board
import adafruit_veml7700
i2c = busio.I2C(board.GP5, board.GP4, frequency=400000)
veml7700 = adafruit_veml7700.VEML7700(i2c)
while True:
print("Ambient light:", veml7700.light)
time.sleep(0.1) REPL:
|
Last test complete. Moved the VEML7700 to channel one of the TCA9548A. Pico running Micropython with platformdetect and blinka folders installed. import sys
import time
import board
import busio
import digitalio
import adafruit_tca9548a
import adafruit_veml7700
import adafruit_veml6070
sample_sec = time.ticks_ms()
i2c = busio.I2C(board.GP5, board.GP4, frequency=400000)
tca = adafruit_tca9548a.TCA9548A(i2c)
for channel in range(8):
if tca[channel].try_lock():
print("Channel {}:".format(channel), end="")
addresses = tca[channel].scan()
print([hex(address) for address in addresses if address != 0x70])
tca[channel].unlock()
# UV SENSOR
uv = adafruit_veml6070.VEML6070(tca[0])
# Alternative constructors with parameters
# uv = adafruit_veml6070.VEML6070(tca[1], 'VEML6070_1_T')
# uv = adafruit_veml6070.VEML6070(tca[1], 'VEML6070_HALF_T', True)
def UV_DATA():
uv_raw = uv.uv_raw
risk_level = uv.get_index(uv_raw)
print("Reading: {0} | Risk Level: {1}".format(uv_raw, risk_level))
UV_DATA()
# LUX SENSOR
luxsensor = adafruit_veml7700.VEML7700(tca[1])
print("Light Integration Time:", luxsensor.light_integration_time)
print("Ambient Light:", luxsensor.lux)
def LUX_DATA():
print("Ambient Light:", luxsensor.lux)
while True:
if (time.ticks_ms() - sample_sec > 10000):
UV_DATA()
LUX_DATA()
sample_sec = time.ticks_ms() REPL:
|
Seems odd that this is showing up in REPL output:
The Does the issue repeat is your try this simpler program? import board
import adafruit_tca9548a
import adafruit_veml7700
print("VEML770 Test.")
tca = adafruit_tca9548a.TCA9548A(board.I2C())
luxsensor = adafruit_veml7700.VEML7700(tca[1])
print("Light Integration Time:", luxsensor.light_integration_time)
print("Ambient Light:", luxsensor.lux) |
Definitely understand the confusion. As a test of the VEML6070 I had a call to the function one line before the VEML7700 init line. I've edited the comment to showcase the full code and REPL. Sorry about that. I'll give this shorter code a run within the hour. |
when we say 'micropython without blinka' we mean using a micropython driver for the veml7700. also, remove the veml6070, its totally different. |
That code snippet gave some errors with board not having attribute I2C. Running this code import board
import busio
import adafruit_tca9548a
import adafruit_veml7700
print("VEML770 Test.")
tca = adafruit_tca9548a.TCA9548A(busio.I2C(board.GP5, board.GP4, frequency=400000))
luxsensor = adafruit_veml7700.VEML7700(tca[1])
print("Light Integration Time:", luxsensor.light_integration_time)
print("Ambient Light:", luxsensor.lux) Gave this REPL:
|
remove the frequency arg |
tca = adafruit_tca9548a.TCA9548A(busio.I2C(board.GP5, board.GP4)) REPL:
|
ok this is not a high priority and its a very complex setup, so we dont have a recommendation at this time for a fix. you may have to use it without the expander |
Adding this here FWIW, wanted to sanity check hardware combo. Tested with CircuitPython and works fine. test code: import board
import busio
import adafruit_tca9548a
import adafruit_veml7700
print("VEML770 Test.")
i2c = busio.I2C(board.GP5, board.GP4)
tca = adafruit_tca9548a.TCA9548A(i2c)
luxsensor = adafruit_veml7700.VEML7700(tca[1])
print("Light Integration Time:", luxsensor.light_integration_time)
print("Ambient Light:", luxsensor.lux) result: Adafruit CircuitPython 7.1.1 on 2022-01-14; Raspberry Pi Pico with rp2040
>>> import veml_test
VEML770 Test.
Light Integration Time: 0
Ambient Light: 266.227
>>> |
Yes. I get the same result when running CircuitPython directly on the Pico. The problem occurs when I move the Pico to MicroPython and use blinka to run adafruit libraries. The only library that has given this error is VEML7700. These libraries are all connected to the same setup and TCA without issue. TCA uses I2C0 scl=pin5, sda=pin4 direct on I2C1 scl=Pin15, sda=Pin14 The reason I've been trying to switch to micropython is to open up threading. I'd like to run my ESP01 communication code on core 2 and use core 1 to collect sensor data. |
@ladyada - Understand it is a low priority. I also agree that it is a complex setup. I rebuilt the circuit on breadboard to remove and issues with the setup on the board. Using a different Pico, TCA board, and VEML7700. Micropython Direct Connect Code: from machine import Pin, I2C
import veml7700
i2c = I2C(0, scl=Pin(5), sda=Pin(4))
print("VEML TEST.")
veml = veml7700.VEML7700(address=0x10, i2c=i2c, it=100, gain=1/8)
print(veml.read_lux()) REPL:
Micropython, TCA, VEML standard library Code: import board
import busio
import adafruit_tca9548a
import veml7700
i2c = busio.I2C(board.GP5, board.GP4)
tca = adafruit_tca9548a.TCA9548A(i2c)
print("VEML TEST.")
veml = veml7700.VEML7700(address=0x10, i2c=tca[0], it=100, gain=1/8)
print(veml.read_lux()) REPL: Type "help()" for more information.
This would make sense as the python library reference the writeto_mem while the TCA uses the writeto() and readfrom_into() functions Micropython TCA, VEML adafruit libraries import board
import busio
import adafruit_tca9548a
import adafruit_veml7700
i2c = busio.I2C(board.GP5, board.GP4)
tca = adafruit_tca9548a.TCA9548A(i2c)
print("VEML TEST.")
veml = adafruit_veml7700.VEML7700(tca[0])
print(veml.light) REPL:
Cpy on Pico TCA and VEML adafruit libraries Code: import board
import busio
import adafruit_tca9548a
import adafruit_veml7700
i2c = busio.I2C(board.GP5, board.GP4)
tca = adafruit_tca9548a.TCA9548A(i2c)
print("VEML TEST.")
veml = adafruit_veml7700.VEML7700(tca[0])
print(veml.light) REPL:
|
@ladyada not sure if this is helpful, but I attempted to force the VEMLL7700 to set the light_shutdown = False in the init function and got the following. Code: def __init__(self, i2c_bus, address=0x10):
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
self.light_shutdown = False # Line 190
print(self.light_shutdown)
for _ in range(3):
try:
self.light_shutdown = False # Enable the ambient light sensor
break
except OSError:
pass
else:
raise RuntimeError("Unable to enable VEML7700 device") REPL:
|
Running Micropython on Pi Pico and attempting to use the VEML7700 connected to a TCA9548a on Channel 0. Platform_Detector and Blinka src files are installed. Other adafruit libraries are working fine. As you can see in the output below my VEML6070 is communicating on channel 1 without issues.
REPL OUTPUT:
MicroPython v1.18 on 2022-01-17; Raspberry Pi Pico with RP2040
Type "help()" for more information.
I've flashed the same Pico with CircuitPython and the sensor works properly with the same library.
The text was updated successfully, but these errors were encountered: