GNU General Public License v3.0

项目介绍

Kampi/BeeLight 是一个托管在 GitHub 上的开源项目,主要使用 JavaScript 编写,采用 GNU General Public License v3.0 许可证,目前获得 13 个 Star、3 次 Fork。

仓库全名
Kampi/BeeLight
开源许可证
GNU General Public License v3.0
Star 数
13
Fork 数
3
未关闭 Issue
3

README 摘要

BeeLight - Zigbee based light & environment sensor for Home Automation Table of Contents BeeLight - Zigbee based light \& environment sensor for Home Automation Table of Contents About Technical features Before you start PCB Firmware Build the firmware Flash the firmware Generate the production config for the device Using west Using the command line Housing Zigbee Standard clusters Custom cluster Zigbee Dongle…

完整内容见 GitHub 原始 README 或本页 。

常见问题

BeeLight 用什么语言开发?

主要使用 JavaScript 编写,采用 GNU General Public License v3.0 许可证,目前有 13 个 Star。

BeeLight 可以免费商用吗?

仓库标注的许可证为 GNU General Public License v3.0,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 BeeLight 的源码?

可以直接克隆仓库:git clone https://github.com/Kampi/BeeLight.git;安装与运行步骤见仓库 README。

BeeLight 最近还在维护吗?

仓库最近一次更新为 3月29日,当前有 3 个未关闭 Issue;Star 数为 13,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Zigbee environment sensor device with Zigbee2MQTT support.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

Batchfile
C
CMake
HTML
JavaScript
Python
Shell

贡献者

README

BeeLight - Zigbee based light & environment sensor for Home Automation

License PCB Documentation

Table of Contents

About

Open-Source Zigbee-based light and environmental sensor with Zigbee2MQTT support for your Home Automation (e.g., Home Assistant).

Rendering

Technical features

  • Cutting-edge MCU module 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 (40x42x20 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

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 -DEXTRA_CONF_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!

Flash the firmware

After building the firmware you can run

west flash

to flash the firmware into the module.

NOTE For some reason the current consumption stays high after flashing. I recommend a complete power cycle after flashing to make sure the device is consuming the lowest current possible.

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_PRODUCT_CONFIG_OFFSET macro in build/<app>/zephyr/include/generated/pm_config.h. Also make sure to change extended_address in the Zigbee configuration file if you use more than one device!

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 clusters
Cluster ID
Temperature 0x0402
Pressure 0x0403
Rel. Humidity 0x0405
Light 0x0400
Custom cluster

The device uses three 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 clusters with Zigbee2MQTT easily, 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/dist/zspec/zcl/definition and open cluster.js and add the following code to exports.Clusters
...
    msBeelightIAQ: {
        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: {},
    },
    msBeelightVOC: {
        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: {},
    },
    msBeelightCO2: {
        ID: 6668,
        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: {},
    },
...
  1. Save the file
  2. Switch to .../zigbee2mqtt/node_modules/zigbee-herdsman-converters/dist/lib
  3. Open the file modernExtend.js and add the following cluster to the end of the list at the end of the file:
  4. Add
...
exports.BeeLight_iaq = BeeLight_iaq;
exports.BeeLight_co2 = BeeLight_co2;
exports.BeeLight_voc = BeeLight_voc;
...
  1. Extend the following section
// #region Measurement and Sensing
function BeeLight_iaq(args = {}) {
    return numeric({
        name: "BeeLight_iaq",
        cluster: "msBeelightIAQ",
        attribute: "measuredValue",
        reporting: { min: "5_MINUTES", max: "1_HOUR", change: 10 },
        description: "Measured IAQ value",
        unit: "",
        scale: 1,
        access: "STATE_GET",
        ...args,
    });
}
function BeeLight_co2(args = {}) {
    return numeric({
        name: "BeeLight_co2",
        cluster: "msBeelightCO2",
        attribute: "measuredValue",
        reporting: { min: "5_MINUTES", max: "1_HOUR", change: 10 },
        description: "Measured CO2 value",
        unit: "ppm",
        scale: 1,
        access: "STATE_GET",
        ...args,
    });
}
function BeeLight_voc(args = {}) {
    return numeric({
        name: "BeeLight_voc",
        cluster: "msBeelightVOC",
        attribute: "measuredValue",
        reporting: { min: "5_MINUTES", max: "1_HOUR", change: 10 },
        description: "Measured VOC value",
        unit: "ppm",
        scale: 1,
        access: "STATE_GET",
        ...args,
    });
}
...
  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

Using the NCS Zigbee Shell

You can test the device by using the NCS Zigbee Shell example and an nRF54DK or an nRF5340DK.

  1. Flash the Zigbee Shell example to your board
  2. Execute nvram disable
  3. Execute bdb role zc
  4. Execute bdb channel 11
  5. Execute bdb start
  6. Flash the sensor device firmware and the network configuration
  7. Reset the sensor device and start the join procedure
  8. You should get this output from the network coordinator device
[00:05:05.648,345] <inf> zigbee_app_utils: Joined network successfully (Extended PAN ID: f4ce36b2d4c06ca0, PAN ID: 0x6057)
[00:05:24.536,529] <inf> zigbee_app_utils: Device authorization event received (short: 0x02fa, long: 86d79ac5bae41fa3, authorization type: 3, authorization status: 0)
[00:05:24.536,773] <inf> zigbee_app_utils: Unimplemented signal (signal: 53, status: 0)
[00:05:24.537,139] <inf> zigbee_app_utils: Device update received (short: 0x02fa, long: 86d79ac5bae41fa3, status: 1)
  1. Now you can read the clusters with zcl attr read <Address> 10 <Cluster> 0x0104 0x0000
  2. Use zcl subscribe on <Address> 10 <Cluster> 0x0104 0x00 33 <Min (s)> <Max (s)> to create a binding for the given cluster

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-relateBd images
  • hardware: KiCad project for the PCB
  • firmware: Zephyr project for the device firmware
  • prebuilt: Prebuilt binaries
  • z2m: Zigbee2MQTT-related files

Resources

Maintainer

评论

暂无评论