Looking for an accurate sensor to measure water temperature

I am using a max31855 thermocouple and an esp8266 to measure the temperature of water in a water tank. It works great except for the +/- 2°C error that is expected.

I tried calibrating the sensor using the voltage coefficients mentioned in the datasheet as well as the code provided by some veterans in the community. It works, but sometimes (especially when the esp is connecting to the wifi), I get wrong readings. I tried providing the max31855 with its own power supply and placing a capacitor in the power lines but that didn't resolve the problem.

This is my calibration function:


float State::get_calibrated_temperature()
{
    float thermocoupleVoltage = (Thermocouple_max31855.readCelsius() - Thermocouple_max31855.readInternal()) * 0.041276;

    float coldJunctionTemperature = Thermocouple_max31855.readInternal();
    float coldJunctionVoltage = -0.176004136860E-01 +
                                0.389212049750E-01 * coldJunctionTemperature +
                                0.185587700320E-04 * pow(coldJunctionTemperature, 2.0) +
                                -0.994575928740E-07 * pow(coldJunctionTemperature, 3.0) +
                                0.318409457190E-09 * pow(coldJunctionTemperature, 4.0) +
                                -0.560728448890E-12 * pow(coldJunctionTemperature, 5.0) +
                                0.560750590590E-15 * pow(coldJunctionTemperature, 6.0) +
                                -0.320207200030E-18 * pow(coldJunctionTemperature, 7.0) +
                                0.971511471520E-22 * pow(coldJunctionTemperature, 8.0) +
                                -0.121047212750E-25 * pow(coldJunctionTemperature, 9.0) +
                                0.118597600000E+00 * exp(-0.118343200000E-03 *
                                                         pow((coldJunctionTemperature - 0.126968600000E+03), 2.0));

    float voltageSum = thermocoupleVoltage + coldJunctionVoltage;

    float b0, b1, b2, b3, b4, b5, b6, b7, b8, b9;
    if (thermocoupleVoltage < 0)
    {
        b0 = 0.0000000E+00;
        b1 = 2.5173462E+01;
        b2 = -1.1662878E+00;
        b3 = -1.0833638E+00;
        b4 = -8.9773540E-01;
        b5 = -3.7342377E-01;
        b6 = -8.6632643E-02;
        b7 = -1.0450598E-02;
        b8 = -5.1920577E-04;
        b9 = 0.0000000E+00;
    }
    else if (thermocoupleVoltage < 20.644)
    {
        b0 = 0.000000E+00;
        b1 = 2.508355E+01;
        b2 = 7.860106E-02;
        b3 = -2.503131E-01;
        b4 = 8.315270E-02;
        b5 = -1.228034E-02;
        b6 = 9.804036E-04;
        b7 = -4.413030E-05;
        b8 = 1.057734E-06;
        b9 = -1.052755E-08;
    }
    else if (thermocoupleVoltage < 54.886)
    {
        b0 = -1.318058E+02;
        b1 = 4.830222E+01;
        b2 = -1.646031E+00;
        b3 = 5.464731E-02;
        b4 = -9.650715E-04;
        b5 = 8.802193E-06;
        b6 = -3.110810E-08;
        b7 = 0.000000E+00;
        b8 = 0.000000E+00;
        b9 = 0.000000E+00;
    }
    else
    {
        // Handle error - out of range
        return previous_temperature;
    }

    float calibratedTemperature = b0 +
                                  b1 * voltageSum +
                                  b2 * pow(voltageSum, 2.0) +
                                  b3 * pow(voltageSum, 3.0) +
                                  b4 * pow(voltageSum, 4.0) +
                                  b5 * pow(voltageSum, 5.0) +
                                  b6 * pow(voltageSum, 6.0) +
                                  b7 * pow(voltageSum, 7.0) +
                                  b8 * pow(voltageSum, 8.0) +
                                  b9 * pow(voltageSum, 9.0);

    return calibratedTemperature;
}

I am looking for an alternate sensor that can measure the temperature of water in a water tank precisely and accurately to the 100ths of degrees C.

Any suggestions as to which sensor I should use?

A tough ask!

Have you considered ds18b20? These come in supposedly waterproof versions (I've heard that only the metal part of the sensor should be immersed, keeping the other end, where the wires emerge, out of the liquid, even though it is supposed to be sealed). These don't have 0.01C precision either, but may be better than your thermocouple.

What is the temperature range you need 0.01C precision over?

How quickly might the temperature change?

Is the water intended for use in food production or human consumption?

1 Like

Sorry I meant 10th of degrees....

I have not used these but will order some and see how they work.

No. Just regular water heater tank meant for cleaning purpose I supose.

In theory, ds18b20 has sufficient precision for this if you use it's (slow) 12-bit precision mode. But precision does not mean accuracy. The claimed accuracy is only 0.5C, but perhaps further calibration can improve that. If course, you need something even more accurate to calibrate against!

Why would you need to measure temperature to 0.1C for this purpose?

1 Like

Thank you for your suggestion. I will get the sensor today and will update on the results.

The application I am building requires actions to be done at specific temperatures and those temperatures have a 0.1C precision.

That sounds utterly unreasonable, and implies you need a controlled environment, which you should address first.

1 Like

Assuming you mean 0.1 C accuracy, careful insulation of the environment and good stirring will be extremely important. In addition, the control system must be able to maintain a temperature with much less than 0.1 C variation.

Not a task to be taken lightly, as the temperature measurement is the least of your problems.

1 Like

For greatest accuracy and repeatability you should abandon thermocouples entirely. A platinum RTD is what you need. Even then you will have to calibrate your measurement system against a known reference to get 0. 1 C accuracy. I cannot imagine where such accuracy would be required, especially for “cleanup water”.

As stated by others there is a big difference between precision and accuracy. You can still program to 0.1 precision but you will have to adjust your action points to offset the inaccuracy of your measurement.

1 Like

other problems are where you measure the temperature and where the water is heated and is the water continually recirculated. Any of those will negate any accuracy you try to achieve.

1 Like

Hi,

What is the reason for not accepting +/- 2DegC?

Is the tank insulated?

What is the capacity of the tank?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

1 Like

I do not think the OP understands how regular water heaters work. Is the heater gas fired or electric? If the tank is vertical, how far from the top is the thermostat that controls the heating?

1 Like

First of all, thanks to everyone for your contributions.

I understand the difference between accuracy and precision. It's worth mentioning that this is a project for a company that I work for, and these temperature thresholds that have a 0.1 precision are what they require.

So I was looking for a sensor that has both a precision of 0.1C but that also a pretty narrow range of accuracy straight out of the box. The reason for this is because this is for a commercial product and thus calibrating each sensor individually would be a hassle.

Yes they are insulated.

The tanks have varying capacities: 150L, 210L and 300L.

Yes you are right good sir, I do not know much about water tanks. If you could educate me on what issues could be faced in a situations when accurate temperature readings are needed, I would be grateful.

There will be different types of tanks (all vertical):

  1. Direct heating: electric element placed either at the top or the bottom of the tank, depending on the model.

  2. Indirect heating: Heat pump fueled by gaz, fioul, etc.

The sensor is placed in the same pocket where the original thermostat is placed.

Again, it depends on the model. Some do circulate the waters and others don't.

But one thing I forgot to mention is that regardless of the model, the initial step is to heat up the water to a certain temperature. Only after this temperature is achieved will the actual program run.

I probably missed some questions, so if I did, please let me know.

From your descriptions, there will never be a common method and location to measure "water temperature". Each type of tank will be different. Did someone do the engineering of the systems or did they just get added one at a time as they were needed?
If this was my project, I would identify each tank by number and make a drawing of each different tank. Show the water input and output and location of the heating element(s).
Once done you can indicate the proper location for a temperature sensor.

Please define "pretty narrow", and state the accuracy that is required for the uniformity of the temperature throughout the tank, and for maintaining the temperature.

Some do circulate the waters and others don't.

It is impossible to have uniform water temperature in tanks that do not circulate.

2 Likes

If you want an uncertainty that close I hope your water is moving in the tank. Thermal stratification can be a problem unless your water in the tank is moving or agitated. The warmer less dense water will stay on the top trapping the colder more dense water on the bottom. This is why if you want temperature uniformity you need agtitation.

Using a DS18B20 you will want a standard to compare your readings against. What temperature range did you have in mind?

Ron

1 Like

Remember your physics. Warm water rises and replaces cooler water. The only place where the water will be as you measured it will be at that specific place. It cannot measure the water in other parts of the tank.

1 Like

What is the tolerance of their precision? Everything that is made or controlled has two specs. A target dimension and a tolerance value. For example a machined part may have a specification of 2.000 inches +/-0.00015 inches. A temperature control specification might have a specification of 85.0 deg C +/-2 degrees C. Or +2/-0 degrees C etc.

If you accepted a job without such a specification then you have assigned yourself an impossible task. To expect 0.1 degree C accuracy from off the shelf components is without much fussing is impossible.

I have stated in a previous post that platinum RTD’s have greater accuracy and repeatability than thermocouples. But even they are not that accurate off the shelf.

1 Like

Well whoever called out the specification of +/- 0.1 degree should know that while sensors and measurment instrumentation to do that is available it comes with a hefty price tag. I used PRTs which cost a few grand ($2,000 USD) and that was for sensor and calibration curves not including the instrumentation. Precision being just a high measure of repeatability while accuracy may be defined as unbiased precision. For a commercial application I would be looking to companies who manufacture what you actually want / need. When you start getting into the uncertainty you want the stuff is expensive. Granted been 10 years since I retired but the stuff is out there. Additionally temperature sinsors of this nature are normally calibrated periodically.

In addition to agitation which I mentioned earlier you may also want to consider response times of your sensors. Anyway whoever came up with an uncertainty of +/- 0.1 degree should well know what that uncertainty cost and it is not quite inexpensive. :slight_smile:

Ron

1 Like

Thank you Mr. Blain.

Yeah I am having some issues with these people. Expectations too high and understanding not so quite.

Anyways, I am terminating my cooperation with them because they think they can hire a freelancer to make them a complicated commercial product for a few bucks.

I hope they can find what they're looking for but it will not be with me.

Thank you to everyone who contributed to this question. It taught me that water tanks are not as simple as one might think.

God bless

Thank you for your insight. As I mentioned before, I don't know much about water tanks. There's an engineer that asked for those specs. I assumed he knew what he was talking about. For me it was just a matter of coding and checking for the right temperature. I assumed the control of the environment and the sensors that were used were studied and understood... Apparently not...

Anyways. Thank you again.