2jcie-ble-decode 中文文档教程

发布于 4年前 浏览 31 项目主页 更新于 3年前

2jcie-ble-decode

一个简单的包,用于解码 Omron 的 2JCIE-BU01 传感器发送的数据帧

Description

该包将允许与 Omron 的 2JCIE-BU01 传感器轻松连接 BLE。 有类似的传感器也可以工作,但没有经过测试。

不支持(在此包中)通过 USB 读取数据。

Setup

该软件包能够解码“传感器数据”和“计算数据”消息类型。 默认情况下,传感器仅传输“传感器数据”,但您可以使用 Omron 的移动应用程序将其配置为发送两者。

PlatformApp Link
App StoreENV Monitor
Google PlayENV Monitor

Usage

  1. Install the package with npm i --save 2jcie-ble-decode
  2. Require the dependency
  3. Instantiate the dependency with optional configuration
  4. Register event handlers
const Sensor = require('2jcie-ble-decode');
const sensor = new Sensor();

(() => {
    // Listener for all events
    sensor.on('event', (data) => console.log(data));

    // Listeners for specific event types (options are 'calculation' and 'sensor')
    sensor.on('calculation', handleCalculationData);
    sensor.on('sensor', handleSensorData);

    // Listener for error events
    sensor.on('error', handleErrors);

}) ();

Configuration

构造函数接受一个选项对象,该对象可以省略以接受默认值:

const sensor = new Sensor();

您可以向 Sensor() 构造函数提供一个选项对象参数,如下所示:

const sensor = new Sensor({
    // Activate test mode, which doesn't require Bluetooth hardware or a sensor. 
    // You will receive alternating sample "sensor" and "calculation" events ever 1s
    // Sample events defined in ./mock/example.js
    testMode: false, // defaults to false

    // Activate the whitelist.  Ignore any events not originating from one of these addresses
    whitelist: [ 'yourSensorMAC' ], 

    // If omitted, a Barnowl instance will be created and register the BarnowlHci listener
    // Use this if you already have a Barnowl instance in your project and you just want to
    // add the ability to process Omron data frames.
    barnowl: existingBarnowlInstance,

    // Minimum number of seconds to wait before emitting another reading.
    interval: 5

});

Output

输出将在以下格式:

'sensor' Event Type:

{
    "dataType": 3,
    "sequenceNumber": 54,
    "temperature": 23.97,
    "relativeHumidity": 49.25,
    "ambientLight": 361,
    "barometricPressure": 1018.602,
    "soundLevel": 51.58,
    "eTVOC": 25,
    "eCO2": 565,
    "messageType": "sensor",
    "temperatureF": 75.146,
    "deviceId": "d13e50866f01"
}

'calculation' Event Type:

{
    "dataType": 3,
    "sequenceNumber": 54,
    "discomfortIndex": 70.36,
    "heatStrokeRisk": 20.26,
    "vibration": 0,
    "siValue": 0,
    "peakGroundAcceleration": 0,
    "seismicIntensity": 0,
    "accXAxis": 894.3,
    "accYAxis": 6305.9,
    "accZAxis": 6249.9,
    "messageType": "calculation",
    "deviceId": "d13e50866f01"
}

Resources

OMRON 2JCIE-BU01 手册:https ://omronfs.omron.com/en_US/ecb/products/pdf/A279-E1-01.pdf

2jcie-ble-decode

A simple package to decode the data frames sent by the 2JCIE-BU01 sensor from Omron

Description

This package will allow for easy BLE interfacing with the 2JCIE-BU01 sensor from Omron. There are similar sensors that may also work, but are not tested.

There's no support (in this package) for reading data via USB.

Setup

This package is capable of decoding both "Sensor Data" and "Calculation Data" message types. The sensor only transmits "Sensor Data" by default, but you can use Omron's mobile app to configure it to send both.

PlatformApp Link
App StoreENV Monitor
Google PlayENV Monitor

Usage

  1. Install the package with npm i --save 2jcie-ble-decode
  2. Require the dependency
  3. Instantiate the dependency with optional configuration
  4. Register event handlers
const Sensor = require('2jcie-ble-decode');
const sensor = new Sensor();

(() => {
    // Listener for all events
    sensor.on('event', (data) => console.log(data));

    // Listeners for specific event types (options are 'calculation' and 'sensor')
    sensor.on('calculation', handleCalculationData);
    sensor.on('sensor', handleSensorData);

    // Listener for error events
    sensor.on('error', handleErrors);

}) ();

Configuration

The constructor accepts an options object which can be omitted to accept defaults:

const sensor = new Sensor();

You can provide an options object parameter to the Sensor() constructor as follows:

const sensor = new Sensor({
    // Activate test mode, which doesn't require Bluetooth hardware or a sensor. 
    // You will receive alternating sample "sensor" and "calculation" events ever 1s
    // Sample events defined in ./mock/example.js
    testMode: false, // defaults to false

    // Activate the whitelist.  Ignore any events not originating from one of these addresses
    whitelist: [ 'yourSensorMAC' ], 

    // If omitted, a Barnowl instance will be created and register the BarnowlHci listener
    // Use this if you already have a Barnowl instance in your project and you just want to
    // add the ability to process Omron data frames.
    barnowl: existingBarnowlInstance,

    // Minimum number of seconds to wait before emitting another reading.
    interval: 5

});

Output

Output will be in the following format:

'sensor' Event Type:

{
    "dataType": 3,
    "sequenceNumber": 54,
    "temperature": 23.97,
    "relativeHumidity": 49.25,
    "ambientLight": 361,
    "barometricPressure": 1018.602,
    "soundLevel": 51.58,
    "eTVOC": 25,
    "eCO2": 565,
    "messageType": "sensor",
    "temperatureF": 75.146,
    "deviceId": "d13e50866f01"
}

'calculation' Event Type:

{
    "dataType": 3,
    "sequenceNumber": 54,
    "discomfortIndex": 70.36,
    "heatStrokeRisk": 20.26,
    "vibration": 0,
    "siValue": 0,
    "peakGroundAcceleration": 0,
    "seismicIntensity": 0,
    "accXAxis": 894.3,
    "accYAxis": 6305.9,
    "accZAxis": 6249.9,
    "messageType": "calculation",
    "deviceId": "d13e50866f01"
}

Resources

OMRON 2JCIE-BU01 Manual: https://omronfs.omron.com/en_US/ecb/products/pdf/A279-E1-01.pdf

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文