8000 GitHub - Kampi/BeeLight: Zigbee light sensor device with Zigbee2MQTT support.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Kampi/BeeLight

Repository files navigation

BeeLight - Zigbee based light & environment sensor for Home Automation

Table of Contents

About

Open-Source Zigbee-based light and environmental sensor with Zigbee2MQTT support for your Home Automation with I. e. Home Assistant.

Rendering

Technical features

  • Cutting-edge MCU with an nRF54L, running Zephyr
  • Powered by a single coin cell
  • Can measure
    • Temperature
    • Humidity
    • Pressure
    • IAQ
    • CO2 equivalent
    • VOC equivalent
    • Light intensity
    • Battery voltage
  • Small housing (40x42 mm)
  • Very basic electronic → Can be assembled by hand very easily
  • Zigbee2MQTT compatibility

Block diagram

Before you start

The project directory contains the hardware as a KiCad 9 project, the firmware and the Zigbee2MQTT configuration. You can check it out with Git:

git clone https://github.com/Kampi/BeeLight
cd BeeLight
git submodule update --init --recursive
cd firmware/app
west init -l .
west update

Run the following commands to install the BSEC2 library:

west config manifest.group-filter +bsec
west update

You also need nrfutil and the nrf5sdk-tools to flash the production configuration to the sensor. First install nrfutil and then run the following command to install the SDK tools:

nrfutil install nrf5sdk-tools

PCB

The project uses Kibot to automatically generate all required output data. After installing it you can execute the following command to run it:

cd hardware
./kibot-launch.sh

As an alternative you can run it via CI/CD in GitHub.

NOTE
You have to provide a Mouser API key with a variable called MOUSER_KEY to make use of the KiCost feature in the Kibot job.

NOTE
The programming connector is optional and can be left out or unsoldered after flashing the device.

Firmware

Build the firmware

The firmware can be built with the following command:

cd firmware/app
west build --build-dir build . --pristine --board beelight@1/nrf54l15/cpuapp -- -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=config/debug.conf -DBOARD_ROOT=.

You also need a Zigbee network to test and integrate the device. I use Zigbee2MQTT running on a Raspberry Pi which allows me to connect my Zigbee network with my Home Automation.

NOTE
I do not support other Zigbee networks (like ZHA). The Zigbee standard allows you to connect the device with all other networks but I can´t deliver a functional integration for these networks. You have to do it on your own!

Generate the production config for the device

Using west

You can run the command west upload-config to build and upload your configuration to the device automatically.

Using the command line

You must flash a production config to the device, before you can use it with Zigbee. You can either use the prebuilt config from the project or adjust it according to your needs.

nrfutil nrf5sdk-tools zigbee production_config zigbee_config.yml zigbee_config.hex --offset 0x17a000
nrfjprog --program zigbee_config.hex --verify

NOTE
The offset 0x17a000 is taken from the PM_ZBOSS_NVRAM_END_ADDRESS macro in build/<app>/zephyr/include/generated/pm_config.h

Housing

The housing is optimized for 3D printing and needs ~12 g of filament (PLA). You can find all the needed files in the 3d-printing directory of this project.

Zigbee

The device uses different standard and custom cluster to report the data to the network.

Standard cluster

Cluster ID
Temperature 0x0402
Pressure 0x0403
Rel. Humidity 0x0405
Light 0x0400

Custom cluster

The device uses two custom cluster to report IAQ, VOC and CO2 to the network. Both clusters have three attributes for value, min_value, max_value and tolerance.

Cluster ID
IAQ 0x1A0A
VOC 0x1A0B
CO2 0x1A0C
Attribute ID
Value 0x0000
Min. Value 0x0001
Max. Value 0x0002
Tolerance 0x0003

Zigbee Dongle

Make sure to use a Zigbee 3 compatible dongle like SONOFF ZBDongle-E and update the firmware to the latest version to prevent issues. You can follow this guide if you use a SONOFF dongle.

Install the device to Zigbee2MQTT

