esp-idf/examples/zigbee/light_sample/HA_on_off_switch
Harshit Malpani bbbede07d0
fix(partition_table): Check partition size for type APP
The size of partition of type APP should be multiple of 4 KB. Partition
generation tool now make this as a mandatory requirement. This is
minimum flash erase size. If the size of the APP type partition is not
aligned to 4 KB then the last erase operation could go beyond the allocated
partition and hence may fail. This issue would only be observed when the
firmware size grows very close to the allocated partition size, and hence
causing the OTA update to fail.

For already deployed devices on-field with the size of APP partition not
aligned to flash sector boundary, it is best to ensure that firmware
size always remains within the lower 4 KB boundary of the total
allocated space. While migrating to ESP-IDF 5.3 release, partition table
for an existing project can be adjusted accordingly for the build to
succeed.

Found during discussion in https://github.com/espressif/esp-idf/pull/12460
2023-12-11 10:14:57 +05:30
..
main feat(zigbee): optimize Zigbee example implementation 2023-09-20 10:49:37 +08:00
CMakeLists.txt Zigbee: Update Zigbee examples for the latest library 2022-10-12 17:56:39 +08:00
partitions.csv fix(partition_table): Check partition size for type APP 2023-12-11 10:14:57 +05:30
README.md docs: update the readme for Thread/Zigbee examples 2023-04-07 12:22:52 +08:00
sdkconfig.defaults TWDT: Use the new TWDT Kconfig options in the examples and tests 2023-02-17 11:22:25 +08:00

Supported Targets ESP32-C6 ESP32-H2

Light Switch Example

This test code shows how to configure Zigbee Coordinator and use it as an HA on/off_switch.

The ESP Zigbee SDK provides more examples and tools for productization:

Hardware Required

  • One development board with ESP32-H2 SoC acting as Zigbee Coordinator (loaded with HA_on_off_switch)
  • A USB cable for power supply and programming
  • Choose another ESP32-H2 as Zigbee end-device (see HA_on_off_light)

Configure the project

Before project configuration and build, make sure to set the correct chip target using idf.py --preview set-target TARGET command.

Erase the NVRAM

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

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 switch:

I (318) gpio: GPIO[9]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2
I (328) system_api: Base MAC address is not set
I (328) system_api: read default base MAC address from EFUSE
I (408) phy: libbtbb version: 6c47ec3, Mar 16 2022, 18:54:24
I (408) phy: phy_version: 101, bb2a234, Mar 16 2022, 18:54:11
I (818) ESP_ZB_ON_OFF_SWITCH: status: 255
I (818) ESP_ZB_ON_OFF_SWITCH: Zigbee stack initialized
I (818) ESP_ZB_ON_OFF_SWITCH: Start network formation
I (1318) ESP_ZB_ON_OFF_SWITCH: Formed network successfully (Extended PAN ID: ff:fc:7c:c0:f0:bd:97:10, PAN ID: 0x88e7)
I (1778) ESP_ZB_ON_OFF_SWITCH: status: 0
I (5528) ESP_ZB_ON_OFF_SWITCH: status: 0
I (6038) ESP_ZB_ON_OFF_SWITCH: status: 0
I (6068) ESP_ZB_ON_OFF_SWITCH: New device commissioned or rejoined (short: 0x2878)
I (6098) ESP_ZB_ON_OFF_SWITCH: User find cb: address:0x2878, endpoint:10
I (6638) ESP_ZB_ON_OFF_SWITCH: status: 0
I (6678) ESP_ZB_ON_OFF_SWITCH: status: 0
I (8168) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command
I (8898) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command
I (9458) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command
I (10088) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command
I (10588) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command
I (11098) ESP_ZB_ON_OFF_SWITCH: send move to on_off toggle command

Light Control Functions

  • By toggling the switch button (BOOT) on this board, the LED on the board loaded with the HA_on_off_light example will turn on and off.

Troubleshooting

For any technical queries, please open an issue on GitHub. We will get back to you soon.