Skip to content

feat(zigbee): Add Zigbee library #10265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 42 commits into from
Oct 2, 2024
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
94cc558
Initial commit - light bulb + switch working
P-R-O-C-H-Y Jun 28, 2024
3764810
Merge remote-tracking branch 'upstream/master' into feature/zigbee-li…
P-R-O-C-H-Y Jun 28, 2024
7776aa5
Add Thermostat + fix enum
P-R-O-C-H-Y Jul 10, 2024
8ce22e1
Dev update: roles, cb removal, handlers
P-R-O-C-H-Y Aug 9, 2024
3078306
Dev update: implement on/off light and switch methods
P-R-O-C-H-Y Aug 9, 2024
194693a
Merge remote-tracking branch 'upstream/master' into feature/zigbee-li…
P-R-O-C-H-Y Aug 9, 2024
14b99db
Dev update: Factory reset, names, multiple EPs
P-R-O-C-H-Y Aug 12, 2024
54488a4
Dev update: Device ID to string
P-R-O-C-H-Y Aug 12, 2024
a83f695
Implement cmd default response handler
P-R-O-C-H-Y Aug 13, 2024
06b0700
Remove unused _identify_cluster
P-R-O-C-H-Y Aug 14, 2024
ec60ed4
Dev Update: Color DImmable light + switch implemented
P-R-O-C-H-Y Aug 14, 2024
ef1cc89
Implement Network Scanning
P-R-O-C-H-Y Aug 16, 2024
97920df
Dev Update: Thermostat and Temperature sensor EP
P-R-O-C-H-Y Aug 28, 2024
459e4df
Merge remote-tracking branch 'upstream/master' into feature/zigbee-li…
P-R-O-C-H-Y Aug 29, 2024
fa716f0
fix(): Replace deprecated function
P-R-O-C-H-Y Aug 29, 2024
db01086
Remove ported IDF examples
P-R-O-C-H-Y Aug 30, 2024
4d18a8c
Update Zigbee examples with new APIs
P-R-O-C-H-Y Aug 30, 2024
fa6267a
Dev Update: Version setting, Thermostat fix, ...
P-R-O-C-H-Y Aug 30, 2024
7693a16
Remove EP template + add lib to CMakeLists
P-R-O-C-H-Y Aug 30, 2024
7312de3
Merge branch 'master' into feature/zigbee-library
P-R-O-C-H-Y Sep 2, 2024
95ff61b
Rename classes to have proper naming
P-R-O-C-H-Y Sep 2, 2024
495a24f
Add check for SOC_IEEE802154_SUPPORTED
P-R-O-C-H-Y Sep 2, 2024
b000bea
Ignore false positive unused variable/function
P-R-O-C-H-Y Sep 2, 2024
96c18c4
Fix compilation errors in examples
P-R-O-C-H-Y Sep 2, 2024
4edfb8c
Fill keyworkds.txt, remove unnecessary defines
P-R-O-C-H-Y Sep 3, 2024
6e220ec
Rename methods, variables + make private/protected
P-R-O-C-H-Y Sep 10, 2024
4eb37aa
Remove unnecesary defaults defines
P-R-O-C-H-Y Sep 10, 2024
39633f1
Merge branch 'master' into feature/zigbee-library
P-R-O-C-H-Y Sep 10, 2024
59335bb
Remove outdated comments
P-R-O-C-H-Y Sep 10, 2024
9a771b8
Merge branch 'feature/zigbee-library' of https://github.com/P-R-O-C-H…
P-R-O-C-H-Y Sep 10, 2024
2fdeef7
Update Scan networks Readme
P-R-O-C-H-Y Sep 10, 2024
9a86d6f
fix(example): Use proper naming of func and variables
P-R-O-C-H-Y Sep 16, 2024
9a354ae
Change virtual methods to callbacks (TODO)
P-R-O-C-H-Y Sep 19, 2024
f321d43
Refactor classes methods + implement Identify command
P-R-O-C-H-Y Sep 26, 2024
27ecf23
Apply suggestions from code review by @lucasssvaz
P-R-O-C-H-Y Sep 27, 2024
04e0f75
Update READMEs + add openNetwork fucntion
P-R-O-C-H-Y Sep 27, 2024
2eedc2e
Use [[maybe_unused]] instead of #pragma
P-R-O-C-H-Y Sep 27, 2024
3198de3
Merge branch 'master' into feature/zigbee-library
P-R-O-C-H-Y Sep 27, 2024
6e56936
Use gpio calls for OnOff Light example
P-R-O-C-H-Y Sep 27, 2024
3961642
ci(pre-commit): Apply automatic fixes
lucasssvaz Oct 1, 2024
7d763df
fix(): Codespell issues
P-R-O-C-H-Y Oct 2, 2024
44f5522
Merge branch 'master' into feature/zigbee-library
P-R-O-C-H-Y Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -112,6 +112,7 @@ set(ARDUINO_ALL_LIBRARIES
WiFi
WiFiProv
Wire
Zigbee
)

set(ARDUINO_LIBRARY_ArduinoOTA_SRCS libraries/ArduinoOTA/src/ArduinoOTA.cpp)
@@ -240,6 +241,18 @@ set(ARDUINO_LIBRARY_WiFiProv_SRCS libraries/WiFiProv/src/WiFiProv.cpp)

set(ARDUINO_LIBRARY_Wire_SRCS libraries/Wire/src/Wire.cpp)

set(ARDUINO_LIBRARY_Zigbee_SRCS
libraries/Zigbee/src/ZigbeeCore.cpp
libraries/Zigbee/src/ZigbeeEP.cpp
libraries/Zigbee/src/ZigbeeHandlers.cpp
libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp
libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.cpp
libraries/Zigbee/src/ep/ZigbeeLight.cpp
libraries/Zigbee/src/ep/ZigbeeSwitch.cpp
libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp
libraries/Zigbee/src/ep/ZigbeeThermostat.cpp
)

set(ARDUINO_LIBRARY_BLE_SRCS
libraries/BLE/src/BLE2901.cpp
libraries/BLE/src/BLE2902.cpp
84 changes: 42 additions & 42 deletions boards.txt

Large diffs are not rendered by default.

This file was deleted.

10 changes: 0 additions & 10 deletions libraries/ESP32/examples/Zigbee/Zigbee_Light_Bulb/ci.json

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions libraries/ESP32/examples/Zigbee/Zigbee_Light_Switch/ci.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions libraries/ESP32/examples/Zigbee/Zigbee_Thermostat/ci.json

This file was deleted.

68 changes: 68 additions & 0 deletions libraries/Zigbee/examples/Zigbee_Color_Dimmable_Light/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Arduino-ESP32 Zigbee Color Dimmable Light Example

This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) color dimmable light.

# Supported Targets

Currently, this example supports the following targets.

| Supported Targets | ESP32-C6 | ESP32-H2 |
| ----------------- | -------- | -------- |

## Hardware Required

* One development board (ESP32-H2 or ESP32-C6) acting as Zigbee coordinator (loaded with Zigbee_Color_Dimmer_Switch example)
* A USB cable for power supply and programming
* Choose another board (ESP32-H2 or ESP32-C6) as Zigbee end device and upload the Zigbee_Color_Dimmable_Light example

### Configure the Project

Set the LED GPIO by changing the `LED_PIN` definition. By default, the LED_PIN is `RGB_BUILTIN`.

#### Using Arduino IDE

