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 🙏

© 2025 – Pkg Stats / Ryan Hefner

lsm6ds

v1.0.1

Published

An I2C driver for the LSM6DS accelerometer and gyroscope sensor family.

Downloads

183

Readme

A nodeJS I2C driver for the ST LSM6DS family of IMUs

This library uses the i2c-bus nodeJS package to communicate with the chip over I2C.

Supported modules

I only have the need for the ISM330DHCX, hence it's the only one both supported and tested. If you have any of the untested sensors then feel free to test them and submit a PR if they work correctly.

| Variant | Supported | Tested | |---------|-------------|-------------:| | ISM330DHCX | :white_check_mark: | :white_check_mark: | | LSM6DS3TR-C | :white_check_mark: | :x: | | LSM6DS33 | :white_check_mark: | :x: | | LSM6DS3 | :white_check_mark: | :x: | | LSM6DSO32 | :white_check_mark: | :x: | | LSM6DSOX | :white_check_mark: | :x: |

Supported functionality

  • Reading accelerometer and gyroscope data
  • Accelerometer and gyroscope range and rate configuration
  • Accelerometer high-pass filter configuration
  • FIFO batching support for accel and gyro data

Installation

npm install lsm6ds

Examples

Reading a single value at a time. Reading gyroscope data works identically.

const { ISM330DHCX } = require('lsm6ds');

(async () => {
  const sensor = new ISM330DHCX();
  try {
    await sensor.init({ accelRate: sensor.Rate.RATE_26_HZ });

    while (true) {
      const data = await sensor.readAccelerometer();
      console.log(`Accel: X=${data.x.toFixed(3)}g Y=${data.y.toFixed(3)}g Z=${data.z.toFixed(3)}g`);
      await new Promise((r) => setTimeout(r, 100));
    }
  } catch (err) {
    console.error('sensor init error', err);
    process.exit(1);
  }
})();

You can use the FIFO buffer to avoid the I2C overhead that comes from reading a single value at a time. For example, at 6.66kHz you can read ~200 samples every ~10ms instead of reading 1 sample every ~0.15ms. This means that even on non-realtime systems such as the Raspberry Pi you can utilize the full datarate, instead of skipping some readings due to timing issues. Fast-Mode Plus I2C mode is of course also required.

const { ISM330DHCX } = require('lsm6ds');

(async () => {
  const sensor = new ISM330DHCX();
  try {
    await sensor.init({ accelRate: sensor.Rate.RATE_6_66K_HZ });
    await sensor.setFIFOMode(sensor.FIFOModes.CONTINUOUS);
    await sensor.setAccelFIFOBatchRate(sensor.Rate.RATE_6_66K_HZ);

    while (true) {
      const data = await sensor.readFIFOData(await sensor.getFIFOSampleCount());
      
      console.log(`Got ${data.accel.length} samples`);
      await new Promise((r) => setTimeout(r, 10));
    }
  } catch (err) {
    console.error('sensor init error', err);
    process.exit(1);
  }
})();