Created
December 12, 2021 07:14
-
-
Save deton/fd3540212b6372683507593fce25bb5a to your computer and use it in GitHub Desktop.
read decibel value from GM1356 Digital Sound Level Meter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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