Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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)
);
});
});
}
@faermanj

This comment has been minimized.

Copy link

@faermanj faermanj commented Dec 16, 2019

Thanks, that helped me a lot. How did you find the data handle (0x002d) ?

@art0

This comment has been minimized.

Copy link

@art0 art0 commented Apr 21, 2020

Do you know where to fetch the status of the battery?

@chuckbenz

This comment has been minimized.

Copy link

@chuckbenz chuckbenz commented Sep 9, 2020

Unfortunately, my TH1 returns just 5 bytes with that data handle (from gattool: 02 2e 00 f4 ff), and that doesn't seem to vary over time. Any hints as to how to explore further? I poked at other handles and didn't find any that returned 6 bytes.

@uvolmer

This comment has been minimized.

Copy link

@uvolmer uvolmer commented Nov 24, 2020

I'm not sure at the moment, but you may try --handle=0x0028

@chuckbenz

This comment has been minimized.

Copy link

@chuckbenz chuckbenz commented Dec 1, 2020

Handle 0x0028 works for me - I get 7 bytes, and the first 4 match 100x the current temp (in C) and humidity. Example: 57 02 da 20 01 a9 8f
(side note - I'm not sure why I was expecting 6 bytes in my Sep 9 comment - I apparently miscounted).
Thanks!

@aphetor-dev

This comment has been minimized.

Copy link

@aphetor-dev aphetor-dev commented Jan 6, 2021

I have an Inkbird TH-1 Plus (with display) and I believe the handle is 0x23

The characteristic name is "Real-time data"

Here's an example reading: 24-09-C7-0F-00-E3-96

First 2 bytes are temp, second humidity - in C and % x100

What are the last 3?

@wattsie

This comment has been minimized.

Copy link

@wattsie wattsie commented Jan 29, 2021

I have an Inkbird TH-1 Plus (with display) and I believe the handle is 0x23
The characteristic name is "Real-time data"
Here's an example reading: 24-09-C7-0F-00-E3-96
First 2 bytes are temp, second humidity - in C and % x100
What are the last 3?

I think the next byte (4th) shows if Internal "00" or external "01" sensor is being measured.

Not sure how to decode last two.
Might be a crc (maybe crc16) not checked.

Cheers.

@dasJ

This comment has been minimized.

Copy link

@dasJ dasJ commented Mar 5, 2021

The CRC in use is modbus crc16

2 Bytes Temperature
2 Bytes Humidity
1 Byte  Sensor (0 → Internal, 1 → External)
2 Bytes Modbus CRC16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment