# Convert ohm value to celsius from a pt1000

**URL:** <https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540>\
**Category:** General\
**Created:** [14 January 2024 21:34 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540 "2024-01-14T21:34:37Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![essereumano](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/essereumano/32/48262_2.png) [@essereumano](https://discourse.nodered.org/u/essereumano)\
**Post date:** [14 January 2024 21:34 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/1 "2024-01-14T21:34:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [14 January 2024 21:55 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/2 "2024-01-14T21:55:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [14 January 2024 21:58 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/3 "2024-01-14T21:58:33Z")

</div>

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.

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![waldbaer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/waldbaer/32/74212_2.png) [@waldbaer](https://discourse.nodered.org/u/waldbaer)\
**Post date:** [14 January 2024 22:04 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/4 "2024-01-14T22:04:08Z")

</div>

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

> **[Adafruit MAX31865 RTD PT100 or PT1000 Amplifier](https://learn.adafruit.com/adafruit-max31865-rtd-pt100-amplifier/arduino-code)**
>
> To get precision and accuracy out of your platinum (PT100 or PT1000) RTD you must use an amplifier that is designed to read the low resistance. Better yet, have an amplifier that can automatically adjust and compensate for the resistance of the...

---

<div class="post-metadata">

**Author:** ![essereumano](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/essereumano/32/48262_2.png) [@essereumano](https://discourse.nodered.org/u/essereumano)\
**Post date:** [14 January 2024 22:06 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/5 "2024-01-14T22:06:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![essereumano](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/essereumano/32/48262_2.png) [@essereumano](https://discourse.nodered.org/u/essereumano)\
**Post date:** [14 January 2024 22:06 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/6 "2024-01-14T22:06:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![essereumano](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/essereumano/32/48262_2.png) [@essereumano](https://discourse.nodered.org/u/essereumano)\
**Post date:** [14 January 2024 22:10 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/7 "2024-01-14T22:10:14Z")

</div>

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

> **[PT100 Calculator | Fluke Calibration](https://us.flukecal.com/pt100-calculator)**
>
> Quickly convert RTD resistance to temperature or vice versa in Celsius, Fahrenheit, or Kelvin for PT-385 or PT-392 at 100, 500, 1000 or any other value of Ohms.

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [15 January 2024 01:59 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/8 "2024-01-15T01:59:08Z")

</div>

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

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [15 January 2024 19:42 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/9 "2024-01-15T19:42:26Z")

</div>

**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:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/d/4dfd52fe8d8a4659e79f490c01bd63e69a1b03d9.png)

et voila, no coding needed.

---

<div class="post-metadata">

**Author:** ![essereumano](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/essereumano/32/48262_2.png) [@essereumano](https://discourse.nodered.org/u/essereumano)\
**Post date:** [15 January 2024 20:12 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/10 "2024-01-15T20:12:51Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![maxwellhadley](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxwellhadley/32/7827_2.png) [@maxwellhadley](https://discourse.nodered.org/u/maxwellhadley)\
**Post date:** [15 January 2024 22:22 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/11 "2024-01-15T22:22:52Z")

</div>

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:

```auto
    // 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!

---

<div class="post-metadata">

**Author:** ![essereumano](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/essereumano/32/48262_2.png) [@essereumano](https://discourse.nodered.org/u/essereumano)\
**Post date:** [16 January 2024 14:22 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/12 "2024-01-16T14:22:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![essereumano](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/essereumano/32/48262_2.png) [@essereumano](https://discourse.nodered.org/u/essereumano)\
**Post date:** [16 January 2024 14:23 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/13 "2024-01-16T14:23:43Z")

</div>

Thanks again to everyone who proposed solutions.

---

<div class="post-metadata">

**Author:** ![jsprenkle](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jsprenkle/32/81249_2.png) [@jsprenkle](https://discourse.nodered.org/u/jsprenkle)\
**Post date:** [19 January 2024 18:28 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/14 "2024-01-19T18:28:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![essereumano](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/essereumano/32/48262_2.png) [@essereumano](https://discourse.nodered.org/u/essereumano)\
**Post date:** [19 January 2024 19:07 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/15 "2024-01-19T19:07:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![essereumano](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/essereumano/32/48262_2.png) [@essereumano](https://discourse.nodered.org/u/essereumano)\
**Post date:** [21 January 2024 13:46 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/16 "2024-01-21T13:46:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 February 2024 13:47 UTC](https://discourse.nodered.org/t/convert-ohm-value-to-celsius-from-a-pt1000/84540/17 "2024-02-04T13:47:36Z")

</div>

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