npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@chirimen/as7341

v1.0.0

Published

CHIRIMEN driver for AS7341 sensor

Readme

@chirimen/as7341

CHIRIMEN driver for AS7341 (11-channel spectral color sensor)

ams-OSRAM製の11チャンネル分光カラーセンサー AS7341 用のCHIRIMENドライバです。 本ドライバの read() では、可視光域をカバーする8つの分光チャンネル(F1〜F8: 415nm〜680nm)に加え、Clear(全可視光)とNIR(近赤外)の計10チャンネルの値を取得できます。 光の色成分・スペクトル分析、色識別、光源の種類判定などの用途に利用できます。 測定時間(ATIME/ASTEP)とゲイン(0.5倍〜512倍)を設定可能です。

主な仕様

| 項目 | 内容 | | ---------------- | ---------------------------------- | | 型番 | AS7341 | | インターフェース | I2C | | I2Cアドレス | 0x39 | | 測定チャンネル | F1〜F8(415nm〜680nm)、Clear、NIR |

Installation

npm install @chirimen/as7341

Usage

import { requestI2CAccess } from "node-web-i2c";
import AS7341 from "@chirimen/as7341";
const sleep = (msec) => new Promise((resolve) => setTimeout(resolve, msec));

const i2cAccess = await requestI2CAccess();
const as7341 = new AS7341(i2cAccess.ports.get(1));

await as7341.init();

while (true) {
  // f1〜f8(各波長の強度)、clear(全可視光)、nir(近赤外)
  const { f1, f2, f3, f4, f5, f6, f7, f8, clear, nir } = await as7341.read();
  console.dir({ f1, f2, f3, f4, f5, f6, f7, f8, clear, nir });
  await sleep(1000);
}

API

new AS7341(i2cPort, slaveAddress = 0x39)

ドライバのインスタンスを生成します。

  • i2cPort: requestI2CAccess() で取得したI2Cポート
  • slaveAddress: I2Cアドレス(省略可。デフォルト値: 0x39

async init()

センサーを初期化します。チップIDの確認・電源ONの後、測定条件のデフォルト値 (ATIME=100、ASTEP=999、ゲイン=256倍)を設定します。 初期化に失敗した場合は null を返します。

async setATIME(value)

積分時間パラメータ ATIME を設定します(0255)。 範囲外の値を渡した場合は null を返します。

async setASTEP(value)

積分ステップ時間パラメータ ASTEP を設定します(065534)。 範囲外の値を渡した場合は null を返します。

async setGain(gain)

ADCのゲイン(倍率)を設定します。指定できる値は 0.5, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 のいずれかです。 無効な値を渡した場合は null を返します。

async read()

全チャンネルの測定を行い、結果をオブジェクトで返します。 SMUXの切り替えを伴う2回の測定(F1〜F4系→F5〜F8系)を内部で実行します。

{
  f1: number,    // 415nm
  f2: number,    // 445nm
  f3: number,    // 480nm
  f4: number,    // 515nm
  f5: number,    // 555nm
  f6: number,    // 590nm
  f7: number,    // 630nm
  f8: number,    // 680nm
  clear: number, // 全可視光
  nir: number    // 近赤外
}

データシート

参考