You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Arduino-ESP32 Zigbee Light Sensor Sleepy Device Example
2
+
3
+
This example demonstrates how to use the Zigbee library to create an end device light sensor and use it as a Home Automation (HA) extended light sensor.
4
+
5
+
# Supported Targets
6
+
7
+
Currently, this example supports the following targets.
8
+
9
+
| Supported Targets | ESP32-C6 | ESP32-H2 |
10
+
| ----------------- | -------- | -------- |
11
+
12
+
## Light Sensor Functions
13
+
14
+
1. Initialize a Zigbee light sensor.
15
+
2. Measure illuminance value.
16
+
3. Report the measured value to the Zigbee network.
17
+
18
+
## Hardware Required
19
+
20
+
* ESP32-H2 or ESP32-C6 development board
21
+
* A USB cable for power supply and programming
22
+
* Some kind of light sensor, such as a photoresistor
23
+
24
+
### Configure the Project
25
+
26
+
In this example the raw analog value of a light sensor is used to calculate illuminance.
27
+
Alter the calculation according to your use case and calibrate it to receive correct lux values.
28
+
Set the light sensor GPIO by changing the `light_sensor_pin` variable to the pin to the pin to which your sensor is connected.
29
+
Set the button GPIO by changing the `button` variable. By default, it's the pin `BOOT_PIN` (BOOT button on ESP32-C6 and ESP32-H2).
30
+
31
+
#### Using Arduino IDE
32
+
33
+
To get more information about the Espressif boards see [Espressif Development Kits](https://www.espressif.com/en/products/devkits).
34
+
35
+
* Before Compile/Verify, select the correct board: `Tools -> Board`.
36
+
* Select the End device Zigbee mode: `Tools -> Zigbee mode: Zigbee ED (end device)`
37
+
* Select Partition Scheme for Zigbee: `Tools -> Partition Scheme: Zigbee 4MB with spiffs`
38
+
* Enable USB CDC to be able to use the serial monitor: `Tools -> USB CDC On Boot: Enabled`
39
+
* Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port.
40
+
* Optional: Set debug level to verbose to see all logs from Zigbee stack: `Tools -> Core Debug Level: Verbose`.
41
+
42
+
## Troubleshooting
43
+
44
+
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.
45
+
You can do the following:
46
+
47
+
* In the Arduino IDE go to the Tools menu and set `Erase All Flash Before Sketch Upload` to `Enabled`.
48
+
* Add to the sketch `Zigbee.factoryReset();` to reset the device and Zigbee stack.
49
+
50
+
By default, the coordinator network is closed after rebooting or flashing new firmware.
51
+
To open the network you have 2 options:
52
+
53
+
* Open network after reboot by setting `Zigbee.setRebootOpenNetwork(time);` before calling `Zigbee.begin();`.
54
+
* In application you can anytime call `Zigbee.openNetwork(time);` to open the network for devices to join.
55
+
56
+
***Important: Make sure that you are using a good quality USB cable with data lines and that you have a reliable power source***
57
+
58
+
***LED not blinking:** Check the wiring connection and the IO selection.
59
+
***Programming Fail:** If the programming/flash procedure fails, try reducing the serial connection speed.
60
+
***COM port not detected:** Check the USB cable and the USB to Serial driver installation.
61
+
62
+
If the error persists, you can ask for help at the official [ESP32 forum](https://esp32.com) or see [Contribute](#contribute).
63
+
64
+
## Contribute
65
+
66
+
To know how to contribute to this project, see [How to contribute.](https://github.com/espressif/arduino-esp32/blob/master/CONTRIBUTING.rst)
67
+
68
+
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!
69
+
70
+
Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else.
71
+
72
+
## Resources
73
+
74
+
* Official ESP32 Forum: [Link](https://esp32.com)
75
+
* Arduino-ESP32 Official Repository: [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
76
+
* ESP32-C6 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf)
77
+
* ESP32-H2 Datasheet: [Link to datasheet](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf)
78
+
* Official ESP-IDF documentation: [ESP-IDF](https://idf.espressif.com)
0 commit comments