Issue #4 adjusted the watch face so that we fetch and display solar efficiency data.
Although this works, the watch's battery life isn't great (makes sense, we're doing SSL stuff every minute).
So I want to adjust so that we only fetch/write periodically.
Currently we:
What I want to adjust to is
To make creating the 5 minute interval simpler, solar/temperature have been swapped between odd and even.
#4 | Query Solar Status from InfluxDB |
#3 | Report steps and battery to InfluxDB |
Activity
16-Jun-23 07:59
assigned to @btasker
16-Jun-23 07:59
marked this issue as related to #4
16-Jun-23 07:59
marked this issue as related to #3
16-Jun-23 08:24
mentioned in issue #4
16-Jun-23 10:41
mentioned in commit sysconfigs/watchy-code@76deec75dfd0875b128f1d9c6e54f7ccccfeff1c
Message
Move to only polling solar status every 5 mins and cache result (misc/watchy-experimentation#5)
Out of (developer) convenience, this also swaps when solar efficiency data displays to odd minutes. Weather temperature data will now display on even minutes only.
16-Jun-23 10:41
mentioned in commit sysconfigs/watchy-code@4aa008383bd3b59d57044359b293061aec5a8ac3
Message
Switch distribution between even+odd minutes back (misc/watchy-experimentation#5)
16-Jun-23 10:41
mentioned in commit sysconfigs/watchy-code@2ab8bd93a963a6051934a1b7fcdbf6323d60543b
Message
Switch cache storage type (misc/watchy-experimentation#5)
Moves from
RTC_NOINIT_ATTR
toRTC_DATA_ATTR
.Haven't yet looked into why this makes a difference, but it seems to
16-Jun-23 10:41
mentioned in commit sysconfigs/watchy-code@76bb5520f079d956b8cd1532f83e0786140a9edd
Message
Revert "Switch cache storage type (misc/watchy-experimentation#5)"
This reverts commit 2ab8bd93a963a6051934a1b7fcdbf6323d60543b.
16-Jun-23 10:59
I've run into an issue storing the cached solar efficiency data with
RTC_NOINIT_ATTR
.Rather than getting the written value back, we get a long number (currently it seems to consistently be
786411844
).It looks like this might be because
RTC_SLOW_MEM
isn't being powered during deep sleep. That forum post says it's a bug, but I wondered if it was also possible that Watchy is specifically disabling it:Seems not.
I also wondered if I was relying on a false assumption - is the issue with that variable or are we receiving bad data from upstream?
Adding a couple of
display.print()
lines suggests upstream auth has started failing, so we're not actually getting a result back to write into that variable - we're probably just seeing the initial value.16-Jun-23 11:01
Switched auth and it suddenly appears to be working just fine.
You have to actually retrieve data to be able to use it.... who knew? :)
16-Jun-23 11:06
mentioned in commit sysconfigs/watchy-code@162015cf15daa5ea2e6e5eecc54cb6e4ab3dc3e3
Message
Fix auth - failing auth turned out to be the cause of issues in misc/watchy-experimentation#5
16-Jun-23 11:20
Currently, we're still toggling the Wifi on and off once a minute, because that happens in the calling function:
I think it's probably within the spirit of this issue to adjust that too.
We trigger (non weather) actions if the following is true:
currentTime.Minute % 5 == 0
currentTime.Minute % 2 != 0
currentTime.Minute % 5 == 0
We don't actually need the wifi on for solar display either.
So, it might be better to break that calling wrapper up a bit
It's not very tidy to read but can't easily be abstracted out: we can't just set (and pass) a boolean to a single call of
getSolarState
because we need to turn the radio off.However, we probably can make
getSolarState()
a little more CPU efficient. As we've already calculated the current minute modulo 5 we could just pass a boolean intogetSolarState()
so that it doesn't have to repeat the operation.We could, in fact, also pass the result of
currentTime.Minute % 2
into bothdrawWeather
andgetSolarState
- they both use them to identify which should be displaying for the current minute.16-Jun-23 11:35
mentioned in commit sysconfigs/watchy-code@e61409560f2e170b40a27860e1202f26f53d6331
Message
Only toggle wifi on if we're intended to place requests (misc/watchy-experimentation#5)
This gates the call to
connectWiFi
with a check of the current minute modulo 5.16-Jun-23 11:37
OK, so we now have the following update/display pattern
currentTime.Minute % 5 == 0
currentTime.Minute % 5 == 0
currentTime.Minute % 5 == 0
currentTime.Minute % 2 == 0
currentTime.Minute % 2 != 0
The combination of
2.
and5.
means that we don't actually fetch Solar data every 5 minutes, but instead every 10.The reason for this is that
getSolarState()
will only be called if the current minute is odd. Minutes00
,10
,20
,30
,40
and50
are not odd, therefore it won't be called (and so won't trigger an update).It wasn't entirely intentional, but I'm OK with this - I had been starting to think that a less frequent update cadence could be wise anyway, so this is a good result (as it's been achieved without wasting CPU time calculating another modulo).
To reduce CPU time, we now aim to calculate modulos once and pass a boolean in subsequent calls:
16-Jun-23 22:23
Re-opening to explore whether we're still polling too regularly
16-Jun-23 22:27
I had been meaning to look at adjusting how often calls are made to OpenWeatherAPI, but having looked into it they're actually already restricted to every 30 ticks (with each tick being a minute in this case).
In
Watchy.cpp
the relevant function starts asSo actually, the weather stuff only makes 2 external calls an hour.
By comparison, we've added
Increasing the number of external connections/hour by 10x.
Probably explains why the battery lasts about a day, rather than days.
16-Jun-23 22:34
If we switched to a 15 minute interval, we'd have
That's still a 5x increase (though it halves the number of requests vs now).
If we moved to 30 minute it'd be a 3x increase (there's no getting away from it being a sizeable increase - the base number is low, and we're doing a few things at once).
Obviously we could get it down to 1 by hosting a dedicated application, but I explicitly want to avoid that (at least for now: it could be interesting to put something together in LUA to handle it in OpenResty).
I think the answer is to move to 30 minutes and see how the battery life looks and then perhaps look at increasing.
I'll raise a seperate ticket if I decide to do it, but I have also considered having
telegraf
fetch the OpenWeatherAPI information and write into InfluxDB - that way the weather data could be fetched with a simple InfluxQL query, potentially cutting out some processing overhead vs using the API.16-Jun-23 22:38
mentioned in commit sysconfigs/watchy-code@4815c386a1dc7aa0948d8371df0d7506410c270a
Message
Move to making HTTP requests once every 30 minutes (misc/watchy-experimentation#5)
This amends our timing logic so that we update Solar efficiency data and write out stats once every 30 minutes.
The main aim here is to improve battery life
16-Jun-23 22:40
One minor drawback with the recent change: just after startup (i.e. after a new image has been flashed, or the watch's battery ran out etc), the Solar data won't currently show anything (because it'll not have been retrieved yet).
That was an issue prior to the change, but only really persisted for 5-10 minutes at most.
Having it persist for 30 minutes seems a bit much - we could check the cache for an initialisation value and run a fetch if necessary.
The catch with that, though, is if the watch reboots when out of wifi range - we're going to absolutely hammer the battery. Given it should be rare, seems better to accept that it may take up to 30 mins for the data to begin showing.
16-Jun-23 23:13
To support the 30 min update interval (at least without adding an additional ticker), I've had to swap solar back to the even minutes (this is getting ridiculous...) - 30/00 are both even.
16-Jun-23 23:18
mentioned in commit sysconfigs/watchy-code@656bb52e0291641449c7332c7037cf7581b91ce8
Message
Switch solar back to being on even minutes misc/watchy-experimentation#5
This is to ensure it's display aligns with the new 30 minute schedule
17-Jun-23 08:12
9ish hours later, the battery's still on 3 bips. That's a good sign, but we'll have to see how it does throughout the day.
Currently though, the calling function is defined as follows
19-Jun-23 08:04
It's about 33 hours since I last charged the watch, and it's still got 2 bips on the battery.
The latest stats writes into InfluxDB suggest the battery voltage is 3.97v so we're not far off dropping to one bip:
19-Jun-23 11:00
I'm going to close this as done.
There are things we could look at in future to improve efficiency further, particularly if we move to using InfluxDB as the source of truth for everything (because then we can send multiple queries in a single request). But, if I decide to play around with that, it's best left to a dedicated ticket.