Traceback (most recent call last):
File "<stdin>", line 12, in <module>
ValueError: BreakoutLTR559: Bad i2C object
Line 12 is ltr = BreakoutLTR559(i2c)
#import machine
from machine import I2C, Pin
sda=machine.Pin(4) # Explorer 20 Breakout 4
scl=machine.Pin(5) # Explorer 21 Breakout 5
i2c=machine.I2C(0,sda=sda, scl=scl, freq=400000)
import veml6075
import time
import machine
from breakout_ltr559 import BreakoutLTR559
ltr = BreakoutLTR559(i2c)
uv = veml6075.VEML6075(i2c)
connected = uv.initUV()
import picodisplay2 as display2
display_buffer = bytearray(320 * 240 * 2) # 2-bytes per pixel (RGB565)
display2.init(display_buffer)
display2.set_backlight(0.8)
while True:
reading = ltr.get_reading()
#print("Lux:", reading[BreakoutLTR559.LUX], "Prox:", reading[BreakoutLTR559.PROXIMITY])
light = reading[BreakoutLTR559.LUX]
display2.set_pen(0, 255, 0)
display2.text("sun", 0, 70, 240, 3)
#Convert light level in lux to descriptive value.
if light < 50:
display2.text("dark", 60, 70, 240, 3)
elif 50 <= light < 100:
display2.text("dim", 60, 70, 240, 3)
elif 100 <= light < 500:
display2.text("light", 60, 70, 240, 3)
elif light >= 500:
display2.text("bright", 60, 70, 240, 3)
UVI, UVIA, UVIB = uv.readUV()
display2.set_pen(0, 255, 0)
#display2.text("uv", 0, 70, 240, 3)
display2.text("UVIA {0:.1f}" .format(UVIA), 0, 180, 240, 3)
display2.text("UVIB {0:.1f}" .format(UVIB), 0, 200, 240, 3)
display2.text("UVI avg {0:.1f}" .format(UVI), 0, 220, 240, 3)
display2.update()
display2.set_pen(0, 0, 0)
display2.clear()
time.sleep(1.0)