Skip to content

Commit 209c3d1

Browse files
committed
add basic AS7343 example
1 parent f18f1ba commit 209c3d1

File tree

1 file changed

+28
-0
lines changed
  • micropython/examples/breakout_as7343

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Prints data from the AS7343 sensor to the console
2+
# Open up the plotter window in Thonny to see the values change in real-time!
3+
4+
from breakout_as7343 import BreakoutAS7343
5+
from pimoroni_i2c import PimoroniI2C
6+
import time
7+
8+
# use (sda=20, scl=21) if you have a Pico Explorer Base or other board that uses the alt I2C pins
9+
i2c = PimoroniI2C(sda=4, scl=5)
10+
as7343 = BreakoutAS7343(i2c)
11+
12+
as7343.set_channels(18)
13+
as7343.set_gain(1024)
14+
as7343.set_measurement_time(33) # Roughly 30fps at 16ms/measurement
15+
as7343.set_integration_time(27800)
16+
17+
as7343.set_illumination_current(4)
18+
as7343.set_illumination_led(True)
19+
20+
while True:
21+
reading = as7343.read()
22+
23+
print(
24+
"FZ: {0}, FY: {1}, FXL: {2}, NIR: {3}, F2: {4}, F3: {5}, F4: {6}, F6: {7}, F1: {8}, F5: {9}, F7: {10}, F8: {11}".format(
25+
*reading
26+
)
27+
)
28+
time.sleep(0.01)

0 commit comments

Comments
 (0)