This website is available for multi language.

obniz Parts Library

MESH_100PA

GitHub
MESH_100PA
Usable Devices :
obniz_board
m5stickc
obnizble
esp32
esp32gateway
m5stackbasic
ak-030
obnizble_lte
obniz_plc

MESH-100PA (MESH Brightness)

MESH-100PA (MESH Brightness) is an app-enabled light sensor of MESH blocks.

MESH official web site is here.

Requirement

MESH block : version 1.2.5 or higher

Use case

// Example
const MESH_100PA = Obniz.getPartsClass('MESH_100PA');
obniz.ble.scan.onfind = async (peripheral) => {
    if (!MESH_100PA.isMESHblock(peripheral)) {
        return;
    }
    console.log('found');

    // Create an instance
    const brightnessBlock = new MESH_100PA(peripheral);

    // Connect to the Brightness block
    await brightnessBlock.connectWait();
    console.log(`connected: ${brightnessBlock.peripheral.localName}`);
    
    // Get sensor data
    const res = await brightnessBlock.getSensorDataWait();
    console.log('proximity: ' + res.proximity + ', brightness: ' + res.brightness);
};
// Example
const MESH_100PA = Obniz.getPartsClass('MESH_100PA');
obniz.ble.scan.onfind = async (peripheral) => {
    if (!MESH_100PA.isMESHblock(peripheral)) {
        return;
    }
    console.log('found');

    // Create an instance
    const brightnessBlock = new MESH_100PA(peripheral);

    // Connect to the Brightness block
    await brightnessBlock.connectWait();
    console.log(`connected: ${brightnessBlock.peripheral.localName}`);
    
    // Set event handler
    brightnessBlock.onSensorEvent = ((proximity, brightness) => {
        console.log('proximity: ' + proximity + ', brightness: ' + brightness);
    });

    // Prepare params (See the linked page below for more information.)
    const notifyMode = MESH_100PA.NotifyMode.ALWAYS;
    
    // Write
    brightnessBlock.setMode(notifyMode);
};

Related documents

MESH technical specification.

Supported from: obniz.js 3.23.0