2023-04-07 00:20:26 -04:00
| Supported Targets | ESP32-C6 | ESP32-H2 |
| ----------------- | -------- | -------- |
2021-10-20 06:45:55 -04:00
2022-10-19 03:57:24 -04:00
# Light Bulb Example
2021-10-20 06:45:55 -04:00
2023-04-07 00:20:26 -04:00
This test code shows how to configure Zigbee end device and use it as HA on/off light bulb.
The ESP Zigbee SDK provides more examples and tools for productization:
* [ESP Zigbee SDK Docs ](https://docs.espressif.com/projects/esp-zigbee-sdk )
* [ESP Zigbee SDK Repo ](https://github.com/espressif/esp-zigbee-sdk )
2021-10-20 06:45:55 -04:00
## Hardware Required
2023-04-07 00:20:26 -04:00
* One development board with ESP32-H2 SoC acting as Zigbee end device (loaded with HA_on_off_light example)
2021-10-20 06:45:55 -04:00
* A USB cable for power supply and programming
2023-04-07 00:20:26 -04:00
* Choose another ESP32-H2 as Zigbee coordinator (see [HA_on_off_switch example ](../HA_on_off_switch ))
2021-10-20 06:45:55 -04:00
## Configure the project
2022-12-29 23:02:41 -05:00
Before project configuration and build, make sure to set the correct chip target using `idf.py --preview set-target TARGET` command.
2021-10-20 06:45:55 -04:00
2022-10-19 03:57:24 -04:00
## Erase the NVRAM
2022-09-22 02:51:30 -04:00
Before flash it to the board, it is recommended to erase NVRAM if user doesn't want to keep the previous examples or other projects stored info using `idf.py -p PORT erase-flash`
2021-10-20 06:45:55 -04:00
## Build and Flash
Build the project, flash it to the board, and start the monitor tool to view the serial output by running `idf.py -p PORT flash monitor` .
(To exit the serial monitor, type ``Ctrl-]``.)
## Example Output
As you run the example, you will see the following log:
light bulb:
2022-10-26 02:40:02 -04:00
```
2022-10-19 03:57:24 -04:00
I (918) ESP_ZB_LIGHT: status: 255
I (901) ESP_ZB_LIGHT: Zigbee stack initialized
I (901) ESP_ZB_LIGHT: Start network steering
I (2611) ESP_ZB_LIGHT: Joined network successfully (Extended PAN ID: aa:98:48:01:a0:03:f7:84, PAN ID: 0x0e8b)
I (5651) ESP_ZB_LIGHT: on/off light set to 1
I (6631) ESP_ZB_LIGHT: on/off light set to 0
I (7331) ESP_ZB_LIGHT: on/off light set to 1
I (8251) ESP_ZB_LIGHT: on/off light set to 0
I (9111) ESP_ZB_LIGHT: on/off light set to 1
I (9671) ESP_ZB_LIGHT: on/off light set to 0
2022-10-26 02:40:02 -04:00
```
2021-10-20 06:45:55 -04:00
## Light Control Functions
2023-04-07 00:20:26 -04:00
* By toggling the switch button (BOOT) on the ESP32-H2 board loaded with the `HA_on_off_switch` example, the LED on this board loaded with `HA_on_off_light` example will be on and off.
2021-10-20 06:45:55 -04:00
## Troubleshooting
For any technical queries, please open an [issue ](https://github.com/espressif/esp-idf/issues ) on GitHub. We will get back to you soon.