Skip to content

Commit 9c79fbf

Browse files
authored
Merge pull request #961 from pimoroni/patch-as7343-examples
AS7343 examples tidy
2 parents f18f1ba + f587cd2 commit 9c79fbf

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ add_subdirectory(breakout_bme688)
1919
add_subdirectory(breakout_bmp280)
2020
add_subdirectory(breakout_bme280)
2121
add_subdirectory(breakout_as7262)
22-
add_subdirectory(as7343)
22+
add_subdirectory(breakout_as7343)
2323
add_subdirectory(breakout_bh1745)
2424
add_subdirectory(breakout_icp10125)
2525
add_subdirectory(breakout_scd41)
File renamed without changes.
File renamed without changes.

examples/as7343/as7343_demo.cpp renamed to examples/breakout_as7343/as7343_demo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
using namespace pimoroni;
77

8-
I2C i2c(6, 7);
8+
I2C i2c(BOARD::BREAKOUT_GARDEN);
99
AS7343 as7343(&i2c);
1010

1111
int main() {
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+
from pimoroni import BREAKOUT_GARDEN_I2C_PINS # or PICO_EXPLORER_I2C_PINS or HEADER_I2C_PINS
7+
import time
8+
9+
i2c = PimoroniI2C(**BREAKOUT_GARDEN_I2C_PINS)
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)