- BeeLight - Zigbee based light & environment sensor for Home Automation
Open-Source Zigbee-based light and environmental sensor with Zigbee2MQTT support for your Home Automation with I. e. Home Assistant.
- 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
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
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 calledMOUSER_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.
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!
You can run the command west upload-config
to build and upload your configuration to the device automatically.
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 offset0x17a000
is taken from thePM_ZBOSS_NVRAM_END_ADDRESS
macro inbuild/<app>/zephyr/include/generated/pm_config.h
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.
The device uses different standard and custom cluster to report the data to the network.
Cluster | ID |
---|---|
Temperature | 0x0402 |
Pressure | 0x0403 |
Rel. Humidity | 0x0405 |
Light | 0x0400 |
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 |
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.
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 directoryz2m/data/external_converters/example
if you want to check how the modified files look like.
- Download and install Zigbee2MQTT
- Copy the external converter from
z2m/data_external_converters
to thedata
directory of yourZigbee2MQTT
installation - Switch into the directory
.../zigbee2mqtt/node_modules/zigbee-herdsman-converters/converters
- Open the file
fromZigbee.js
and add the following code beforeconst 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 };
},
},
};
- Change
const converters = { ...converters1, ...converters2 };
toconst converters = { ...converters1, ...converters2, ...converters3 };
- Save the file
- Switch to
.../zigbee2mqtt/node_modules/zigbee-herdsman/dist/zspec/zcl/definition
- 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: {},
},
};
- Save the file
- Restart Zigbee2MQTT
The device can now be connected to your Zigbee network and with this to your Home Assistant.
3d-print
: All 3D print related filescad
: All relevant 3D modelsdocs
: 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 PCBfirmware
: Zephyr project for the device firmwareprebuilt
: Prebuilt binariesz2m
: Zigbee2MQTT related files