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

audiomoth-hid

v2.3.0

Published

AudioMoth USB interaction module.

Readme

AudioMoth-HID

A Node.js library for interfacing with AudioMoth devices over USB. The module is hosted on npm under the name 'audiomoth-hid'.

Usage

The module should be imported as normal:

var audiomoth = require('audiomoth-hid');

Asynchronous function calls then provide access to its functionality. To obtain the time used by the onboard clock:

audiomoth.getTime(function (err, date) {
	console.log("Time/date on device: " + date);
});

Set the onboard clock with a Date() object:

audiomoth.setTime(new Date(), function (err, date) {
	console.log("New time/date of device: " + date);
});

Get AudioMoth's unique 16 digit ID number:

audiomoth.getID(function (err, id) {
	console.log("Device unique ID: " + id);
});

Get string containing the current battery state of attached AudioMoth:

audiomoth.getBatteryState(function (err, batteryState) {
	console.log("Attached device's current battery state: " + batteryState);
});

Send application packet of max length 62 (message limit of 64 bytes, 2 bytes required for message identification) :

var packet = new Uint8Array(62);

Insert date object into packet

var date = new Date();
writeLittleEndianBytes(packet, 0, 4, date.valueOf() / 1000);

Insert 32 bit number into packet

var i = 10000;
writeLittleEndianBytes(packet, 4, 4, i);

Insert arbitrary 8 bit values into packet:

packet[8] = 5;
packet[9] = 0x00;
packet[10] = 0x01;
audiomoth.setPacket(packet, function (err, packet) {
	console.log("Data returned from application specific packet: " + packet);
});

Get application packet set in AudioMoth firmware:

audiomoth.getPacket(function (err, packet) {
	console.log("Data returned from application specific packet: " + packet);
});

Get firmware version set in AudioMoth firmware:

audiomoth.getFirmwareVersion(function (err, firmwareVersion) {
    console.log("Attached device's firmware version: " + firmwareVersion);
});

Get firmware description set in AudioMoth firmware:

audiomoth.getFirmwareDescription(function (err, firmwareDescription) {
    console.log("Attached device's firmware description: " + firmwareDescription);
});

Query AudioMoth to see if it supports switching to bootloader with a USB command:

audiomoth.queryBootloader(function (err, supportsBootloaderSwitch) {
    if (supportsBootloaderSwitch) {
        console.log("Attached device's firmware supports bootloader switching over HID.");
    } else {
        console.error("Attached device's firmware does not support bootloader switching over HID.");
    }
});

Switch AudioMoth to bootloader for flashing:

audiomoth.switchToBootloader(function (err, packet) {
    if (packet[0] === 0x0A) {
        if (packet[1] === 0x01) {
            console.log("Attached device switching to bootloader.");
        } else {
            console.error("Attached device's firmware does not support bootloader switching over HID.");
        }
    }
});

Query AudioMoth to see if it supports the USB HID bootloader:

audiomoth.queryUSBHIDBootloader(function (err, supportsUSBHIDBootloader) {
    if (supportsUSBHIDBootloader) {
        console.log("Attached device's firmware supports the USB HID bootloader.");
    } else {
        console.error("Attached device's firmware does not support the USB HID bootloader.");
    }
});

Send single USB HID packet:

audiomoth.sendPacketToUSBHIDBootloader(function (err, packet) {
	console.log("Data returned from USB HID bootloader: " + packet);
});

Send multiple USB HID packets:

audiomoth.sendMultiplePacketsToUSBHIDBootloader(function (err, packet) {
	console.log("Data returned from USB HID bootloader: " + packet);
});

Linux

The module will work as is on macOS and Windows. However, Linux prevents USB HID devices from being writable by default. This can be fixed by navigating to /lib/udev/rules.d/ and adding a file called 99-audiomoth.rules. The content of this file should by:

SUBSYSTEM=="usb", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="0002", MODE="0666"

Updating module

Execution permissions are lost when binaries are committed to npm repository from a Windows machine. To avoid this, all updates must be published from MacOS.

Example applications using this module

License

Copyright 2017 Open Acoustic Devices.

MIT license.