Skip to content

Commit c6c2ee0

Browse files
committed
Docs final review & publish
Final review edits to docs files & adding GH pages build files.
1 parent e404393 commit c6c2ee0

11 files changed

+313
-33
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build Documentation
2+
3+
on:
4+
# Runs on pushes targeting the default branch
5+
push:
6+
branches: ["main"]
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow files to be committed to gh-pages branch
12+
permissions:
13+
contents: write
14+
15+
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Instal pgnquant for optimize plugin
27+
run: sudo apt-get install pngquant
28+
29+
- name: Set up Python runtime
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: 3.x
33+
34+
- name: Install Python dependencies
35+
run: pip install mkdocs-monorepo-plugin mkdocs-redirects mkdocs-git-authors-plugin mkdocs-git-revision-date-localized-plugin mkdocs-git-committers-plugin-2 Pillow 'mkdocs-material[imaging]'
36+
37+
- name: Set up build cache
38+
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
39+
- uses: actions/cache@v4
40+
with:
41+
key: mkdocs-material-${{ env.cache_id }}
42+
path: .cache
43+
restore-keys: |
44+
mkdocs-material-
45+
46+
- name: Install Insiders build
47+
env:
48+
MKDOCS_TOKEN: ${{ secrets.MKDOCS_SECRET }}
49+
run: pip install git+https://${MKDOCS_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git
50+
- run: mkdocs gh-deploy --clean

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
1-
# SparkFun_Spectral_Sensor_Breakout_AS7343_Qwiic
2-
Qwiic Breakout for the 14-channel Multi-Spectral Sensor AS7343 from AMS.
1+
SparkFun Spectral Sensor - AS7343 (Qwiic)
2+
=========================================
3+
[![Banner image for Spectral Sensor - AS7343](./docs/assets/img/AS7343_GH_Banner.png)](https://www.sparkfun.com/sparkfun-spectral-sensor-as7343-qwiic.html)
4+
5+
6+
The SparkFun Spectral Sensor Breakout - AS7343 (Qwiic) offers a highly accurate but compact spectral analysis tool for both the visible spectrum and near-infrared. The AS7343 senses light between ~380mn to 1000mn over 14 channels with 11 color bands across the visible spectrum, one near-infrared channel, one clear channel (full sensing spectrum) along with flicker detection. The AS7343 also has an interrupt pin to trigger events based on specific measurements from the sensor as well as a programmable GPIO pin to help synchronize measurements with external devices. This breakout comes standard with a bright white LED for taking measurements but also includes connection points for users who wish to use their own LED if needed.
7+
8+
Repository Contents
9+
-------------------
10+
11+
* **/Documentation** - Data sheets, additional product information
12+
* **/Hardware** - Eagle design files (.brd, .sch)
13+
* **/Production** - Production panel files (.brd)
14+
* **/docs** - Documentation files for the Spectral UV Sensor
15+
* **/overrides** - Overrides for GitHub pages content
16+
17+
Documentation
18+
--------------
19+
* **[Arduino Library](https://github.com/sparkfun/SparkFun_AS7343_Arduino_Library/tree/main)** - Arduino library for the Spectral Sensor - AS7343 (Qwiic).
20+
* **[Python Package](https://github.com/sparkfun/qwiic_as7343_py)** - Python package for the Spectral Sensor - AS7343 (Qwiic)
21+
* **[Hookup Guide](https://docs.sparkfun.com/SparkFun_Spectral_Sensor_Breakout_AS7343_Qwiic)** - Basic hookup guide for the Spectral Sensor - AS7343 (Qwiic).
22+
23+
Product Versions
24+
----------------
25+
* [SEN-23220](https://www.sparkfun.com/sparkfun-spectral-sensor-as7343-qwiic.html) - Spectral Sensor - AS7343 (Qwiic)
26+
27+
License Information
28+
-------------------
29+
30+
This product is _**open source**_!
31+
32+
Please review the LICENSE.md file for license information.
33+
34+
If you have any questions or concerns on licensing, please contact technical support on our [SparkFun forums](https://forum.sparkfun.com/viewforum.php?f=152).
35+
36+
Distributed as-is; no warranty is given.
37+
38+
- Your friends at SparkFun.

docs/arduino_examples.md

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Let's take a closer look at the examples included in the SparkFun AS7343 Arduino
22

33
## Example 1 - Basic Readings
44

5-
The first example sets up the AS7343 to operate with default settings and outputs data from just four channels (Red, Green, Blue and NIR). Open the example in Arduino by navigating to **File** > **Examples** > **SparkFun AS7343 Arduino Library** > **Example_01_BasicReadings**. Next, select your board (RedBoard IoT - ESP32) and Port and click the "Upload" button. After the code finishes compiling and uploading, open the [serial monitor]() with the baud set to **115200** and you should see readings for red, blue, green and NIR print out like the screenshot below shows:
5+
The first example sets up the AS7343 to operate with default settings and outputs data from just four channels (Red, Green, Blue and NIR). Open the example in Arduino by navigating to **File** > **Examples** > **SparkFun AS7343 Arduino Library** > **Example_01_BasicReadings**. Next, select your board (RedBoard IoT - ESP32) and Port and click the "Upload" button. After the code finishes compiling and uploading, open the [serial monitor](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-serial-monitor/) with the baud set to **115200** and you should see readings for red, blue, green and NIR print out like the screenshot below shows:
66

77
<figure markdown>
88
[![Screenshot of example 1 serial print](./assets/img/AS7343_Arduino_Example1.jpg){ width="600"}](./assets/img/AS7343_Arduino_Example1.jpg "Click to enlarge")
@@ -12,13 +12,36 @@ The first example sets up the AS7343 to operate with default settings and output
1212

1313
Example 2 - All Channels shows how to set up the AS7343 with default settings to print out all spectral data from the sensor. This example is nearly identical to the first outside of the serial data printed out. Instead of getting and printing data from four specific channels, this example requests data from all channels and prints it as comma separated values. Open the example in Arduino by navigating to **File** > **Examples** > **SparkFun AS7343 Arduino Library** > **Example_02_AllChannels**.
1414

15-
In order to get data from all channels, the AS7343 takes measurements in three cycles with each one stepping through four individual channels combined with readings from the Clear/VIS and Flicker Detect/FD which is then stored in the sensor's data registers. The example prints out spectral data stepping through each channel from 0 to 17 following the format of **value needed**.
15+
In order to get data from all channels, the AS7343 takes measurements in three cycles with each one stepping through four individual channels combined with readings from the Clear/VIS and Flicker Detect/FD which is then stored in the sensor's data registers. The example prints out spectral data stepping through each channel from 0 to 17 in comma-separated values:
16+
17+
```c++
18+
for (int channel = 0; channel < channelsRead; channel++)
19+
{
20+
Serial.print(myData[channel]);
21+
Serial.print(",");
22+
}
23+
24+
Serial.println();
25+
```
1626
1727
## Example 3 - Gain
1828
1929
The third example shows how to set up the AS7343 with specific Spectral Engines Gain Settigns (aka AGAIN) and cycle through the gain settings using serial commands. Open the example in Arduino by navigating to **File** > **Examples** > **SparkFun AS7343 Arduino Library** > **Example_03_Gain**. If necessary, select your board and port and click the "Upload" button. Open the serial terminal with the baud set to **115200** after the code finishes uploading.
2030
21-
The example accepts serial inputs of "+" and "-" to step up and down, respectively, through the available gain settings and prints out the value of the gain each time it's updated. The code also prints out spectral readings from all channels every 1 second so'll want to pay close attention to the serial monitor when adjusting the gain value to see the returned serial data like the screenshot below shows:
31+
The example accepts serial inputs of "+" and "-" to step up and down, respectively, through the available gain settings and prints out the value of the gain each time it's updated:
32+
33+
```c++
34+
if(Serial.available())
35+
{
36+
userInput = Serial.read();
37+
if (userInput == '+' || userInput == '-')
38+
{
39+
updateGainSetting(userInput);
40+
}
41+
}
42+
```
43+
44+
The code also prints out spectral readings from all channels every 1 second so'll want to pay close attention to the serial monitor when adjusting the gain value to see the returned serial data like the screenshot below shows:
2245

2346
<figure markdown>
2447
[![Screenshot of Example 3 - Gain serial printout.](./assets/img/AS7343_Arduino_Example3.jpg){ width="600"}](./assets/img/AS7343_Arduino_Example3.jpg "Click to enlarge")
@@ -36,16 +59,67 @@ Not sure which pins on your development board support the `attachInterrupt()` fu
3659
3760
## Example 5 - Flicker Detection
3861
39-
Example five shows how to set up and monitor flicker detection readings from the sensor. It sets up the AS7343 with default settings with flicker detection enabled and prints the values over serial.
62+
Example five shows how to set up and monitor flicker detection readings from the sensor. It sets up the AS7343 with default settings with flicker detection enabled. It then checks to see if flicker detection values are invalid or saturated and prints out for either case:
63+
64+
**Flicker Detection is Invalid**
65+
```c++
66+
if (fdValid == false)
67+
{
68+
Serial.print("Flicker Detection Measurement Invalid");
69+
Serial.println();
70+
delay(1000);
71+
return;
72+
}
73+
```
74+
**Flicker Detection Saturated**
75+
```c++
76+
if (fdSaturation == true)
77+
{
78+
Serial.print("Flicker Detection Saturation Detected");
79+
Serial.println();
80+
delay(1000);
81+
return;
82+
}
83+
```
84+
85+
If the flicker detection value is valid and not saturated, it reads the value and prints it in Hz over serial:
86+
87+
```c++
88+
if(fdValid == true && fdSaturation == false)
89+
{
90+
if (fdFrequency == 0) // if getFlickerDetectionFrequency() returns 0, no frequency detected
91+
Serial.print("No Flicker Detected");
92+
else
93+
{
94+
Serial.print("Flicker Detected at frequency: ");
95+
Serial.print(fdFrequency);
96+
Serial.print("Hz");
97+
}
98+
Serial.println();
99+
}
100+
101+
delay(1000);
102+
```
40103

41104
## Example 6 - Sleep
42105

43-
Example six shows how to put the AS734 in and out of Sleep Mode to take intermittent measurements.
106+
Example six shows how to put the AS734 in and out of "sleep" to take intermittent measurements. Note, the AS7343 [datasheet](./assets/component_documentation/AS7343_DS001046_6-00.pdf) refers to each mode of operation as Sleep, Idle and Active. There is no direct control of a power mode but we can turn off the Measurement and the Power ON bits in the Enable register to put the AS7343 into a low power state that draws ~350uA. This example creates helper functions to wake the sensor, take a reading and then put the sensor back to sleep once every five seconds in the main loop:
107+
108+
```c++
109+
void loop()
110+
{
111+
takeReading(); // Wake up and take a reading from the sensor
112+
113+
sleepSensor(); // Disables measurement (IDLE) and powers off (SLEEP)
114+
115+
delay(5000); // Wait 5 seconds to allow reading sleep current if needed.
116+
}
117+
```
44118

45119
## Example 7 - Web Terminal Bar Graph
46120

47-
The seventh example takes data from all of the AS7343's channels (visible spectrum, NIR and clear) and formats it in a way to work with the SparkFun Online Serial Terminal to display the readings in a colorful bar graph. After uploading the code, head to the [SparkFun Web Serial Plotter]() site, select the COM port with the baud set to <b>115200</b> and click connect. You should start to see serial data print out in the top window along with a bar graph matching the channel data in the bottom window:
121+
The seventh example takes data from all of the AS7343's channels (visible spectrum, NIR and clear) and formats it in a way to work with the SparkFun [Web Serial Plotter](https://docs.sparkfun.com/SparkFun_WebSerialPlotter/) tool to display the readings in a colorful bar graph. After uploading the code, open the [SparkFun Web Serial Plotter](https://docs.sparkfun.com/SparkFun_WebSerialPlotter/) site, select the COM port with the baud set to <b>115200</b> and click connect. You should start to see serial data print out in the top window along with a bar graph matching the channel data in the bottom window:
48122

49123
<figure markdown>
50-
[![Gif of bar graph demo](./assets/img/spectral_bars_v10.gif)](./assets/img/spectral_bars_v10.gif "Click to enlarge")
124+
[![Gif of bar graph demo](./assets/img/spectral_bars_v10.gif){ width="600"}](./assets/img/spectral_bars_v10.gif "Click to enlarge")
51125
</figure>

docs/assets/img/AS7343_GH_Banner.png

675 KB
Loading

docs/assets/img/AS7343_HG_Banner.png

675 KB
Loading

docs/hardware_overview.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Let's take a closer look at the AS7343 and other hardware on the SparkFun Spectr
66

77
## AS7343 Spectral Sensor
88

9-
The AS7343 from AMS<sup>&trade;</sup> measures irradiated, reflected and transmitted light in both the visible spectrum and near-infrared (NIR). The sensor package has 14 channels (12 for visible light, 1 for NIR and 1 for flicker detection).
9+
The AS7343 from AMS<sup>&trade;</sup> measures irradiated, reflected and transmitted light in both the visible spectrum and near-infrared (NIR). The sensor features 14 channels in a 5x5 photodiode array, enabling the detection of 11 specific color bands across the visible spectrum. Additionally, dedicated photodiodes on the outer edges of this array are designed for near-infrared (845-865 nm) and flicker detection. It has exceptional sensitivity for measuring reflected, emitted and transmitted light even in low-light environments and also behind tinted glass.
1010

1111
## Power
1212

@@ -26,4 +26,8 @@ The board has three solder jumpers labeled <b>I2C</b>, <b>PWR</b> and <b>WLED</b
2626

2727
## Board Dimensions
2828

29-
The SparkFun Spectral Sensor Breakout - AS7343 matches the Qwiic breakout standard and measures 1" x 1" (22.5mm x 22.5mm) and has four mounting holes that fit a [4-40 screw]().
29+
The SparkFun Spectral Sensor Breakout - AS7343 matches the Qwiic breakout standard and measures 1" x 1" (22.5mm x 22.5mm) and has four mounting holes that fit a [4-40 screw](https://www.sparkfun.com/screw-phillips-head-1-4-4-40-10-pack.html).
30+
31+
<figure markdown>
32+
[![Dimensional drawing](./assets/board_files/SparkFun_AS7343_Qwiic-Dimensions.jpg){ width="600"}](./assets/board_files/SparkFun_AS7343_Qwiic-Dimensions.jpg "Click to enlarge")
33+
</figure>

docs/introduction.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
1+
<figure markdown>
2+
![Spectral Sensor Breakout Banner Image](./assets/img/AS7343_HG_Banner.png)
3+
</figure>
24

35
The SparkFun Spectral Sensor Breakout - AS7343 (Qwiic) offers a highly accurate but compact spectral analysis tool for both the visible spectrum and near-infrared. The AS7343 senses light between ~380mn to 1000mn over 14 channels with 11 color bands across the visible spectrum, one near-infrared channel, one clear channel (full sensing spectrum) along with flicker detection. The AS7343 also has an interrupt pin to trigger events based on specific measurements from the sensor as well as a programmable GPIO pin to help synchronize measurements with external devices. This breakout comes standard with a bright white LED for taking measurements but also includes connection points for users who wish to use their own LED if needed.
46

docs/micropython_examples.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
Let's take a quick look at each example included in the SparkFun AS7343 Python package. Note, the naming of these examples matches the examples in the Arduino library and skips from 3 to 5 as this package does not have an interrupt example (Example 4 in the Arduino library).
2+
3+
## Example 1 - Basic Readings
4+
5+
This simple example demonstrates how to set up the AS7343 with default settings and though it does set the AS7343 to report data from all 18 channels it only prints data for four channels (Red, Green, Blue and NIR) using this command:
6+
7+
```py
8+
print(myAS7343.get_blue(), end=',')
9+
print(myAS7343.get_red(), end=',')
10+
print(myAS7343.get_green(), end=',')
11+
print(myAS7343.get_nir(), end=',\n')
12+
```
13+
14+
## Example 2 - All Channels
15+
16+
Example 2 demonstrates how to set up the AS7343 to output data from all channels on the sensor in comma-separated values by steping through all channels:
17+
18+
```py
19+
for i in range(0, myAS7343.kNumChannels):
20+
print(myAS7343.get_data(i), end=',')
21+
print()
22+
```
23+
24+
## Example 3 - Gain
25+
26+
The third example shows how to set the gain for the AS7343. It defaults to set the gain as `512x` but you can adjust it in this line:
27+
28+
```py
29+
if not myAS7343.set_a_gain(myAS7343.kAgain64):
30+
```
31+
32+
Refer to the main .py file [here](https://github.com/sparkfun/qwiic_as7343_py/blob/master/qwiic_as7343.py#L102) for all allowed values for gain settings.
33+
34+
## Example 5 - Flicker Detection
35+
36+
The Flicker Detection example demonstrates how to use the AS7343's flicker detection feature. It initializes the sensor with default settings and then prints out flicker detection vlues in Hz to the serial monitor:
37+
38+
```py
39+
if fdFrequency == 0:
40+
print("No flicker detected")
41+
else:
42+
print("Flicker detected at frequency: {} Hz".format(fdFrequency))
43+
44+
time.sleep(1)
45+
```
46+
47+
## Example 6 - Sleep
48+
49+
The sixth example shows how to create a `def` to cycle the AS7343 in and out of "sleep" between measurement reports to help conserve power:
50+
51+
```py
52+
def sleep_device(device):
53+
# Disable spectral measurements
54+
if not device.spectral_measurement_disable():
55+
print("Failed to disable spectral measurements", file=sys.stderr)
56+
return
57+
print("Spectral measurements disabled")
58+
59+
# Power off the device
60+
if not device.power_off():
61+
print("Failed to power off the device", file=sys.stderr)
62+
return
63+
print("Device powered off")
64+
```
65+
66+
The main example then initializes the sensor with default settings, takes readings, puts it to sleep for 5 seconds and then loops:
67+
68+
```py
69+
while True:
70+
# Take a reading
71+
take_reading(myAS7343)
72+
73+
# Put the device to sleep
74+
sleep_device(myAS7343)
75+
76+
# Wait 5 seconds before taking another reading
77+
time.sleep(5.0)
78+
```
79+
80+
Though there is no direct control of a power mode, the example turns off the measurement and Power ON bits in the Enable register to put the sensor into a low power state so it draws ~350&micro;A.
81+
82+
## Example 7 - Web Bar Graph
83+
84+
Example 7 shows how to use the Spectral Sensor with the SparkFun [Web Serial Plotter](https://docs.sparkfun.com/SparkFun_WebSerialPlotter/) to display spectral data from all channels in a neat and colorful bar graph. You'll need to run this on a microcontroller like the [IoT RedBoard - ESP32 MicroPython](https://www.sparkfun.com/sparkfun-iot-redboard-esp32-micropython-development-board.html) as the Web Serial Plotter connects over a serial COM port. The code initializes the AS7343 with default settings and then prints out the comma-separated values in a format compatible with the web serial plotter:
85+
86+
```py
87+
print(f"{myAS7343.get_data(myAS7343.kChPurpleF1405nm)},"
88+
f"{myAS7343.get_data(myAS7343.kChDarkBlueF2425nm)},"
89+
f"{myAS7343.get_data(myAS7343.kChBlueFz450nm)},"
90+
f"{myAS7343.get_data(myAS7343.kChLightBlueF3475nm)},"
91+
f"{myAS7343.get_data(myAS7343.kChBlueF4515nm)},"
92+
f"{myAS7343.get_data(myAS7343.kChGreenF5550nm)},"
93+
f"{myAS7343.get_data(myAS7343.kChGreenFy555nm)},"
94+
f"{myAS7343.get_data(myAS7343.kChOrangeFxl600nm)},"
95+
f"{myAS7343.get_data(myAS7343.kChBrownF6640nm)},"
96+
f"{myAS7343.get_data(myAS7343.kChRedF7690nm)},"
97+
f"{myAS7343.get_data(myAS7343.kChDarkRedF8745nm)},"
98+
f"{myAS7343.get_data(myAS7343.kChVis1)},"
99+
f"{myAS7343.get_data(myAS7343.kChNir855nm)}\n", end='')
100+
```
101+
102+
After running the example, open the [Web Serial Plotter](https://docs.sparkfun.com/SparkFun_WebSerialPlotter/) and select the COM port and click "Connect" and you should see serial data print out in the top window and a nice colorful bar graph in the bottom window like the gif below shows:
103+
104+
<figure markdown>
105+
[![Gif of serial plotter bar graph spectral data](./assets/img/spectral_bars_v10.gif){ width="600"}](./assets/img/spectral_bars_v10.gif "Click to enlarge")
106+
</figure>

0 commit comments

Comments
 (0)