Convert ohm value to celsius from a pt1000

Hello everyone, I have built a box that records temperature and humidity using pt1000 and the wet bulb technique. Inside the box there is an esp32 with esphome and two Max31865, via rest api node red polls the data, obviously the value in ohm is returned, what ways are there to convert ohm to celsius? I read around that there is a formula for the conversion but I don't understand how to turn it into code in the function node. Has anyone already addressed this topic? Many thanks in advance.

How many ohms equals what temperature? Somewhere in the device docs there should be some type of graph or conversion formula.

If it is a simple mathematical formula, then a change node would do it.
declare the factor and use jsonata function to multiply the factor with input resistance value.

[{"id":"afbbd5d097a09fdc","type":"inject","z":"31b9b5175e679dd4","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"150","payloadType":"num","x":320,"y":140,"wires":[["93bb56ebaa1a5586"]]},{"id":"93bb56ebaa1a5586","type":"change","z":"31b9b5175e679dd4","name":"Convert Ohms to Celcius","rules":[{"t":"set","p":"factor","pt":"msg","to":"0.3916","tot":"num"},{"t":"set","p":"celcius","pt":"msg","to":"payload*factor","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":140,"wires":[["213c8f7b08a68d94"]]},{"id":"213c8f7b08a68d94","type":"debug","z":"31b9b5175e679dd4","name":"debug 465","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"celcius","targetType":"msg","statusVal":"celcius","statusType":"msg","x":790,"y":140,"wires":[]}]
1 Like

Sounds like a lookup table might be necessary for proper conversation...

True, but with the table I don't have the correspondence of tenths of a degree while through the mathematical formula I have a higher resolution, furthermore it is more immediate to implement via software

When I can access to my PC I'll try, really thank you

For completeness I am inserting a link that refers to the aforementioned formula, you can find it at the bottom of the page.
Ps. This is for pt100, I need for pt1000

Changed the function as per your link. Celcius=Ohms*0.29262-292.62. (Approximation)

[{"id":"afbbd5d097a09fdc","type":"inject","z":"31b9b5175e679dd4","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1000","payloadType":"num","x":330,"y":140,"wires":[["93bb56ebaa1a5586"]]},{"id":"93bb56ebaa1a5586","type":"change","z":"31b9b5175e679dd4","name":"Convert Ohms to Celcius","rules":[{"t":"set","p":"factor","pt":"msg","to":"0.29262","tot":"num"},{"t":"set","p":"celcius","pt":"msg","to":"$round((payload*factor)-(1000*factor), 2)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":140,"wires":[["213c8f7b08a68d94"]]},{"id":"213c8f7b08a68d94","type":"debug","z":"31b9b5175e679dd4","name":"debug 465","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"celcius","targetType":"msg","statusVal":"payload&' ohm- '&celcius&'°C'","statusType":"jsonata","x":790,"y":140,"wires":[]},{"id":"8bbbef10ea84df08","type":"inject","z":"31b9b5175e679dd4","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1100","payloadType":"num","x":330,"y":180,"wires":[["93bb56ebaa1a5586"]]},{"id":"22c6891e7dfa0d3c","type":"inject","z":"31b9b5175e679dd4","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1194","payloadType":"num","x":330,"y":220,"wires":[["93bb56ebaa1a5586"]]}]
1 Like

If the response curve is linear, then you can do the conversion inside a range node. You just read the ohms at 2 known temperatures (ideally 0 from ice water, and 100 from boiling water), and enter those into the input range values:

et voila, no coding needed.

1 Like

Excellent solution, in reality the conversion is not perfectly linear and has a slight curvature, however I will also test this option to understand if the deviation is acceptable for my needs (measure a value between - 10 and +60)

Here is some Javascript code you can use in a function node to carry out the conversion from resistance in ohms to temperature in degrees Celsius:

    // Callendar-van Dusen equation gives r/r0 as a function of t,
    // where r is the PRT resistance at temperature t degrees C,
    // and r0 is the PRT resistance at 0.0 degC:
    // W(t) = r/r0 = 1 + At + Bt^2 + Ct^3(t - 100)
    // For temperatures >= 0.0 degC, C = 0
    const r0 = 1000.0;
    // C-vD reference function coefficients from EN 60751:1996
    const A = 3.9083e-3, B = -5.775e-7, C = -4.183e-12;
    const r = msg.payload;
    const w_minus_1 = r/r0 - 1.0;
    // Use the quadratic formula for temperatures >= 0.0 degC
    let t = (-A + Math.sqrt(A*A + 4*B*w_minus_1))/(2*B);
    // For negative temperatures, apply the van Dusen correction
    // using an iterative approach. A single iteration gives good
    // enough accuracy for temperatures down to -55 degC
    if (t < 0.0) {
        t = w_minus_1/(A + B*t + C*t*t*(t - 100.0));
    msg.payload = t;
    return msg;

I hope you find it useful!


It was exactly what I was looking for! A thousand thanks

Thanks again to everyone who proposed solutions.

The device changes resistance based on temperature. You need to calibrate it by exposing it to known temperature and recording the resistance. Boiling water and freezing water are easy since the temperature is pretty well known and you don't need another thermometer.

Once you have some readings you can create a table, or a mathematical function to convert your readings into a temperature.

There will always be variances when manufacturing so each device may read slightly differently. The more expensive devices are usually calibrated at the factory and do this conversion for you.

There might be a graph or formula in the data sheet for the device.

You are right, there are many factors that affect the resistance variation such as the type and length of the cable, it is however true that these variations can be ignored if an extremely precise temperature is not needed as in my case. A good calibration is necessary (and in any case must be repeated regularly) in case it is necessary to provide certified values

I would also like to add that the calibration method using boiling water is not reliable, in fact it is known that water boils at different temperatures based on atmospheric pressure, the lower the pressure the lower the temperature at which the water goes to boiling. If we wanted to carry out a precise calibration, a certified reference thermometer with still valid certification is still necessary. Obviously this need does not concern us mere mortals.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.