Skip to content

Instantly share code, notes, and snippets.

@viktoschi
Forked from onderweg/inkbird.js
Created October 23, 2020 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viktoschi/5aa9682cfa3de5108c83d0eb8cb6aed5 to your computer and use it in GitHub Desktop.
Save viktoschi/5aa9682cfa3de5108c83d0eb8cb6aed5 to your computer and use it in GitHub Desktop.
Read temperature and humidity data from Inkbird ibs-TH1.

This Gist contains an example code fragment of how to read temperature and humidity data from Inkbird ibs-TH1 bluetooth thermometer in NodeJS with Noble.

Note that you can also read values directly via command line with gatttool:

gatttool -b <MAC> --char-read --handle=0x002d

Example value:

c8 0a a8 16 00 49 88  
  • c8 0a uint16 Little Endian temperature value * 100
  • a8 16 uint16 Little Endian humidity value * 100

To find MAC adress of sensor, you can use hcitool.

sudo hcitool lescan

or bluetoothctl.

const DATA_HND = 0x002d;
const parseData = (data) => {
const rawTemp = data.readInt16LE(0);
const rawHum = data.readInt16LE(2);
return {
temperature: rawTemp / 100,
humidity: rawHum / 100
}
}
exports.readData = async (peripheral) => {
return new Promise((resolve, reject) => {
peripheral.readHandle(DATA_HND, function (error, data) {
if (error) {
reject(error);
}
resolve(
parseData(data)
);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment