Documentation ¶
Overview ¶
Package as7262 controls an AMS 6 channel visible spectral sensor via an i2c interface. The as7262 features 6 spectral channels spaced at 450, 500, 550, 570, 600, 650 nm and includes 2 integrated LED drivers.
Datasheet ¶
https://ams.com/documents/20143/36005/AS7262_DS000486_2-00.pdf
Example ¶
package main import ( "fmt" "log" "time" "periph.io/x/periph/conn/physic" "periph.io/x/periph/conn/i2c/i2creg" "periph.io/x/periph/experimental/devices/as7262" "periph.io/x/periph/host" ) func main() { // Make sure periph is initialized. if _, err := host.Init(); err != nil { log.Fatal(err) } // Open default I²C bus. bus, err := i2creg.Open("") if err != nil { log.Fatalf("failed to open I²C: %v", err) } defer bus.Close() // Create a new spectrum sensor. sensor, err := as7262.New(bus, &as7262.DefaultOpts) if err != nil { log.Fatalln(err) } // Read values from sensor. spectrum, err := sensor.Sense(25*physic.MilliAmpere, 500*time.Millisecond) if err != nil { log.Fatalln(err) } fmt.Println(spectrum) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOpts = Opts{ InterruptPin: nil, Gain: G1x, }
DefaultOpts are the recommended default options.
Functions ¶
This section is empty.
Types ¶
type Band ¶
Band has two types of measurement of relative spectral flux density.
Value ¶
Value are the calibrated readings. The accuracy of the channel counts/μW/cm2 is ±12%.
Counts ¶
Counts are the raw readings, there are approximately 45 counts/μW/cm2 with a gain of 16 (Gx16).
Wavelength ¶
Wavelength is the nominal center of a band, with a ±40nm bandwidth around the center. Wavelengths for the as7262 are: 450nm, 500nm, 550nm, 570nm, 600nm and 650nm.
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
Dev is a handle to the as7262 sensor.
func (*Dev) Gain ¶
Gain sets the gain of the sensor. There are four levels of gain 1x, 3.7x, 16x, and 64x.
func (*Dev) Sense ¶
Sense preforms a reading of relative spectral radiance of all the sensor bands.
Led Drive Current ¶
The AS7262 provides a current-limited integrated led drive circuit. Valid limits for the drive current are 0mA, 12.5mA, 25mA, 50mA and 100mA. If non valid values are given the next lowest valid value is used.
Resolution ¶
For best resolution it is recommended that for a specific led drive current that the senseTime or gain is increased until at least one of the bands returns a count above 10000. The maximum senseTime time is 714ms senseTime will be quantised into intervals of of 2.8ms. Actual time taken to make a reading is twice the senseTime.
type Spectrum ¶
type Spectrum struct { Bands []Band SensorTemperature physic.Temperature Gain Gain LedDrive physic.ElectricCurrent Integration time.Duration }
Spectrum is the reading from the sensor including the actual sensor state for the readings.