diff --git a/examples/tcs34725_simpletest.py b/examples/tcs34725_simpletest.py index 96cbef7..fb20055 100644 --- a/examples/tcs34725_simpletest.py +++ b/examples/tcs34725_simpletest.py @@ -18,8 +18,11 @@ r, g, b = sensor.color_rgb_bytes print('Detected color: #{0:02X}{1:02X}{2:02X}'.format(r, g, b)) # Read the color temperature and lux of the sensor too. - temp = sensor.temperature - lux = sensor.lux - print('Temperature: {0}K Lux: {1}'.format(temp, lux)) + try: + temp = sensor.temperature + lux = sensor.lux + print('Temperature: {0}K Lux: {1}'.format(temp, lux)) + except ZeroDivisionError: + print("No light to measure") # Delay for a second and repeat. time.sleep(1.0)