NOTE
Because it´s not possible to use custom cluster with Zigbee2MQTT easily, so you must adjust the application directly to use the sensor. Please take a look into the directory z2m/data/external_converters/example if you want to check how the modified files look like.

  1. Download and install Zigbee2MQTT
  2. Copy the external converter from z2m/data_external_converters to the data directory of your Zigbee2MQTT installation
  3. Switch into the directory .../zigbee2mqtt/node_modules/zigbee-herdsman-converters/converters
  4. Open the file fromZigbee.js and add the following code before const converters = { ...converters1, ...converters2 }; at the end of the file
const converters3 = {
  BeeLight_iaq: {
    cluster: 'msIAQ',
    type: ['attributeReport', 'readResponse'],
    convert: (model, msg, publish, options, meta) => {
      const iaq = msg.data['measuredValue'];
      const tolerance = msg.data['tolerance'];
      const property = (0, utils_1.postfixWithEndpointName)('iaq', msg, model, meta);
      return { [property]: iaq };
    },
  },
  BeeLight_voc: {
    cluster: 'msVOC',
    type: ['attributeReport', 'readResponse'],
    convert: (model, msg, publish, options, meta) => {
      const voc = msg.data['measuredValue'];
      const tolerance = msg.data['tolerance'];
      const property = (0, utils_1.postfixWithEndpointName)('voc', msg, model, meta);
      return { [property]: voc };
    },
  },
  BeeLight_co2: {
    cluster: 'msCO2',
    type: ['attributeReport', 'readResponse'],
    convert: (model, msg, publish, options, meta) => {
      const co2 = msg.data['measuredValue'];
      const tolerance = msg.data['tolerance'];
      const property = (0, utils_1.postfixWithEndpointName)('co2', msg, model, meta);
      return { [property]: co2 };
    },
  },
};
  1. Change const converters = { ...converters1, ...converters2 }; to const converters = { ...converters1, ...converters2, ...converters3 };
  2. Save the file
  3. Switch to .../zigbee2mqtt/node_modules/zigbee-herdsman/dist/zspec/zcl/definition
  4. Open the file cluster.js and add the following cluster to the end of the list at the end of the file:
      ...
    },
    msIAQ: {
        ID: 6666,
        attributes: {
            measuredValue: { ID: 0, type: enums_1.DataType.UINT16 },
            minMeasuredValue: { ID: 1, type: enums_1.DataType.UINT16 },
            maxMeasuredValue: { ID: 2, type: enums_1.DataType.UINT16 },
            tolerance: { ID: 3, type: enums_1.DataType.UINT8 },
        },
        commands: {},
        commandsResponse: {},
    },
    msVOC: {
        ID: 6667,
        attributes: {
            measuredValue: { ID: 0, type: enums_1.DataType.UINT16 },
            minMeasuredValue: { ID: 1, type: enums_1.DataType.UINT16 },
            maxMeasuredValue: { ID: 2, type: enums_1.DataType.UINT16 },
            tolerance: { ID: 3, type: enums_1.DataType.UINT8 },
        },
        commands: {},
        commandsResponse: {},
    },
    msCO2: {
        ID: 6668,
        attributes: {
            measuredValue: { ID: 0, type: enums_1.DataType.UINT32 },
            minMeasuredValue: { ID: 1, type: enums_1.DataType.UINT32 },
            maxMeasuredValue: { ID: 2, type: enums_1.DataType.UINT32 },
            tolerance: { ID: 3, type: enums_1.DataType.UINT8 },
        },
        commands: {},
        commandsResponse: {},
    },
};
  1. Save the file
  2. Restart Zigbee2MQTT

The device can now be connected to your Zigbee network and with this to your Home Assistant.

Zigbee2MQTT HomeAssistant

Directory structure

  • 3d-print: All 3D print related files
  • cad: All relevant 3D models
  • docs: All kinds of project documentation like schematics, BOM, etc.
    • drawings: 2D drawings for subcomponents, etc.
    • images: All documentation related images
  • hardware: KiCad project for the PCB
  • firmware: Zephyr project for the device firmware
  • prebuilt: Prebuilt binaries
  • z2m: Zigbee2MQTT related files

Ressources

Maintainer

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •  
0