Open rei-vilo opened 5 months ago
Hello @rei-vilo,
Yes, the examples use polling - so they're might not be that power efficient. We'll look into introducing event callbacks to the library so you can block your user task and wait for Matter events to happen - it's a good idea.
Hello @rei-vilo,
I just realized what you need here is to replace the busy-looping with a simple delay()
- that'll block the user task for the provided amount of time allowing the device to enter a low-power mode and also run the radio stack if necessary. We'll also introduce support for ArduinoLowPower
to allow more control.
What I was thinking about is the ability to register a callback for your devices which is called when some property changes. This would allow you to block your user task and go low power until something changes - then only react to it once without constantly polling for changes. This will be very useful, so it'll be definitely coming.
Thank you for the suggestion.
Actually, a delay()
fits perfectly if there is only one single task.
As the weather sensor can raise an interrupt, I am considering using events. This is what I did for the Low Power Home Network Weather Monitoring project based on sub-1GHz and TI-RTOS: idle mode required as little as 0.0267 mW.
Summary
In many examples, delay before two consecutive data acquisition is performed by polling.
https://github.com/SiliconLabs/arduino/blob/65a739a859fa8b98e755f23f2b9c8010d25ca1e2/libraries/Matter/examples/matter_sensor_multiple/matter_sensor_multiple.ino#L61-L67
This might not be especially low-power.
How to use instead an event raised by a timer? As SiLabs core for Arduino seems to rely on FreeRTOS, the RTOS elements should be already available.
Thank you!