Skip to content

Instantly share code, notes, and snippets.

@deton
Created December 12, 2021 07:14
Show Gist options
  • Select an option

  • Save deton/fd3540212b6372683507593fce25bb5a to your computer and use it in GitHub Desktop.

Select an option

Save deton/fd3540212b6372683507593fce25bb5a to your computer and use it in GitHub Desktop.
read decibel value from GM1356 Digital Sound Level Meter
// read decibel value from GM1356 Digital Sound Level Meter
//
// https://github.com/gymnasty/gm1356
// https://github.com/pvachon/gm1356
// https://github.com/dobra-noc/gm1356
// https://github.com/PhilippCo/soundmeter
const HID = require('node-hid');
const device = new HID.HID(0x64bd, 0x74e3);
device.on('data', function (data) {
const db = (data[0] * 256 + data[1]) / 10;
console.log(db);
});
device.on('error', function (err) {
console.error(err);
});
const MEASURE_REQ = [0xb3, 0, 0, 0, 0, 0, 0, 0]; // XXX: need random data?
setInterval(function() {
device.write(MEASURE_REQ);
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment