forked from NPC1399/AS7265X_sparkfun_micropython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (23 loc) · 724 Bytes
/
main.py
File metadata and controls
28 lines (23 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from machine import Pin, I2C
from AS7265X import AS7265X
import time
sensor_type = "None"
try:
i2c = I2C(0, I2C.MASTER, pins=('P22', 'P21'))
sensor = AS7265X(i2c=i2c) # create and use non-default PIN assignments (P22=SDA, P21=SCL)
sensor_type = sensor.get_device_type()
print("Sensor type: {}".format(sensor_type))
print("Wavelengths: {}".format(sensor.get_wavelengths()))
time.sleep(1)
except Exception as error:
print(error)
pass
while True:
calibrated_values = []
try:
sensor.take_measurements()
calibrated_values = sensor.get_all_values(calibrated=True)
print(calibrated_values)
except Exception as error:
print(error)
time.sleep(5.0)