Friday, August 28, 2015

Current optimization of wireless measurement sensors - part 2

In the last post I managed to reduce the average current consumption of my wireless temperature and humidity sensors by about 20% to 1.56 uA just by reducing the measurement resolution. Figure 1 shows the current profile after this optimization. In this post I try to reduce the current used in the measuring process, i.e. the smaller spikes, even further.
Figure 1. Current usage after optimizations implemented last time. Small spikes are humidity and temperature measurements and the large spike is measurement together with radio communication

I'm using the sensors in "hold master" mode, in which the sensor IC keeps SCL of the I2C bus low during the measurement. This is the fastest mode to get measurements out of the sensor as no polling or waiting is required. However, when an I2C line is pulled low, current flows through the pull-up resistor. In my case this resistor is 10 kilo-ohms, which produces a current of 300 uA. This current is equivalent to the amount used by the whole sensor IC itself. Furthermore, although the microcontroller (ATMEGA328P) is in idle sleep mode while the sensor IC measures, the idle mode current consumption is still greater than that of the sensor.

My plan is to switch the measurement mode to "no hold master" so that the sensor IC releases the I2C bus and to put the processor into power-save sleep mode in which only the 32.768 kHz low-power crystal oscillator runs. I don't want to mess with the timer prescale settings so that I still have accurate timestamps on the measurements. The prescaler is set to its maximum, which is divide by 1024. This gives a minimum sleep time of 31.25 ms. The measurement time is significantly shorter than this, but this shouldn't increase the power consumption as the sensor IC will go into sleep mode after it completes a measurement. Figure 2 shows the result of this.

Figure 2. Current usage using "no hold master" mode in measurements and putting CPU in power save mode during measurements.

It is evident that the current consumption increased as a result. I guessed that the reason was that it took such a long time to get the processor out of power save mode (start all the clocks and wait for them to stabilize etc.) that all benefit of that mode was lost. I reverted back to using the idle sleep mode of the processor, but lowered the CPU clock speed before doing so to save power. This is very unstatisfying as the internal RC oscillator of the microcontroller already takes about 100 uA of current. With that amount of current at hand, I can't waste time after the measurement has been completed. With this modification the we get the results shown in figure 3.
Figure 3. Current usage using "no hold master" mode in measurements and putting the CPU in low clock frequency idle mode during the measurements.
This modification had the side effect that I also used a lower CPU clock frequency while waiting to receive an acknowledgement of data over the radio. The current used for the radio communication thus also slightly decreased. Longer time period plots of the current usage before and after this optimization are shown in Figures 4 and 5, respectively.
Figure 4. Current usage before this optimization.
Figure 5. Current usage after this optimization.
With these modifications the hypothetical battery life (using CR2032 @ 250mAh) of the measurement devices has gone up from around 14 years to 17.5 years to 18.9 years. Of course this is probably nowhere near the actual battery life as real batteries have non-ideal behavior such as self discharge and high internal resistance, also these measurements assume a 100% success rate in radio transmission. I'm confident though that they'll last at least a couple of years.

No comments:

Post a Comment