ATC_MiThermometer icon indicating copy to clipboard operation
ATC_MiThermometer copied to clipboard

advertising interval

Open michapr opened this issue 3 years ago • 20 comments

Checking the battery usage I have seen that the advertising interval is about 1,9s instead of 3s (if understand the setting in app_config.h right). #define ADVERTISING_INTERVAL 3000

If change it to 6000 the advertising time is about 3,8 seconds - this will save battery, right? setting 3000 (one unit is 1sec): adv_setting_3000 setting 6000 (one unit is 1sec): adv_setting_6000

Do not look at the noise, I did not make any filter... ;)

michapr avatar Nov 08 '20 15:11 michapr

Hey.

Yes that will increase battery life times 2

The advertising time is calculated by 0.65 if i remember correctly. Thats why its such a strange number

atc1441 avatar Nov 08 '20 16:11 atc1441

I have changed additional the sensor wakeup time - it will give more battery time. What do you think, make it configurable for user (web UI) - or is a setting in code fine? like RAM uint8_t measure_interval = 6;//multiply by 10 for value in sec.

Will make a PR in next days with some pictures like above ;)

michapr avatar Nov 08 '20 16:11 michapr

I would only make that setting in code as you can lock yourself out of the thermometer with a wrong setting

Otherwise it is a good feature. But bear in mind the longer the interval the harder it is to connect to the device

atc1441 avatar Nov 08 '20 16:11 atc1441

Otherwise it is a good feature. But bear in mind the longer the interval the harder it is to connect to the device

Right. The original device have nearly the same advertising time. I think take 3 seconds would be ok.

For temperature measure interval I think to take 1 minute by default - just now it is about 7,5 seconds. It will save much battery because the measure time is relatively long, as you already said.

michapr avatar Nov 08 '20 18:11 michapr

I think it maybe a feature for special optimization, but not for everybody now. Anyway I think it could be changed to 3 seconds (x2) to save battery on one side and reach it stable... Will be within standard.

The advertising interval should be in the interval 20 ms to 10.24 s (Bluetooth Core Specification v 4.2, Vol 2, Part E, chapter 7.8.5).

michapr avatar Nov 10 '20 17:11 michapr

@michapr hi, i have lost battery every day ~ 1-2% , rssi > 78

If this is too much just ignore but could you compile for me as fallow: Smile: Comfort indicator, Custom, Battery: Enabled, Advertise: 180 seconds (3m) and up advertising interval ble to ~ 7 sec

twocolors avatar Nov 26 '20 04:11 twocolors

@twocolors hi, I will make it for you, I also try to get less battery usage... The advertise 180 seconds will not help, this means only that any detected change will be reported after 180 seconds. I will make "next measurement" (enable sensor) every 180 seconds then for you - ok? see https://github.com/atc1441/ATC_MiThermometer/issues/63

michapr avatar Nov 26 '20 12:11 michapr

@michapr thx, for help. 180 seconds for "next measurement" - ok. It all works with the help of magic, i have three sensors

  1. rssi > 70 < 75 , 7 days - 100% battery
  2. rssi > 75 < 80 , battery every day ~ -1-2%
  3. rssi > 75 < 80 , battery every day ~ -1-2%

i think will help if "advertising interval" up to 7-9 sec, to not poll the sensor so often https://github.com/noble/bleno#set-advertising-interval

twocolors avatar Nov 26 '20 17:11 twocolors

@twocolors I made two images for you - one with about 6 seconds BLE advertising interval, second with about 8seconds (in case of problems with your requesting software. - what do you use?). Additional the battery measurement is more limited - will be one only every 50th loop, while temperature is measured. So every about 150-160 seconds * 50 = 7500seconds = every 2 hours about. This all will save battery...

Your files: https://www.smarthome-work.com/download/ATC_Thermometer__batt_6sec-adv_3min-meas_opt-batt-meas.bin https://www.smarthome-work.com/download/ATC_Thermometer__batt_8sec-adv_3min-meas_opt-batt-meas.bin

Tell me please about the battery usage after some time ;)

BTW: all batteries are new - and from same date / manufacturer?

michapr avatar Nov 26 '20 19:11 michapr

i use https://github.com/espruino/EspruinoHub , yes all battery replace ikea CR2032 i check and have 3.3V

twocolors avatar Nov 26 '20 19:11 twocolors

wow in you fw all battery > 85% && < 90% level, 8sec is really 7.3 thx, i will watch, maybe the problem is in the quality of the battery

twocolors avatar Nov 26 '20 19:11 twocolors

After flashing the battery is going a bit down. Flashing take some energy.

michapr avatar Nov 26 '20 19:11 michapr

@twocolors Any changes in battery usage visible?

michapr avatar Dec 05 '20 20:12 michapr

@michapr oh ... show ...

Screenshot 2020-12-14 at 00 58 46

twocolors avatar Dec 13 '20 22:12 twocolors

seems better as before (was 1-2% per day)?

Will send you another image in a few days, with additional energy optimizations ;) (it is just in test at my sensors)

michapr avatar Dec 14 '20 06:12 michapr

yes, 1-2% per day

i use ATC_Thermometer__batt_8sec-adv_3min-meas_opt-batt-meas.bin

twocolors avatar Dec 14 '20 09:12 twocolors

I would only make that setting in code as you can lock yourself out of the thermometer with a wrong setting

Would it be possible to vary the advertising interval like so: Upon cold boot for the first couple of minutes a small advertising interval is used to make it possible to connect to the module. After that a user configurable long advertising interval (like 300s or 600s) would be used for maximum battery saving. ?

AndrewLinden avatar Dec 14 '20 16:12 AndrewLinden

@AndrewLinden that's a really good idea! Should be easy to do with just a counter.

hancockks avatar Dec 16 '20 00:12 hancockks

@michapr hi, is there something to test? or you can go to build from https://github.com/atc1441/ATC_MiThermometer/releases/tag/30

twocolors avatar Jan 22 '21 14:01 twocolors

Hi,

you can use this forked repo - here is all optimized inside ;) https://github.com/pvvx/ATC_MiThermometer/

Michael

michapr avatar Jan 23 '21 07:01 michapr