Closed
Description
Both sensor.color_temperature
and sensor.lux
throw division by zero errors:
Traceback (most recent call last):
File "code.py", line 7, in
File "adafruit_tcs34725.py", line 113, in color_temperature
File "adafruit_tcs34725.py", line 314, in _temperature_and_lux_dn40
ZeroDivisionError: division by zero
Here is my code:
from board import SCL, SDA
from busio import I2C
from adafruit_tcs34725 import TCS34725
i2c = I2C(SCL, SDA)
sensor = TCS34725(i2c)
print('Color: ({0}, {1}, {2})'.format(*sensor.color_rgb_bytes))
print('Temperature: {0}K'.format(sensor.color_temperature))
print('Lux: {0}'.format(sensor.lux))
I think it may be caused when the color source is too bright.
Also there is a typo on the Adafruit tutorial. The property temperature
should be color_temperature
. It is incorrect in the docs and the example: https://learn.adafruit.com/adafruit-color-sensors/python-circuitpython#circuitpython-and-python-usage-3-7
Metadata
Metadata
Assignees
Labels
No labels