To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits).

* Before Compile/Verify, select the correct board: `Tools -> Board`.
* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)`
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`
* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port.
* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`.

## Troubleshooting

If the End device flashed with this example is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator.
You can do the following:

* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`.
* Add to the sketch `Zigbee.factoryReset();` to reset the device and Zigbee stack.

By default, the coordinator network is closed after rebooting or flashing new firmware.
To open the network you have 2 options:

* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`.
* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join.

***Important: Make sure you are using a good quality USB cable and that you have a reliable power source***

* **LED not blinking:** Check the wiring connection and the IO selection.
* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed.
* **COM port not detected:** Check the USB cable and the USB to Serial driver installation.

If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute).

## Contribute

To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst)

If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome!

Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else.

## Resources

* Official ESP32 Forum: [Link](https://esp32.com)
* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf)
* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com)
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @brief This example demonstrates Zigbee Color Dimmable light bulb.
*
* The example demonstrates how to use Zigbee library to create an end device with
* color dimmable light end point.
* The light bulb is a Zigbee end device, which is controlled by a Zigbee coordinator.
*
* Proper Zigbee mode must be selected in Tools->Zigbee mode
* and also the correct partition scheme must be selected in Tools->Partition Scheme.
*
* Please check the README.md for instructions and more detailed description.
*
* Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/)
*/

#ifndef ZIGBEE_MODE_ED
#error "Zigbee end device mode is not selected in Tools->Zigbee mode"
#endif

#include "ZigbeeCore.h"
#include "ep/ZigbeeColorDimmableLight.h"

#define LED_PIN RGB_BUILTIN
#define BUTTON_PIN 9 // C6/H2 Boot button
#define ZIGBEE_LIGHT_ENDPOINT 10

ZigbeeColorDimmableLight zbColorLight = ZigbeeColorDimmableLight(ZIGBEE_LIGHT_ENDPOINT);

/********************* RGB LED functions **************************/
void setRGBLight(bool state, uint8_t red, uint8_t green, uint8_t blue, uint8_t level) {
float brightness = (float)level / 255;
rgbLedWrite(LED_PIN, red * brightness, green * brightness, blue * brightness);
}

// Create a task on identify call to handle the identify function
void identify(uint16_t time) {
static uint8_t blink = 1;
log_d("Identify called for %d seconds", time);
if (time == 0) {
// If identify time is 0, stop blinking and restore light as it was used for identify
zbColorLight.restoreLight();
return;
}
rgbLedWrite(LED_PIN, 255 * blink, 255 * blink, 255 * blink);
blink = !blink;
}

/********************* Arduino functions **************************/
void setup() {
// Init RMT and leave light OFF
rgbLedWrite(LED_PIN, 0, 0, 0);

// Init button for factory reset
pinMode(BUTTON_PIN, INPUT);

// Set callback function for light change
zbColorLight.onLightChange(setRGBLight);

// Optional: Set callback function for device identify
zbColorLight.onIdentify(identify);

// Optional: Set Zigbee device name and model
zbColorLight.setManufacturerAndModel("Espressif", "ZBColorLightBulb");

// Add endpoint to Zigbee Core
log_d("Adding ZigbeeLight endpoint to Zigbee Core");
Zigbee.addEndpoint(&zbColorLight);

// When all EPs are registered, start Zigbee. By default acts as ZIGBEE_END_DEVICE
log_d("Calling Zigbee.begin()");
Zigbee.begin();
}

void loop() {
// Checking button for factory reset
if (digitalRead(BUTTON_PIN) == LOW) { // Push button pressed
// Key debounce handling
delay(100);
int startTime = millis();
while (digitalRead(BUTTON_PIN) == LOW) {
delay(50);
if ((millis() - startTime) > 3000) {
// If key pressed for more than 3secs, factory reset Zigbee and reboot
Serial.printf("Resetting Zigbee to factory settings, reboot.\n");
Zigbee.factoryReset();
}
}
}
delay(100);
}
16 changes: 16 additions & 0 deletions libraries/Zigbee/examples/Zigbee_Color_Dimmable_Light/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"fqbn": {
"esp32c6": [
"espressif:esp32:esp32c6:PartitionScheme=zigbee,ZigbeeMode=ed"
],
"esp32h2": [
"espressif:esp32:esp32h2:PartitionScheme=zigbee,ZigbeeMode=ed"
]
},
"targets": {
"esp32": false,
"esp32c3": false,
"esp32s2": false,
"esp32s3": false
}
}
68 changes: 68 additions & 0 deletions libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Arduino-ESP32 Zigbee Color Dimmer Switch Example

This example shows how to configure Zigbee Coordinator and use it as a Home Automation (HA) color dimmer light switch.

# Supported Targets

Currently, this example supports the following targets.

| Supported Targets | ESP32-C6 | ESP32-H2 |
| ----------------- | -------- | -------- |

## Hardware Required

* One development board (ESP32-H2 or ESP32-C6) acting as Zigbee end device (loaded with Zigbee_Color_Dimmable_Light example).
* A USB cable for power supply and programming.
* Choose another board (ESP32-H2 or ESP32-C6) as Zigbee coordinator and upload the Zigbee_Color_Dimmable_Light example.

### Configure the Project

Set the Button Switch GPIO by changing the `GPIO_SWITCH` definition. By default, it's the pin `9` (BOOT button on ESP32-C6 and ESP32-H2).

#### Using Arduino IDE

To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits).

* Before Compile/Verify, select the correct board: `Tools -> Board`.
* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator/router)`.
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`.
* Select the COM port: `Tools -> Port: xxx where the `xxx` is the detected COM port.
* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`.

## Troubleshooting

If the End device flashed with the example `Zigbee_Color_Dimmable_Light` is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator.
You can do the following:

* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`.
* Add to the sketch `Zigbee.factoryReset();` to reset the device and Zigbee stack.

By default, the coordinator network is closed after rebooting or flashing new firmware.
To open the network you have 2 options:

* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`.
* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join.

***Important: Make sure you are using a good quality USB cable and that you have a reliable power source***

* **LED not blinking:** Check the wiring connection and the IO selection.
* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed.
* **COM port not detected:** Check the USB cable and the USB to Serial driver installation.

If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute).

## Contribute

To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst)

If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome!

Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else.

## Resources

* Official ESP32 Forum: [Link](https://esp32.com)
* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf)
* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com)
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @brief This example demonstrates Zigbee color dimmer switch.
*
* The example demonstrates how to use Zigbee library to control a RGB light bulb.
* The RGB light bulb is a Zigbee end device, which is controlled by a Zigbee coordinator (Switch).
* To turn on/off the light, push the button on the switch.
* To change the color or level of the light, send serial commands to the switch.
*
* By setting the switch to allow multiple binding, so it can bind to multiple lights.
* Also every 30 seconds, all bound lights are printed to the serial console.
*
* Proper Zigbee mode must be selected in Tools->Zigbee mode
* and also the correct partition scheme must be selected in Tools->Partition Scheme.
*
* Please check the README.md for instructions and more detailed description.
*
* Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/)
*/

#ifndef ZIGBEE_MODE_ZCZR
#error "Zigbee coordinator mode is not selected in Tools->Zigbee mode"
#endif

#include "ZigbeeCore.h"
#include "ep/ZigbeeColorDimmerSwitch.h"

/* Switch configuration */
#define SWITCH_PIN 9 // ESP32-C6/H2 Boot button
#define SWITCH_ENDPOINT_NUMBER 5

/* Zigbee switch */
ZigbeeColorDimmerSwitch zbSwitch = ZigbeeColorDimmerSwitch(SWITCH_ENDPOINT_NUMBER);

/********************* Arduino functions **************************/
void setup() {

Serial.begin(115200);
while (!Serial) {
delay(10);
}

//Init button switch
pinMode(SWITCH_PIN, INPUT);

//Optional: set Zigbee device name and model
zbSwitch.setManufacturerAndModel("Espressif", "ZigbeeSwitch");

//Optional to allow multiple light to bind to the switch
zbSwitch.allowMultipleBinding(true);

//Add endpoint to Zigbee Core
Zigbee.addEndpoint(&zbSwitch);

//Open network for 180 seconds after boot
Zigbee.setRebootOpenNetwork(180);

//When all EPs are registered, start Zigbee with ZIGBEE_COORDINATOR mode
Zigbee.begin(ZIGBEE_COORDINATOR);

Serial.println("Waiting for Light to bound to the switch");
//Wait for switch to bound to a light:
while (!zbSwitch.isBound()) {
Serial.printf(".");
delay(500);
}
Serial.println();
}

void loop() {
// Handle button switch in loop()
if (digitalRead(SWITCH_PIN) == LOW) { // Push button pressed
// Key debounce handling
while (digitalRead(SWITCH_PIN) == LOW) {
delay(50);
}
// Toggle light
zbSwitch.lightToggle();
}
// Handle serial input to control color and level of the light
if (Serial.available()) {
String command = Serial.readString();

if (command == "on") {
zbSwitch.lightOn();
} else if (command == "off") {
zbSwitch.lightOff();
} else if (command == "toggle") {
zbSwitch.lightToggle();
} else if (command == "red") {
zbSwitch.setLightColor(255, 0, 0);
} else if (command == "green") {
zbSwitch.setLightColor(0, 255, 0);
} else if (command == "blue") {
zbSwitch.setLightColor(0, 0, 255);
} else if (command == "white") {
zbSwitch.setLightColor(255, 255, 255);
} else if (command == "color") {
//wait for color value
Serial.println("Enter red value (0-255):");
while (!Serial.available()) {
delay(100);
}
int red = Serial.parseInt();
Serial.println("Enter green value (0-255):");
while (!Serial.available()) {
delay(100);
}
int green = Serial.parseInt();
Serial.println("Enter blue value (0-255):");
while (!Serial.available()) {
delay(100);
}
int blue = Serial.parseInt();
zbSwitch.setLightColor(red, green, blue);
} else if (command == "level") {
//wait for level value
Serial.println("Enter level value (0-255):");
while (!Serial.available()) {
delay(100);
}
int level = Serial.parseInt();
zbSwitch.setLightLevel(level);
} else {
Serial.println("Unknown command");
}
}

// print the bound devices (lights) every 30 seconds
static uint32_t last_print = 0;
if (millis() - last_print > 30000) {
last_print = millis();
zbSwitch.printBoundDevices();
}
}
16 changes: 16 additions & 0 deletions libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"fqbn": {
"esp32c6": [
"espressif:esp32:esp32c6:PartitionScheme=zigbee_zczr,ZigbeeMode=zczr"
],
"esp32h2": [
"espressif:esp32:esp32h2:PartitionScheme=zigbee_zczr,ZigbeeMode=zczr"
]
},
"targets": {
"esp32": false,
"esp32c3": false,
"esp32s2": false,
"esp32s3": false
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Arduino-ESP32 Zigbee Light Bulb Example
# Arduino-ESP32 Zigbee On/Off Light Example

This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) on/off light bulb.

**This example is based on ESP-Zigbee-SDK example esp_zigbee_HA_sample/HA_on_off_light.**
This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) on/off light.

# Supported Targets

@@ -13,9 +11,9 @@ Currently, this example supports the following targets.

## Hardware Required

* One development board (ESP32-H2 or ESP32-C6) acting as Zigbee coordinator (loaded with Zigbee_Light_switch example)
* One development board (ESP32-H2 or ESP32-C6) acting as Zigbee coordinator (loaded with Zigbee_On_Off_switch example)
* A USB cable for power supply and programming
* Choose another board (ESP32-H2 or ESP32-C6) as Zigbee end device (loaded with Zigbee_Light_bulb example)
* Choose another board (ESP32-H2 or ESP32-C6) as Zigbee end device and upload the Zigbee_On_Off_Light example

### Configure the Project

@@ -30,17 +28,22 @@ To get more information about the Espressif boards see [Espressif Development Ki
* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)`
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`
* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port.
* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`.

## Troubleshooting

If the End device flashed with this example is not connecting to the coordinator, erase the flash before flashing it to the board. It is recommended to do this if you did changes to the coordinator.
If the End device flashed with this example is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator.
You can do the following:

* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`
* In the sketch uncomment function `esp_zb_nvram_erase_at_start(true);` located in `esp_zb_task` function.
* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`.
* Add to the sketch `Zigbee.factoryReset();` to reset the device and Zigbee stack.

By default, the coordinator network is closed after rebooting or flashing new firmware.
To open the network you have 2 options:

* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`.
* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join.

By default, the coordinator network is open for 180 s after rebooting or flashing new firmware. After that, the network is closed for adding new devices.
You can change it by editing `esp_zb_bdb_open_network(180);` in `esp_zb_app_signal_handler` function.

***Important: Make sure you are using a good quality USB cable and that you have a reliable power source***

@@ -60,14 +63,8 @@ Before creating a new issue, be sure to try Troubleshooting and check if the sam

## Resources

The ESP Zigbee SDK provides more examples:
* ESP Zigbee SDK Docs: [Link](https://docs.espressif.com/projects/esp-zigbee-sdk)
* ESP Zigbee SDK Repo: [Link](https://github.com/espressif/esp-zigbee-sdk)

* Official ESP32 Forum: [Link](https://esp32.com)
* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
* ESP32 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf)
* ESP32-S2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf)
* ESP32-C3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf)
* ESP32-S3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf)
* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf)
* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com)
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @brief This example demonstrates simple Zigbee light bulb.
*
* The example demonstrates how to use Zigbee library to create a end device light bulb.
* The light bulb is a Zigbee end device, which is controlled by a Zigbee coordinator.
*
* Proper Zigbee mode must be selected in Tools->Zigbee mode
* and also the correct partition scheme must be selected in Tools->Partition Scheme.
*
* Please check the README.md for instructions and more detailed description.
*
* Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/)
*/

#ifndef ZIGBEE_MODE_ED
#error "Zigbee end device mode is not selected in Tools->Zigbee mode"
#endif

#include "ZigbeeCore.h"
#include "ep/ZigbeeLight.h"

#define LED_PIN RGB_BUILTIN
#define BUTTON_PIN 9 // ESP32-C6/H2 Boot button
#define ZIGBEE_LIGHT_ENDPOINT 10

ZigbeeLight zbLight = ZigbeeLight(ZIGBEE_LIGHT_ENDPOINT);

/********************* RGB LED functions **************************/
void setLED(bool value) {
digitalWrite(LED_PIN, value);
}

/********************* Arduino functions **************************/
void setup() {
// Init LED and turn it OFF (if LED_PIN == RGB_BUILTIN, the rgbLedWrite() will be used under the hood)
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);

// Init button for factory reset
pinMode(BUTTON_PIN, INPUT);

//Optional: set Zigbee device name and model
zbLight.setManufacturerAndModel("Espressif", "ZBLightBulb");

// Set callback function for light change
zbLight.onLightChange(setLED);

//Add endpoint to Zigbee Core
log_d("Adding ZigbeeLight endpoint to Zigbee Core");
Zigbee.addEndpoint(&zbLight);

// When all EPs are registered, start Zigbee. By default acts as ZIGBEE_END_DEVICE
log_d("Calling Zigbee.begin()");
Zigbee.begin();
}

void loop() {
// Checking button for factory reset
if (digitalRead(BUTTON_PIN) == LOW) { // Push button pressed
// Key debounce handling
delay(100);
int startTime = millis();
while (digitalRead(BUTTON_PIN) == LOW) {
delay(50);
if ((millis() - startTime) > 3000) {
// If key pressed for more than 3secs, factory reset Zigbee and reboot
Serial.printf("Resetting Zigbee to factory settings, reboot.\n");
Zigbee.factoryReset();
}
}
}
delay(100);
}
16 changes: 16 additions & 0 deletions libraries/Zigbee/examples/Zigbee_On_Off_Light/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"fqbn": {
"esp32c6": [
"espressif:esp32:esp32c6:PartitionScheme=zigbee,ZigbeeMode=ed"
],
"esp32h2": [
"espressif:esp32:esp32h2:PartitionScheme=zigbee,ZigbeeMode=ed"
]
},
"targets": {
"esp32": false,
"esp32c3": false,
"esp32s2": false,
"esp32s3": false
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Arduino-ESP32 Zigbee Light Switch Example
# Arduino-ESP32 Zigbee On/Off Light Switch Example

This example shows how to configure Zigbee Coordinator and use it as a Home Automation (HA) on/off light switch.

**This example is based on ESP-Zigbee-SDK example esp_zigbee_HA_sample/HA_on_off_switch.**

# Supported Targets

Currently, this example supports the following targets.
@@ -13,34 +11,37 @@ Currently, this example supports the following targets.

## Hardware Required

* One development board (ESP32-H2 or ESP32-C6) acting as Zigbee end device (loaded with Zigbee_Light_bulb example).
* One development board (ESP32-H2 or ESP32-C6) acting as Zigbee end device (loaded with Zigbee_On_Off_Light example).
* A USB cable for power supply and programming.
* Choose another board (ESP32-H2 or ESP32-C6) as Zigbee coordinator (loaded with Zigbee_Light_switch example).
* Choose another board (ESP32-H2 or ESP32-C6) as Zigbee coordinator and upload the Zigbee_On_Off_Switch example.

### Configure the Project

Set the Button Switch GPIO by changing the `GPIO_INPUT_IO_TOGGLE_SWITCH` definition. By default, the LED_PIN is `GPIO_NUM_9`.
Set the Button Switch GPIO by changing the `GPIO_INPUT_IO_TOGGLE_SWITCH` definition. By default, it's the pin `9` (BOOT button on ESP32-C6 and ESP32-H2).

#### Using Arduino IDE

To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits).

* Before Compile/Verify, select the correct board: `Tools -> Board`.
* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator)`.
* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator/router)`.
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`.
* Select the COM port: `Tools -> Port: xxx where the `xxx` is the detected COM port.
* Optional: Set debug level to info to see logs from Zigbee stack: `Tools -> Core Debug Level: Info`.
* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`.

## Troubleshooting

If the End device flashed with the example `Zigbee_Light_Bulb` is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator.
If the End device flashed with the example `Zigbee_On_Off_Light` is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator.
You can do the following:

* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`.
* In the `Zigbee_Light_Bulb` example sketch uncomment function `esp_zb_nvram_erase_at_start(true);` located in `esp_zb_task` function.
* In the `Zigbee_On_Off_Light` example sketch call `Zigbee.factoryReset();`.

By default, the coordinator network is closed after rebooting or flashing new firmware.
To open the network you have 2 options:

By default, the coordinator network is open for 180 s after rebooting or flashing new firmware. After that, the network is closed for adding new devices.
You can change it by editing `esp_zb_bdb_open_network(180);` in `esp_zb_app_signal_handler` function.
* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`.
* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join.

***Important: Make sure you are using a good quality USB cable and that you have a reliable power source***

@@ -60,14 +61,8 @@ Before creating a new issue, be sure to try Troubleshooting and check if the sam

## Resources

The ESP Zigbee SDK provides more examples:
* ESP Zigbee SDK Docs: [Link](https://docs.espressif.com/projects/esp-zigbee-sdk)
* ESP Zigbee SDK Repo: [Link](https://github.com/espressif/esp-zigbee-sdk)

* Official ESP32 Forum: [Link](https://esp32.com)
* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
* ESP32 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf)
* ESP32-S2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf)
* ESP32-C3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf)
* ESP32-S3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf)
* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf)
* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com)
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @brief This example demonstrates simple Zigbee light switch.
*
* The example demonstrates how to use Zigbee library to control a light bulb.
* The light bulb is a Zigbee end device, which is controlled by a Zigbee coordinator (Switch).
* Button switch and Zigbee runs in separate tasks.
*
* Proper Zigbee mode must be selected in Tools->Zigbee mode
* and also the correct partition scheme must be selected in Tools->Partition Scheme.
*
* Please check the README.md for instructions and more detailed description.
*
* Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/)
*/

#ifndef ZIGBEE_MODE_ZCZR
#error "Zigbee coordinator mode is not selected in Tools->Zigbee mode"
#endif

#include "ZigbeeCore.h"
#include "ep/ZigbeeSwitch.h"

#define SWITCH_ENDPOINT_NUMBER 5

/* Switch configuration */
#define GPIO_INPUT_IO_TOGGLE_SWITCH 9
#define PAIR_SIZE(TYPE_STR_PAIR) (sizeof(TYPE_STR_PAIR) / sizeof(TYPE_STR_PAIR[0]))

typedef enum {
SWITCH_ON_CONTROL,
SWITCH_OFF_CONTROL,
SWITCH_ONOFF_TOGGLE_CONTROL,
SWITCH_LEVEL_UP_CONTROL,
SWITCH_LEVEL_DOWN_CONTROL,
SWITCH_LEVEL_CYCLE_CONTROL,
SWITCH_COLOR_CONTROL,
} SwitchFunction;

typedef struct {
uint8_t pin;
SwitchFunction func;
} SwitchData;

typedef enum {
SWITCH_IDLE,
SWITCH_PRESS_ARMED,
SWITCH_PRESS_DETECTED,
SWITCH_PRESSED,
SWITCH_RELEASE_DETECTED,
} SwitchState;

static SwitchData buttonFunctionPair[] = {{GPIO_INPUT_IO_TOGGLE_SWITCH, SWITCH_ONOFF_TOGGLE_CONTROL}};

ZigbeeSwitch zbSwitch = ZigbeeSwitch(SWITCH_ENDPOINT_NUMBER);

/********************* Zigbee functions **************************/
static void onZbButton(SwitchData *button_func_pair) {
if (button_func_pair->func == SWITCH_ONOFF_TOGGLE_CONTROL) {
// Send toggle command to the light
zbSwitch.lightToggle();
}
}

/********************* GPIO functions **************************/
static QueueHandle_t gpio_evt_queue = NULL;

