Skip to content

Commit

Permalink
Added examples for AS7265x and AS7341 spectrometers, with JSON files …
Browse files Browse the repository at this point in the history
…for use with Serial Studio
  • Loading branch information
tigoe committed Jul 27, 2021
1 parent 0b8aafb commit e3da32e
Show file tree
Hide file tree
Showing 4 changed files with 434 additions and 7 deletions.
172 changes: 172 additions & 0 deletions LightSensors/AS7265x_spectrometer/AS7265x.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
{
"t": "AS7365x",
"g": [
{
"t": "Readings",
"d": [
{
"t": "395nm",
"v": "%1",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "435nm",
"v": "%2",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "460nm",
"v": "%3",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "485nm",
"v": "%4",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "510nm",
"v": "%5",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "535nm",
"v": "%6",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "560nm",
"v": "%7",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "585nm",
"v": "%8",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "645nm",
"v": "%9",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "705nm",
"v": "%10",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "900nm",
"v": "%11",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "940nm",
"v": "%12",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "610nm",
"v": "%13",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "680nm",
"v": "%14",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "730nm",
"v": "%15",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "760nm",
"v": "%16",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "810nm",
"v": "%17",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
},
{
"t": "860nm",
"v": "%18",
"g": true,
"u": "counts",
"w": "bar",
"min": 0,
"max": 65535
}
]
}
]
}
76 changes: 76 additions & 0 deletions LightSensors/AS7265x_spectrometer/AS7265x_spectrometer.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
AS7265x spectrometer test
Works with MKR1010, MKR1000, Nano 33 IoT
Uses the following libraries:
http://librarymanager/All#SparkFun_AS7265X (for the sensor)
created 22 Jun 2021
by Tom Igoe
*/
// include required libraries and config files
#include <SparkFun_AS7265X.h>

// initialize the light sensor:
AS7265X sensor;

void setup() {
Serial.begin(9600); // initialize serial communication
// if serial monitor is not open, wait 3 seconds:
if (!Serial) delay(3000);
if (!sensor.begin()) {
Serial.println("Sensor is not responding. Please check wiring.");
while (true)
;
}
// print header labels:
Serial.println("395nm, 435nm, 460nm, 485nm, 510nm, 535nm, \
560nm, 585nm, 645nm, 705nm, 900nm, 940nm, \
610nm, 680nm, 730nm, 760nm, 810nm, 860nm");
}

void loop() {

// Read all 18 channels. This takes several seconds:
sensor.takeMeasurements();
// print a header:
Serial.print("/* ");
// Print sensor readings:
Serial.print(sensor.getCalibratedA());
Serial.print(",");
Serial.print(sensor.getCalibratedB());
Serial.print(",");
Serial.print(sensor.getCalibratedC());
Serial.print(",");
Serial.print(sensor.getCalibratedD());
Serial.print(",");
Serial.print(sensor.getCalibratedE());
Serial.print(",");
Serial.print(sensor.getCalibratedF());
Serial.print(",");
Serial.print(sensor.getCalibratedG());
Serial.print(",");
Serial.print(sensor.getCalibratedH());
Serial.print(",");
Serial.print(sensor.getCalibratedI());
Serial.print(",");
Serial.print(sensor.getCalibratedJ());
Serial.print(",");
Serial.print(sensor.getCalibratedK());
Serial.print(",");
Serial.print(sensor.getCalibratedL());
Serial.print(",");
Serial.print(sensor.getCalibratedR());
Serial.print(",");
Serial.print(sensor.getCalibratedS());
Serial.print(",");
Serial.print(sensor.getCalibratedT());
Serial.print(",");
Serial.print(sensor.getCalibratedU());
Serial.print(",");
Serial.print(sensor.getCalibratedV());
Serial.print(",");
Serial.print(sensor.getCalibratedW());
// print a footer:
Serial.println(" */");
}
Loading

0 comments on commit e3da32e

Please sign in to comment.