Skip to content

Instantly share code, notes, and snippets.

Created Jul 1, 2020
What would you like to do?
// This program receives BLE advertisements from shower consumption devices and displays the data inside.
// Installation: see
const noble = require('@abandonware/noble');
noble.on('stateChange', async (state) => {
if (state === 'poweredOn') {
noble.startScanning([], true);
noble.on('discover', async (peripheral) => {
if (peripheral.advertisement.localName != "SHOWER") {
const duration_in_seconds = peripheral.advertisement.manufacturerData.readUInt16BE(9);
const temperature = peripheral.advertisement.manufacturerData.readUInt16BE(11) / 10.0;
const litres = peripheral.advertisement.manufacturerData.readUInt16BE(13);
const id = peripheral.advertisement.manufacturerData.readUInt16BE(15);
console.log("Streamsave", id, "RSSI:", peripheral.rssi, "duration:", duration_in_seconds, "temperature:", temperature, "litres:", litres);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment