Copying the Zigbee Temperature and Humidity example to do something completely different #11055
richardsg307
started this conversation in
Question - Community Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
After getting a Smart Meter fitted, I set myself a project of putting a sensor on the flashing LED (3200 flashes/kWh) and sending data to Home Assistant over Zigbee. I got myself the Seeed Studio XIAO ESP32-C6 and an LM393 optical sensor.
For bread-boarding, I got 1 ESP to get an LED flashing at different rates to emulate 0W up to 20kW. On the sensor side I got the ESP32-C6 loaded up with the Sleepy temperature and humidity example sketch, as that had 2 float variables that could be passed to HA. I got rid of the sleepy stuff and added the code needed to respond to the flashing LED, increment the meter reading (energy) and calculate the power based on the time interval between the last 2 flashes. I then added some code to get it reporting the 2 values (meter and power) every 5 seconds. The reporting is via Zigbee and Serial.print. I also added the Time Cluster but haven't done anything with it yet. This is the bit that does the reporting (note how I use Temperature for Power and Humidity for Meter).
It's all working for the most part but I have a couple of issues.
Could I have done this without the Example sketch or perhaps a different one that could be more suitable? I get the impression that there's something going on behind it that I might need to tinker with but I'm no expert!
When reporting with power randomly fluctuating between 1 and 20 kW I get no problems. But if I set my flasher to emulate random powers between 0 and 1kW, whilst the report subroutine above still gets executed every 5 seconds, the data is not coming through to HA, and it's left me stumped. As a bit of further info, below are some lines in the setup routine that may be relevant.
Below is a screen shot from HA/History showing the data coming in. I have the flaser set up so that it updates the pulse duration every 5 seconds such that 9 times out of 10 it will be randomly in the range 0 - 1kW ( and 1 in 10 times 1 - 10kW). Where I get a long series of the lower range the history graph just flatlines showing no updates coming through until there is a big jump. The Serial monitor clearly shows a new value every 5 seconds.
Any help appreciated. Thanks.
PS - I will be creating Template Helpers to tidy up the 2 entities!
Beta Was this translation helpful? Give feedback.
All reactions