PICAXE-18X & Philips EE: Power-saving
Temperature Monitor
This application shows the use of the PICAXE-18X
as a simple datalogging system, with a focus on very low power
consumption by active control of the power supply of the DS18B20
temperature sensor.
Introduction
My son Joost and I jointly developed this simple datalogging
system, and used it to test the quality of our fridge, as I had
the impression that food (especially meat) could not be preserved
long enough. Normally, food should be kept at an optimum
temperature of about 4 degrees Celsius, so our goal was to see
whether this temperature could be maintained by our fridge on
average.
Hardware & Software Methods
The hardware setup is very simple, using input 0 to read the
temperature values from the DS18B20 temperature sensor. Some leds
were present at outputs 5-7 to signal whether the system is going
to measure or to send previously measured data stored in the
picaxe's EEPROM. In the initial phase of execution a switch at
input 7 is read to determine whether data has to be sent (default
case, input is high; switch left open) or measurements have to be
made (switch pressed, input is low). After measurements have been
made or data has been sent the computer enters low-power mode.
Battery power of 4.5V is applied, with a 100uF capacitor fixed to
the battery input pins. The Philips EE system
has been used for prototyping.
Special precautions have been taken to reduce current
consumption:
- Use of NAP and SLEEP commands for timing, instead of
PAUSE
- Active control of the Vcc of the DS18B20 temperature
sensor. The datasheet mentions the sensor may consume up
to 9 mA continuously, which is a significant amount in
case of measuring over long time intervals. As a PICAXE-18X
output is allowed to sink up to 25mA, one or two DS18B20
sensors may be supplied directly by it, and in this
application the output has been programmed to provide
supply only when needed for a measurement:
- Vcc of DS18B20 is connected to output 7 of PICAXE
instead of 5V.
- When a measurement has to be performed the
sensor's Vcc is pulled high
- The DS18B20 requires at least 750 ms to produce a
temperature reading in digital format. A SLEEP
command has been used to keep the PICAXE idle for
a period of time.
- Subsequently, the temperature sensor is read
using readtemp.
- Finally Vcc is pulled down again to stop the
sensor's current consumption.
After power-down of the system it took several minutes for the
100uF capacitor to discharge to such a level that the system
would come up again when the batteries were reconnected,
indicating very low power consumption.
Code:
Results
The graph below shows the temperature measurements inside our
fridge starting at around 23:00 hrs in the evening, with
measurements ending the next morning at about 8:00 hrs. The
fridge was set at maximum cooling. The door had to be opened to
place the sensor in the middle of the fridge, and around 7:00 hrs
the fridge was opened twice for breakfast.preparation. The graph
was made using Microsoft Excel.
We can draw some interesting conclusions from this graph:
- (-) Our fridge apparently is not able to maintain a low
temperature (5 degrees celsius or less); instead the
average temperature is about 7 degrees Celsius, which is
too high in case of maximum cooling.
- (-) The fridge does not seem to have an "intelligent"
cooling strategy to continuously regulate the temperature
towards a stable, low temperature. Rather, it seems to
actively cool towards 5 degrees Celsius in between fixed
time intervals of about two hours, apparently assuming a
perfect thermal isolation in order for this temperature
level to be maintained for a certain period of time.
During most of the time there is no active cooling and
the temperature is allowed to increase without any
consequences. As a result of thermal leakage the average
temperature is about 2-3 degrees above the minimum
temperature attained during cooling.
- (-) During the night the average of the logged
temperature values seems to drop slowly, possibly caused
by a temperature drop in the environment (which is
realistic during the night). This too suggests thermal
leakage, i.e. poor thermal isolation, and is best checked
by a re-run of the program with an additional DS18B20
sensing and logging the environment (kitchen) temperature.
Straightforword reasoning suggests the performance of the
fridge during daytime might be even worse!
- (+) The fridge is able to cool quicly; within a few
minutes after the door has closed the temperature has
decreased towards the average temperature of 7 degrees
Celsius, as shown at the end of the measurement interval.
Since our fridge is quite old these results do not come as a
complete surprise and do indicate that food cannot be conserved
very long. The simple and somewhat ineffective cooling strategy
was somewhat of a surprise though.
Comments/Suggestions
- In some cases many sensors are used and consequently draw
more current than a PICAXE output can provide. A common
Vcc rail for the sensors may then be switched on/off by a
transistor controlled by the PICAXE output.
- Passive sensor networks (simple voltage dividing networks
with LDR's, NTC's and so on) constantly drain current too
and may be switched on/off in the same manner as the DS18B20
sensor application described here.
- The BASIC program presented here also fits into a PICAXE-08M,
but as both program and data have to fit into the 256
byte eeprom memory some code optimizations are
appropriate in order to be able to store a reasonable
amount of data.(for example the signalling subroutines
may be removed completely). See also Stan Swan's page
for several highly space-efficient datalogging programs
for the 08M. The Vcc control solution described here can
be added to his programs very easily.
- Further power reduction is possible by removing some
LEDs, replace the remaining one(s) with high efficiency
types and by reducing the on/off ratio.
Contact me