static void IRAM_ATTR onGpioInterrupt(void *arg) {
xQueueSendFromISR(gpio_evt_queue, (SwitchData *)arg, NULL);
}

static void enableGpioInterrupt(bool enabled) {
for (int i = 0; i < PAIR_SIZE(buttonFunctionPair); ++i) {
if (enabled) {
enableInterrupt((buttonFunctionPair[i]).pin);
} else {
disableInterrupt((buttonFunctionPair[i]).pin);
}
}
}

/********************* Arduino functions **************************/
void setup() {

Serial.begin(115200);
while (!Serial) {
delay(10);
}

//Optional: set Zigbee device name and model
zbSwitch.setManufacturerAndModel("Espressif", "ZigbeeSwitch");

//Optional to allow multiple light to bind to the switch
zbSwitch.allowMultipleBinding(true);

//Add endpoint to Zigbee Core
log_d("Adding ZigbeeSwitch endpoint to Zigbee Core");
Zigbee.addEndpoint(&zbSwitch);

//Open network for 180 seconds after boot
Zigbee.setRebootOpenNetwork(180);

// Init button switch
for (int i = 0; i < PAIR_SIZE(buttonFunctionPair); i++) {
pinMode(buttonFunctionPair[i].pin, INPUT_PULLUP);
/* create a queue to handle gpio event from isr */
gpio_evt_queue = xQueueCreate(10, sizeof(SwitchData));
if (gpio_evt_queue == 0) {
log_e("Queue was not created and must not be used");
while (1);
}
attachInterruptArg(buttonFunctionPair[i].pin, onGpioInterrupt, (void *)(buttonFunctionPair + i), FALLING);
}

// When all EPs are registered, start Zigbee with ZIGBEE_COORDINATOR mode
log_d("Calling Zigbee.begin()");
Zigbee.begin(ZIGBEE_COORDINATOR);

Serial.println("Waiting for Light to bound to the switch");
//Wait for switch to bound to a light:
while (!zbSwitch.isBound()) {
Serial.printf(".");
delay(500);
}

// Optional: read manufacturer and model name from the bound light
std::list<zb_device_params_t *> boundLights = zbSwitch.getBoundDevices();
//List all bound lights
for (const auto &device : boundLights) {
Serial.printf("Device on endpoint %d, short address: 0x%x\n", device->endpoint, device->short_addr);
Serial.printf(
"IEEE Address: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", device->ieee_addr[0], device->ieee_addr[1], device->ieee_addr[2], device->ieee_addr[3],
device->ieee_addr[4], device->ieee_addr[5], device->ieee_addr[6], device->ieee_addr[7]
);
Serial.printf("Light manufacturer: %s", zbSwitch.readManufacturer(device->endpoint, device->short_addr));
Serial.printf("Light model: %s", zbSwitch.readModel(device->endpoint, device->short_addr));
}

Serial.println();
}

void loop() {
// Handle button switch in loop()
uint8_t pin = 0;
SwitchData buttonSwitch;
static SwitchState buttonState = SWITCH_IDLE;
bool eventFlag = false;

/* check if there is any queue received, if yes read out the buttonSwitch */
if (xQueueReceive(gpio_evt_queue, &buttonSwitch, portMAX_DELAY)) {
pin = buttonSwitch.pin;
enableGpioInterrupt(false);
eventFlag = true;
}
while (eventFlag) {
bool value = digitalRead(pin);
switch (buttonState) {
case SWITCH_IDLE: buttonState = (value == LOW) ? SWITCH_PRESS_DETECTED : SWITCH_IDLE; break;
case SWITCH_PRESS_DETECTED: buttonState = (value == LOW) ? SWITCH_PRESS_DETECTED : SWITCH_RELEASE_DETECTED; break;
case SWITCH_RELEASE_DETECTED:
buttonState = SWITCH_IDLE;
/* callback to button_handler */
(*onZbButton)(&buttonSwitch);
break;
default: break;
}
if (buttonState == SWITCH_IDLE) {
enableGpioInterrupt(true);
eventFlag = false;
break;
}
vTaskDelay(10 / portTICK_PERIOD_MS);
}

// print the bound lights every 10 seconds
static uint32_t lastPrint = 0;
if (millis() - lastPrint > 10000) {
lastPrint = millis();
zbSwitch.printBoundDevices();
}
}
16 changes: 16 additions & 0 deletions libraries/Zigbee/examples/Zigbee_On_Off_Switch/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"fqbn": {
"esp32c6": [
"espressif:esp32:esp32c6:PartitionScheme=zigbee_zczr,ZigbeeMode=zczr"
],
"esp32h2": [
"espressif:esp32:esp32h2:PartitionScheme=zigbee_zczr,ZigbeeMode=zczr"
]
},
"targets": {
"esp32": false,
"esp32c3": false,
"esp32s2": false,
"esp32s3": false
}
}
71 changes: 71 additions & 0 deletions libraries/Zigbee/examples/Zigbee_Scan_Networks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Arduino-ESP32 Zigbee Networks Scan Example

This example shows how to scan Zigbee Networks.

# Supported Targets

Currently, this example supports the following targets.

| Supported Targets | ESP32-C6 | ESP32-H2 |
| ----------------- | -------- | -------- |

## Example Output

Setup done
Loop running...
Loop running...
Loop running...
Loop running...

Scan done
2 networks found:
Nr | PAN ID | CH | Permit Joining | Router Capacity | End Device Capacity | Extended PAN ID
1 | 0xe6f0 | 14 | Yes | Yes | Yes | f0:f5:bd:ff:fe:02:3f:24
2 | 0xa9bb | 24 | No | Yes | Yes | 60:55:f9:00:00:f7:52:d0

## Hardware Required

* One development board (ESP32-H2 or ESP32-C6) acting as Zigbee coordinator (loaded with `Zigbee_Thermostat` example)
* A USB cable for power supply and programming
* Choose another board (ESP32-H2 or ESP32-C6) as Zigbee end device (loaded with `Zigbee_Temperature_Sensor` example)

### Configure the Project

In this example, the internal temperature sensor task is reading the chip temperature.
Set the Button Switch GPIO by changing the `GPIO_INPUT_IO_TOGGLE_SWITCH` definition. By default, it's the `GPIO_NUM_9` (BOOT button on ESP32-C6 and ESP32-H2).

#### Using Arduino IDE

To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits).

* Before Compile/Verify, select the correct board: `Tools -> Board`.
* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)`
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`
* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port.
* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`.

## Troubleshooting

***Important: Make sure you are using a good quality USB cable and that you have a reliable power source***

* **LED not blinking:** Check the wiring connection and the IO selection.
* **Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed.
* **COM port not detected:** Check the USB cable and the USB to Serial driver installation.

If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute).

## Contribute

To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst)

If you have any **feedback** or **issue** to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome!

Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else.

## Resources

* Official ESP32 Forum: [Link](https://esp32.com)
* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf)
* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com)
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @brief This example demonstrates Zigbee Network Scanning.
*
* The example demonstrates how to use ESP Zigbee stack to scan for Zigbee networks.
*
* Any Zigbee mode can be selected in Tools->Zigbee mode
* with proper Zigbee partition scheme in Tools->Partition Scheme.
*
* Please check the README.md for instructions and more detailed description.
*
* Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/)
*/

#if !defined(ZIGBEE_MODE_ED) && !defined(ZIGBEE_MODE_ZCZR)
#error "Zigbee device mode is not selected in Tools->Zigbee mode"
#endif

#include "ZigbeeCore.h"

#ifdef ZIGBEE_MODE_ZCZR
zigbee_role_t role = ZIGBEE_ROUTER; // or can be ZIGBEE_COORDINATOR, but it wont scan itself
#else
zigbee_role_t role = ZIGBEE_END_DEVICE;
#endif

void printScannedNetworks(uint16_t networksFound) {
if (networksFound == 0) {
Serial.println("No networks found");
} else {
zigbee_scan_result_t *scan_result = Zigbee.getScanResult();
Serial.println("\nScan done");
Serial.print(networksFound);
Serial.println(" networks found:");
Serial.println("Nr | PAN ID | CH | Permit Joining | Router Capacity | End Device Capacity | Extended PAN ID");
for (int i = 0; i < networksFound; ++i) {
// Print all available info for each network found
Serial.printf("%2d", i + 1);
Serial.print(" | ");
Serial.printf("0x%04hx", scan_result[i].short_pan_id);
Serial.print(" | ");
Serial.printf("%2d", scan_result[i].logic_channel);
Serial.print(" | ");
Serial.printf("%-14.14s", scan_result[i].permit_joining ? "Yes" : "No");
Serial.print(" | ");
Serial.printf("%-15.15s", scan_result[i].router_capacity ? "Yes" : "No");
Serial.print(" | ");
Serial.printf("%-19.19s", scan_result[i].end_device_capacity ? "Yes" : "No");
Serial.print(" | ");
Serial.printf(
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", scan_result[i].extended_pan_id[7], scan_result[i].extended_pan_id[6], scan_result[i].extended_pan_id[5],
scan_result[i].extended_pan_id[4], scan_result[i].extended_pan_id[3], scan_result[i].extended_pan_id[2], scan_result[i].extended_pan_id[1],
scan_result[i].extended_pan_id[0]
);
Serial.println();
delay(10);
}
Serial.println("");
// Delete the scan result to free memory for code below.
Zigbee.scanDelete();
}
}

void setup() {
Serial.begin(115200);
while (!Serial) {
delay(10);
}

// Initialize Zigbee stack without any EPs just for scanning
Zigbee.begin(role);

// Waint until Zigbee stack is ready
while (!Zigbee.isStarted()) {
delay(100);
}

Serial.println("Setup done");
// Start Zigbee Network Scan with default parameters (all channels, scan time 5)
Zigbee.scanNetworks();
}

void loop() {
// check Zigbee Network Scan process
int16_t ZigbeeScanStatus = Zigbee.scanComplete();
if (ZigbeeScanStatus < 0) { // it is busy scanning or got an error
if (ZigbeeScanStatus == ZB_SCAN_FAILED) {
Serial.println("WiFi Scan has failed. Starting again.");
Zigbee.scanNetworks();
}
// other option is status ZB_SCAN_RUNNING - just wait.
} else { // Found Zero or more Wireless Networks
printScannedNetworks(ZigbeeScanStatus);
Zigbee.scanNetworks(); // start over...
}

// Loop can do something else...
delay(500);
Serial.println("Loop running...");
}
16 changes: 16 additions & 0 deletions libraries/Zigbee/examples/Zigbee_Scan_Networks/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"fqbn": {
"esp32c6": [
"espressif:esp32:esp32c6:PartitionScheme=zigbee,ZigbeeMode=ed"
],
"esp32h2": [
"espressif:esp32:esp32h2:PartitionScheme=zigbee,ZigbeeMode=ed"
]
},
"targets": {
"esp32": false,
"esp32c3": false,
"esp32s2": false,
"esp32s3": false
}
}
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@

This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) temperature sensor.

**This example is based on ESP-Zigbee-SDK example esp_zigbee_HA_sample/HA_temperature_sensor.**

# Supported Targets

Currently, this example supports the following targets.
@@ -14,23 +12,23 @@ Currently, this example supports the following targets.
## Temperature Sensor Functions

Note:
* This board means the board (e.g. ESP32-H2) loaded with `Zigbee_Temperature_Sensor` example.
* The remote board means the board (e.g. ESP32-H2) loaded with `Zigbee_Thermostat` example.
* This board means the board (e.g. ESP32-H2 / C6) loaded with `Zigbee_Temperature_Sensor` example.
* The remote board means the board (e.g. ESP32-H2 / C6) loaded with `Zigbee_Thermostat` example.

Functions:
* After this board first starts up, it would be configured locally to report the temperature on 1 degree change and no periodic reporting to the remote board.
* By clicking the switch button (BOOT) on this board, this board will immediately send a report of the current measured temperature to the remote board.
* By clicking the button (BOOT) on this board, this board will immediately send a report of the current measured temperature to the remote board.

## Hardware Required

* One development board (ESP32-H2 or ESP32-C6) acting as Zigbee coordinator (loaded with `Zigbee_Thermostat` example)
* A USB cable for power supply and programming
* Choose another board (ESP32-H2 or ESP32-C6) as Zigbee end device (loaded with `Zigbee_Temperature_Sensor` example)
* Choose another board (ESP32-H2 or ESP32-C6) as Zigbee end device and upload the `Zigbee_Temperature_Sensor` example

### Configure the Project

In this example, the internal temperature sensor task is reading the chip temperature.
Set the Button Switch GPIO by changing the `GPIO_INPUT_IO_TOGGLE_SWITCH` definition. By default, it's the `GPIO_NUM_9` (BOOT button on ESP32-C6 and ESP32-H2).
Set the Button GPIO by changing the `BUTTON_PIN` definition. By default, it's the pin `9` (BOOT button on ESP32-C6 and ESP32-H2).

#### Using Arduino IDE

@@ -40,17 +38,21 @@ To get more information about the Espressif boards see [Espressif Development Ki
* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)`
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`
* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port.
* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`.

## Troubleshooting

If the End device flashed with this example is not connecting to the coordinator, erase the flash before flashing it to the board. It is recommended to do this if you did changes to the coordinator.
If the End device flashed with this example is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator.
You can do the following:

* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`
* In the sketch uncomment function `esp_zb_nvram_erase_at_start(true);` located in `esp_zb_task` function.
* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`.
* Add to the sketch `Zigbee.factoryReset();` to reset the device and Zigbee stack.

By default, the coordinator network is closed after rebooting or flashing new firmware.
To open the network you have 2 options:

