Temperature measurement in low power applications

rmeldo

Senior Member
A sanity check please.

It occurred to me that in applications where batteries need to last for a long time (years) a DS18B20 would not be a suitable sensor for temperature measurement, due to the fact that it takes quite a while to measure and transmit the temperature to the microcontroller. 12 bits accuracy requires 750 ms reading time + the transmission, etc. Most times 12 bits accuracy is not really needed, but still we would be looking at current draw of tens of second.

Does it make sense?

So I started to look at high precision thermistors with +/- 0.1 deg C accuracy.

Thermistors could be sampled in a shorter amount of time, even with some averaging.

Is this true, after everything that goes into making an accurate measurement is taken into account?

http://www.littelfuse.com/~/media/electronics/datasheets/leaded_thermistors/littelfuse_leaded_thermistors_interchangeable_thermistors_standard_precision_ps_datasheet.pdf.pdf

The datasheets mentions different R-T characteristic curves (A, R, J, ....).

I am struggling to find information on the exact definition of these curves. What are they? Does anyone have any pointers on where I could look?

Thanks in advance

Riccardo
 

techElder

Well-known member
Two points occur to me right off:
  1. Accuracy and resolution are two different things. Which one drives the specs on your project?
  2. I don't see how a thermistor (and all associated components) can be considered low powered.
current draw of tens of second
If a gadget takes 750 mSecs to convert a temperature, even considering transmission how do you get to that current draw time frame?

You haven't really explained the project and why you need to wait "years" to change batteries.
 

Jeremy Harris

Senior Member
I have a few cheap LCD thermometers dotted around the house, like these: https://www.ebay.co.uk/itm/Mini-LCD-Display-Digital-Panel-Mounted-Thermometer-With-Metal-Sensor-For-Testing/391004211365?hash=item5b09aac8a5:g:GhoAAOxyx0JThZjr

They run for around 2 to 3 years on two LR44 cells and use a thermistor as the remote sensor. I had a quick look at how they function and it seems that they energise the thermistor with a short pulse once every few seconds, read the resistance value, do the appropriate conversion sums and then update the LCD, before going back to sleep again. Doing the same with a Picaxe should be easy enough, I think. Just use one pin to apply power to a potential divider that has a fixed resistor and the thermistor sensor and use an A/D pin connected to the junction of the two to read the voltage, which will be proportional to the thermistor resistance. By only powering up the thermistor for a very short time, and putting the Picaxe back to sleep between readings, you should be able to get the power consumption right down.
 

rmeldo

Senior Member
Sorry,
A bit more details to frame the discussion.

My starting point is 2 AA batteries non rechargeable, Duracell type. The duty cycle would be to measure temperature every 10 minutes or so, transmit with a LoRa radio and then go to sleep.

I would like to have about 0.1 Deg resolution and accuracy. Worst acceptable accuracy would need to be, say, 0.25 Deg c.

My thinking is that the thermistor tolerance would control the accuracy and the DAC resolution/sampling method would control the resolution.

The times i quoted come from the DS18B20 datasheet for measurement time. For instance 12 bits resolution requires 750 ms.

I would have thought that sampling a thermistor a few times (for averaging) would take a fraction of that time, therefore reducing the time the microcontroller needs to be awake by quite a lot.

This is my thinking but I asked the question because I don't have much experience and I haven't experimented with thermistors yet

Riccardo
 

lbenson

Senior Member
My guess is that with 3-AAs and 10 minutes sleep, only transmit when there is a change, or if no change, every, say, 72 wake-ups (~12 hours) you would get quite a lot of runtime if all low-power precautions were taken, even with DS18B20. Every day (144 wake-ups) send the battery level (CALIBADC). (I can't quantify "quite a lot".)

Regarding acceptable accuracy, you can get .25C +resolution+ with DS18B20, but accuracy may be within a degree or so. With thermistors, I'm sure you would have to calibrate and probably temperature-compensate to get .25C accuracy (not that I've ever used them).

What about the project requires the .25 degrees of accuracy? That degree of accuracy requirement could rule out the DS18B20 more than its current draw.
 

Jeremy Harris

Senior Member
What sort of temperature range are you looking to measure over?

If it were me, then I think I would probably look at the low power end not doing any corrections, but just powering a thermistor/resistor on, taking a reading with the ADC and then transmitting the raw data before going to sleep.

Converting the raw data to accurate temperatures might well be easily achievable with a look-up table, if 0.25 deg C accuracy/resolution is only needed over a limited temperature range. For example, if measuring UK outdoor temperature, then a range of -15 deg C to +35 deg C would be adequate, which with 0.25 deg C resolution would mean a table with 200 entries. That's not massive, and, depending on what else you want the receiving end to do, is well within the capability of a Picaxe chip.

Alternatively, you may well find that you can come up with a good enough sequence of linear corrections, depending on the transmitted value. Once you have the parameters for the thermistor you wish to use, then using a few sectional linear corrections that approximate closely enough to Bosson's Law may well be good enough. For example, code that has a series of IF statements looking for a specific range of values and applying a slightly different correction factor for each may well be fine. This may well use less memory than a relatively large lookup table.
 

premelec

Senior Member
Thermistors are reliable and stable - AND quite non-linear ; see this site for equations; https://www.thermistor.com/calculators. If your temperature range is small they are easier to use and various schemes have been used to produce more linear output over wide range [see some discussion at www.phanderson.com where he looked at the Thermilinear 2 thermistor technique]. Commonly a lookup table and interpolation can be used. For a more linear device platinum sense units can be used [pt100 OR pt1000]. Temperature has a LONG history of measurement electronics... ;-0
 

AllyCat

Senior Member
Hi,

Mainly to confirm what others have said: Measuring a temperature once every ten minutes at low power should be easy (either with a thermistor or 18B20) but 0.25 degree C accuracy (and maybe 0.1 degree resolution over a large range) much less so. Just switch off power to the thermsitor/sensor, PICaxe and transmitter for 10 minute "sleep" periods.

But genuine 0.25 degree accuracy is hard to achieve and the thermistor calculations are complex. A PICaxe almost certainly needs to use a (precise) lookup table, maybe with interpolation; I've posted code snippets on the interpolation topic but not (yet) on the thermistor maths. I must admit that I was "disappointed" with Peter Anderson's solution if more than a modest temperature range is required. Due to the logarithmic resistance characteristic you may need much better than 10 bit ADC resolution for a moderate temperature range.

Cheers, Alan.
 

rmeldo

Senior Member
Thanks very much.

The range where accuracy is needed is 17-24 Celsius, very narrow, so perhaps a table coarse outside this range would do it.

For linearisation I saw a suggestion to use a resistor in parallel to the thermistor. The resistor having the resistance of the thermistor at the reference temperature. I haven't done the math but it makes sense. probably still non linear, with more equally spaced ADC samples.

The other resistor to choose is the one in series with the thermistor. A small one, say 1/10th of the thermistor value, would maximise the ADC range used. But what would be the drawbacks?

Finally the thermistor resistance at the reference temperature needs to be chosen to select the best one. It would make sense for it to be high, but then the current would be low. Then would the current used by the microcontroller to carry our the ADc sampling affect the measurement ?

Riccardo
 

AllyCat

Senior Member
Hi,

Microchip recommend that the PIC(axe) ADC inputs should be fed from a source impedance of no more than 10k, but a somewhat higher value may be used if a capacitor is connected from the ADC input to earth.

So for your temperature range a thermistor rated as 10k at 25 degrees C seems obvious. But I doubt if you'll get better accuracy than an 18B20. ;)

Cheers, Alan.
 

lbenson

Senior Member
Another factor to consider is how much of a difference in readings to you want to have before you report a change. With the DS18B20, if you are looking at 16ths of a degree C, you may see that it dithers, so you have a different reading every 10 minutes. Dithering can also happen with READTEMP, where the temperature is right at the tipping point of a degree. With a full 10-bit analog reading, it may be an even greater problem to figure out how much change you want to report.

For my non-critical readings with DS18B20, I use [NOT READADC12] READTEMP12, but I want to see a full degree--16 16ths difference--before I report a change.
 
Last edited:

Jeremy Harris

