Having returned from my holiday in the winter sun , I removed the battery from its holder and set about fitting the XH2-2.54mm female connector to the battery holder leads.
I then modified the sketch to reduce the drift in the sleep time which is evident in the chart from Long Term Test 2, repeated below:
I checked the battery voltage and was pleased to see that it still showed 3.74 V on my DMM. Rather than charge it, I decided to reconnect the Wemos d1 mini system and see how much longer the battery would last
When I terminated Long Term Test 2, the battery voltage, as monitored by the Wemos d1, was 3.64V. When I reconnected everything and restarted the sketch, the battery voltage as monitored by the Wemos was 3.8V.
I assume that the improvement in the cabling between the battery and the battery shield could be making a difference. By fitting the XH2-2.54mm female connector to the battery holder leads, I have eliminated 1 pair of screw terminals, 1 pair of Dupont type connections and 2 short lengths of wire
First Partial Test:
I terminated this test run after just over 25 hours, to allow for further correction of the sleep time. At the start of this partial run, the battery voltage, as measured by the Wemos A/D was about 3.8V and at the end it was about 3.75V.
One observation from this first partial test is that the battery voltage appears to be noisier during the night - when the temperature drops.
After adjusting the sleep time correction factor, I had to leave my workspace for a while and left the Wemos still powered from my PC. When I returned, I glanced at the log file and found that the sleep time error was very different from what I expected. I wondered if this might be a function of being powered via USB, rather than by battery. Keen to fully investigate the power consumption, I decided to leave the issue of power source affecting the accuracy of sleep time on one side for now.
I reconnected the battery and restarted the test, to run for a further 24 hours.
Second Partial Test
The battery voltage at the start of this run was about 3.75V and at the end of the run it was about 3.7V - this is over approximately 24 hours. Once again, the measured voltage seems to be noisier overnight - it was colder!
Now that the sleep time error is much less, it's possible to discern a variation of the error with ambient temperature.
I made a further adjustment to the sleep time, reconnected the battery and started another test, intending to run this one until the Wemos stopped working
Third Partial Test
I stopped this partial run after about 3 days, in order to make some minor alterations, including modifying the date/time stamp to use the 24 hour clock instead of am and pm:
The voltage at the start of this partial run was about 3.71V and at the end of the run it was about 3.59V
I restarted the system, determined this time to leave it until the Wemos stopped working. - ie until the battery voltage has fallen below the level required to keep the battery shield delivering 5V. According to the Wemos data sheet, this should be 3.2V,
Fourth and Final Partial Test
And finally, the Wemos dies! The final battery voltage, as measured by the Wemos A/D, was about 2.81V, after a further 3 days. This is a lot lowerr than the 3.2V stated in the Wemos data sheet.
In total, with interruptions, the battery lasted about 336 hours, or 14 days, far longer than originally predicted!
I have concatenated all the battery files together to show the whole discharge pattern - apologies for the first section, before I fitted the correct connector to the battery leads!
The date/time axis has interruptions in it, but is set to display a value every 1440 readings. With +ve drift in the sleep time, this will be slightly more than 24 hours.
The 18650 Li-ion battery lasted far longer than I anticipated - a total of 14 days, with readings at 1 minute intervals. Increasing the interval between readings to 5 minutes would give a battery life of perhaps up to 70 days - plenty long enough for a remote, unattended device.
There is some evidence that the accuracy of the sleep time duration of the Wemos is affected by ambient temperature. In my real application - monitoring inside and outside temperature of an unheated greenhouse - I can expect the temperature swing experienced by the Wemos to be somewhat greater than at my workspace.
I am also aware that the performance of the 18650 Li-ion battery is likely to be affected by ambient temperature.
The crude prototype system has been sealed up in a plastic food container and moved out to one of the greenhouses. One probe is hanging out of the window, a few inches away from the glass; the other is hanging over the potting bench, shielded from direct sunlight.