By default, the coordinator network is open for 180 s after rebooting or flashing new firmware. After that, the network is closed for adding new devices.
You can change it by editing `esp_zb_bdb_open_network(180);` in `esp_zb_app_signal_handler` function.
* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`.
* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join.

***Important: Make sure you are using a good quality USB cable and that you have a reliable power source***

@@ -70,14 +72,8 @@ Before creating a new issue, be sure to try Troubleshooting and check if the sam

## Resources

The ESP Zigbee SDK provides more examples:
* ESP Zigbee SDK Docs: [Link](https://docs.espressif.com/projects/esp-zigbee-sdk)
* ESP Zigbee SDK Repo: [Link](https://github.com/espressif/esp-zigbee-sdk)

* Official ESP32 Forum: [Link](https://esp32.com)
* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
* ESP32 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf)
* ESP32-S2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf)
* ESP32-C3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf)
* ESP32-S3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf)
* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf)
* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com)
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @brief This example demonstrates Zigbee temperature sensor.
*
* The example demonstrates how to use Zigbee library to create a end device temperature sensor.
* The temperature sensor is a Zigbee end device, which is controlled by a Zigbee coordinator.
*
* Proper Zigbee mode must be selected in Tools->Zigbee mode
* and also the correct partition scheme must be selected in Tools->Partition Scheme.
*
* Please check the README.md for instructions and more detailed description.
*
* Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/)
*/

#ifndef ZIGBEE_MODE_ED
#error "Zigbee coordinator mode is not selected in Tools->Zigbee mode"
#endif

#include "ZigbeeCore.h"
#include "ep/ZigbeeTempSensor.h"

#define BUTTON_PIN 9 //Boot button for C6/H2
#define TEMP_SENSOR_ENDPOINT_NUMBER 10

ZigbeeTempSensor zbTempSensor = ZigbeeTempSensor(TEMP_SENSOR_ENDPOINT_NUMBER);

/************************ Temp sensor *****************************/
static void temp_sensor_value_update(void *arg) {
for (;;) {
// Read temperature sensor value
float tsens_value = temperatureRead();
log_v("Temperature sensor value: %.2f°C", tsens_value);
// Update temperature value in Temperature sensor EP
zbTempSensor.setTemperature(tsens_value);
delay(1000);
}
}

/********************* Arduino functions **************************/
void setup() {

Serial.begin(115200);
while (!Serial) {
delay(10);
}

// Init button switch
pinMode(BUTTON_PIN, INPUT);

// Optional: set Zigbee device name and model
zbTempSensor.setManufacturerAndModel("Espressif", "ZigbeeTempSensor");

// Set minimum and maximum temperature measurement value (10-50°C is default range for chip temperature measurement)
zbTempSensor.setMinMaxValue(10, 50);

// Set tolerance for temperature measurement in °C (lowest possible value is 0.01°C)
zbTempSensor.setTolerance(1);

// Add endpoint to Zigbee Core
Zigbee.addEndpoint(&zbTempSensor);

// When all EPs are registered, start Zigbee in End Device mode
Zigbee.begin();

// Start Temperature sensor reading task
xTaskCreate(temp_sensor_value_update, "temp_sensor_update", 2048, NULL, 10, NULL);

// Set reporting interval for temperature measurement in seconds, must be called after Zigbee.begin()
// min_interval and max_interval in seconds, delta (temp change in °C)
// if min = 1 and max = 0, reporting is sent only when temperature changes by delta
// if min = 0 and max = 10, reporting is sent every 10 seconds or temperature changes by delta
// if min = 0, max = 10 and delta = 0, reporting is sent every 10 seconds regardless of temperature change
zbTempSensor.setReporting(1, 0, 1);
}

void loop() {
// Checking button for factory reset
if (digitalRead(BUTTON_PIN) == LOW) { // Push button pressed
// Key debounce handling
delay(100);
int startTime = millis();
while (digitalRead(BUTTON_PIN) == LOW) {
delay(50);
if ((millis() - startTime) > 3000) {
// If key pressed for more than 3secs, factory reset Zigbee and reboot
Serial.printf("Resetting Zigbee to factory settings, reboot.\n");
Zigbee.factoryReset();
}
}
zbTempSensor.reportTemperature();
}
delay(100);
}
16 changes: 16 additions & 0 deletions libraries/Zigbee/examples/Zigbee_Temperature_Sensor/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"fqbn": {
"esp32c6": [
"espressif:esp32:esp32c6:PartitionScheme=zigbee,ZigbeeMode=ed"
],
"esp32h2": [
"espressif:esp32:esp32h2:PartitionScheme=zigbee,ZigbeeMode=ed"
]
},
"targets": {
"esp32": false,
"esp32c3": false,
"esp32s2": false,
"esp32s3": false
}
}
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ Note:
* The remote board means the board (e.g. ESP32-H2) loaded with `Zigbee_Temperature_Sensor` example.

Functions:
* By clicking the switch button (BOOT) on this board, this board will read temperature value, temperature measurement range and temperature tolerance from the remote board. Also, this board will configure the remote board to report the measured temperature value every 10 seconds or every 2 degree changes.
* By clicking the button (BOOT) on this board, this board will read temperature value, temperature measurement range and temperature tolerance from the remote board. Also, this board will configure the remote board to report the measured temperature value every 10 seconds or every 2 degree changes.

## Hardware Required

@@ -28,28 +28,31 @@ Functions:

### Configure the Project

Set the Button Switch GPIO by changing the `GPIO_INPUT_IO_TOGGLE_SWITCH` definition. By default, it's the `GPIO_NUM_9` (BOOT button on ESP32-C6 and ESP32-H2).
Set the Button GPIO by changing the `BUTTON_PIN` definition. By default, it's the pin `9` (BOOT button on ESP32-C6 and ESP32-H2).

#### Using Arduino IDE

To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits).

* Before Compile/Verify, select the correct board: `Tools -> Board`.
* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator)`.
* Select the Coordinator Zigbee mode: `Tools -> Zigbee mode: Zigbee ZCZR (coordinator/router)`.
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`.
* Select the COM port: `Tools -> Port: xxx where the `xxx` is the detected COM port.
* Optional: Set debug level to info to see logs from Zigbee stack: `Tools -> Core Debug Level: Info`.
* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`.

## Troubleshooting

If the End device flashed with the example `Zigbee_Temperature_Sensor` is not connecting to the coordinator, erase the flash of the End device before flashing the example to the board. It is recommended to do this if you re-flash the coordinator.
You can do the following:

* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`.
* In the `Zigbee_Temperature_Sensor` example sketch uncomment function `esp_zb_nvram_erase_at_start(true);` located in `esp_zb_task` function.
* In the `Zigbee_Temperature_Sensor` example sketch call `Zigbee.factoryReset();`.

By default, the coordinator network is open for 180 s after rebooting or flashing new firmware. After that, the network is closed for adding new devices.
You can change it by editing `esp_zb_bdb_open_network(180);` in `esp_zb_app_signal_handler` function.
By default, the coordinator network is closed after rebooting or flashing new firmware.
To open the network you have 2 options:

* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`.
* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join.

***Important: Make sure you are using a good quality USB cable and that you have a reliable power source***

@@ -69,14 +72,8 @@ Before creating a new issue, be sure to try Troubleshooting and check if the sam

## Resources

The ESP Zigbee SDK provides more examples:
* ESP Zigbee SDK Docs: [Link](https://docs.espressif.com/projects/esp-zigbee-sdk)
* ESP Zigbee SDK Repo: [Link](https://github.com/espressif/esp-zigbee-sdk)

* Official ESP32 Forum: [Link](https://esp32.com)
* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
* ESP32 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf)
* ESP32-S2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf)
* ESP32-C3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf)
* ESP32-S3 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf)
* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf)
* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com)
119 changes: 119 additions & 0 deletions libraries/Zigbee/examples/Zigbee_Thermostat/Zigbee_Thermostat.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @brief This example demonstrates simple Zigbee thermostat.
*
* The example demonstrates how to use Zigbee library to get data from temperature
* sensor end device and act as an thermostat.
* The temperature sensor is a Zigbee end device, which is controlled by a Zigbee coordinator (thermostat).
*
* Proper Zigbee mode must be selected in Tools->Zigbee mode
* and also the correct partition scheme must be selected in Tools->Partition Scheme.
*
* Please check the README.md for instructions and more detailed description.
*
* Created by Jan Procházka (https://github.com/P-R-O-C-H-Y/)
*/

#ifndef ZIGBEE_MODE_ZCZR
#error "Zigbee coordinator mode is not selected in Tools->Zigbee mode"
#endif

#include "ZigbeeCore.h"
#include "ep/ZigbeeThermostat.h"

#define BUTTON_PIN 9 // Boot button for C6/H2
#define THERMOSTAT_ENDPOINT_NUMBER 5

ZigbeeThermostat zbThermostat = ZigbeeThermostat(THERMOSTAT_ENDPOINT_NUMBER);

// Save temperature sensor data
float sensor_temp;
float sensor_max_temp;
float sensor_min_temp;
float sensor_tolerance;

/****************** Temperature sensor handling *******************/
void recieveSensorTemp(float temperature) {
Serial.printf("Temperature sensor value: %.2f°C\n", temperature);
sensor_temp = temperature;
}

void recieveSensorConfig(float min_temp, float max_temp, float tolerance) {
Serial.printf("Temperature sensor settings: min %.2f°C, max %.2f°C, tolerance %.2f°C\n", min_temp, max_temp, tolerance);
sensor_min_temp = min_temp;
sensor_max_temp = max_temp;
sensor_tolerance = tolerance;
}
/********************* Arduino functions **************************/
void setup() {
Serial.begin(115200);
while (!Serial) {
delay(10);
}

// Init button switch
pinMode(BUTTON_PIN, INPUT);

// Set callback functions for temperature and configuration receive
zbThermostat.onTempRecieve(recieveSensorTemp);
zbThermostat.onConfigRecieve(recieveSensorConfig);

//Optional: set Zigbee device name and model
zbThermostat.setManufacturerAndModel("Espressif", "ZigbeeThermostat");

//Add endpoint to Zigbee Core
Zigbee.addEndpoint(&zbThermostat);

//Open network for 180 seconds after boot
Zigbee.setRebootOpenNetwork(180);

// When all EPs are registered, start Zigbee with ZIGBEE_COORDINATOR mode
Zigbee.begin(ZIGBEE_COORDINATOR);

Serial.println("Waiting for Temperature sensor to bound to the switch");

//Wait for switch to bound to a light:
while (!zbThermostat.isBound()) {
Serial.printf(".");
delay(500);
}

// Get temperature sensor configuration
zbThermostat.getSensorSettings();
Serial.println();
}

void loop() {
// Handle button switch in loop()
if (digitalRead(BUTTON_PIN) == LOW) { // Push button pressed

// Key debounce handling
while (digitalRead(BUTTON_PIN) == LOW) {
delay(50);
}

// Set reporting interval for temperature sensor
zbThermostat.setTemperatureReporting(0, 10, 2);
}

// Print temperature sensor data each 10 seconds
static uint32_t last_print = 0;
if (millis() - last_print > 10000) {
last_print = millis();
int temp_percent = (int)((sensor_temp - sensor_min_temp) / (sensor_max_temp - sensor_min_temp) * 100);
Serial.printf("Loop temperature info: %.2f°C (%d %%)\n", sensor_temp, temp_percent);
}
}
16 changes: 16 additions & 0 deletions libraries/Zigbee/examples/Zigbee_Thermostat/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"fqbn": {
"esp32c6": [
"espressif:esp32:esp32c6:PartitionScheme=zigbee_zczr,ZigbeeMode=zczr"
],
"esp32h2": [
"espressif:esp32:esp32h2:PartitionScheme=zigbee_zczr,ZigbeeMode=zczr"
]
},
"targets": {
"esp32": false,
"esp32c3": false,
"esp32s2": false,
"esp32s3": false
}
}
105 changes: 105 additions & 0 deletions libraries/Zigbee/keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#######################################
# Syntax Coloring Map For Zigbee
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

# Base Classes
ZigbeeCore KEYWORD1
Zigbee KEYWORD1
ZigbeeEP KEYWORD1

# Endpoint Classes
ZigbeeLight KEYWORD1
ZigbeeSwitch KEYWORD1
ZigbeeColorDimmableLight KEYWORD1
ZigbeeColorDimmerSwitch KEYWORD1
ZigbeeTempSensor KEYWORD1
ZigbeeThermostat KEYWORD1

# Other
zigbee_role_t KEYWORD1
zbstring_t KEYWORD1
zb_device_params_t KEYWORD1
zigbee_scan_result_t KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################

# ZigbeeCore
isStarted KEYWORD2
addEndpoint KEYWORD2
setRadioConfig KEYWORD2
setHostConfig KEYWORD2
getRadioConfig KEYWORD2
getHostConfig KEYWORD2
setPrimaryChannelMask KEYWORD2
setRebootOpenNetwork KEYWORD2
scanNetworks KEYWORD2
scanComplete KEYWORD2
getScanResult KEYWORD2
scanDelete KEYWORD2
factoryReset KEYWORD2

# Common ZigbeeEP
setVersion KEYWORD2
setManufacturerAndModel KEYWORD2
is_bound KEYWORD2
printBoundDevices KEYWORD2
allowMultipleBinding KEYWORD2

# ZigbeeLight + ZigbeeColorDimmableLight
setOnOff KEYWORD2
sceneControl KEYWORD2
setOnOffTime KEYWORD2
setOffWaitTime KEYWORD2
setLevel KEYWORD2
setColor KEYWORD2
setColorSaturation KEYWORD2
setColorHue KEYWORD2

# ZigbeeSwitch + ZigbeeColorDimmerSwitch
lightToggle KEYWORD2
lightOn KEYWORD2
lightOff KEYWORD2
lightOffWithEffect KEYWORD2
lightOnWithTimedOff KEYWORD2
lightOnWithSceneRecall KEYWORD2
setLightLevel KEYWORD2
setLightColor KEYWORD2
setLightColorSaturation KEYWORD2
setLightColorHue KEYWORD2

# ZigbeeTempSensor
setTemperature KEYWORD2
setMinMaxValue KEYWORD2
setTolerance KEYWORD2
setReporting KEYWORD2
reportTemperature KEYWORD2

# ZigbeeThermostat
temperatureRead KEYWORD2
temperatureMin KEYWORD2
temperatureMax KEYWORD2
temperatureTolerance KEYWORD2
getTemperature KEYWORD2
setTemperatureReporting KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################

ZIGBEE_COORDINATOR LITERAL1
ZIGBEE_ROUTER LITERAL1
ZIGBEE_END_DEVICE LITERAL1
ZIGBEE_DEFAULT_ED_CONFIG LITERAL1
ZIGBEE_DEFAULT_ROUTER_CONFIG LITERAL1
ZIGBEE_DEFAULT_COORDINATOR_CONFIG LITERAL1
ZIGBEE_DEFAULT_RADIO_CONFIG LITERAL1
ZIGBEE_DEFAULT_HOST_CONFIG LITERAL1
ZB_ARRAY_LENTH LITERAL1
XYZ_TO_RGB LITERAL1
RGB_TO_XYZ LITERAL1
9 changes: 9 additions & 0 deletions libraries/Zigbee/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=Zigbee
version=3.0.5
author=P-R-O-C-H-Y
maintainer=Jan Procházka <jan.prochazka@espressif.com>
sentence=Enables zigbee connection with the ESP32
paragraph=With this library you can create zigbee end devices, routers, coordinators and connect them to the zigbee network.
category=Communication
url=
architectures=esp32
Loading