Senior Member
If only looking for a 17 deg C to 24 deg C range, then a thermistor and look up table is dead easy, it just needs calibration with a known standard thermometer. No need for any maths, as for 0.25 deg C accuracy/resolution you are only looking at a table with 28 values in it. The hardest part will be getting hold of a good enough reference thermometer and making a temperature controlled calibration rig. I've never needed better than about 0.5 deg accuracy, and managed to calibrate sensors using an NPL calibrated mercury reference thermometer. I don't have it to hand, but have a feeling that it's accurate to about 0.1 deg C.
 

Pongo

Senior Member
Consider using the SHT-31 as mentioned in this thread. Low power, high accuracy digital output, only needs a few milliseconds to make a measurement, and it does humidity too.
 

rmeldo

Senior Member
So I did the maths.

I looked at the option of adding a resistor in parallel with the thermistor. it is true that it linearises the response, but it also reduces the voltage change and therefore the resolution. So it is best to not fit it, as in a narrow temperature range the response is quite linear anyway.

Next I looked at the best value of the resistor in series with the thermistor to complete the voltage divider. It turns out that for maximum resolution it is best to set its resistance to be equal to the thermistor resistance in the middle of the temperature range to measure.

Attached is the Matlab script I used:

Code:
function aaa

Vcc  = 3.3;
Rpar = 100000000000000;
Rser = 10000;

DACbits = 10;

totSteps = 2^DACbits;

T = c2k(10:30);

% ------------------------------------
% data from:
% http://www.littelfuse.com/~/media/electronics/datasheets/leaded_thermistors/littelfuse_leaded_thermistors_interchangeable_thermistors_standard_precision_ps_datasheet.pdf.pdf
B  = 3892;
R0 = 10000;
T0 = c2k(25);
% ------------------------------------

R    = R0*exp(B.*(1./T-1/T0));
Req  = 1./(1./R + 1/Rpar);
Rtot = Req + Rser;

current = Vcc ./ Rtot;
Vadc    = Req .* current;

deltaV    = Vadc(1) - Vadc(end);
deltaVrel = deltaV / Vcc;

steps = floor(totSteps * deltaVrel);

resolution = (max(T)-min(T)) / steps;

figure(1)
clf
subplot(2,1,1)
   hold on
   grid on
   set(gca,'box','on')
   set(gca,'fontsize',12)
%    plot(k2c(T),R,'b')
   plot(k2c(T),Req,'r','linewidth',2)
   plot(k2c(T0),R0,'o','markersize',10,'markerFaceColor','b')
   title('Thermistor Resistance','fontsize',14)
%    xlabel('Temperature [°C]','fontsize',14)
   ylabel('[Ohm]','fontsize',14)
   myLegend({'Curve','Ref values'},'fontsize',14)
subplot(2,1,2)
   hold on
   grid on
   set(gca,'box','on')
   set(gca,'fontsize',12)
   plot(k2c(T),Vadc,'b-','linewidth',2)
   title(['V_{cc} = ' sprintf('%.1f',Vcc), ' V,  \DeltaV = ' sprintf('%.1f',deltaV) ' V, resol (' sprintf('%.0f',DACbits) ' bits) = ' sprintf('%.3f',resolution) ' °C'],'fontsize',14)
   xlabel('Temperature [°C]','fontsize',14)
   ylabel('[V]','fontsize',14)
   ylim([0 Vcc])

return

% -----------------------------------------------
function Tc = k2c(Tk)

Tc = Tk-273.16;


function Tk = c2k(Tc)

Tk = Tc+273.16;

function varargout = myLegend(varargin)

l = legend(varargin{:});
l.ItemHitFcn = @hitcallback_ex1;



function hitcallback_ex1(src,evnt)

if strcmp(evnt.Peer.Visible,'on')
    evnt.Peer.Visible = 'off';
else 
    evnt.Peer.Visible = 'on';
end

The result is that with a 10 bits ADC it is possible to get a resolution of 0.09 degC (see attached figure below).
It is all good on this front.

In terms of accuracy I agree that calibration will be needed, to compensate for the tolerances of all the components involved in the measurements chain.

The biggest problem will be to find an accurate thermometer to compare with.

I might downgrade my requirements and, rather than absolute accuracy, match the average of, say, 10 DS18B20.

That way I would get a very good accuracy in the slope. The main reason for using the thermistor instead than the Dallas sensor is the power consumption.


thermistor.jpg
 
Top