# Convert from Celcius to fairenheit

**URL:** <https://discourse.nodered.org/t/convert-from-celcius-to-fairenheit/34477>\
**Category:** General\
**Created:** [19 October 2020 01:06 UTC](https://discourse.nodered.org/t/convert-from-celcius-to-fairenheit/34477 "2020-10-19T01:06:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AD2TM](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@AD2TM](https://discourse.nodered.org/u/AD2TM)\
**Post date:** [19 October 2020 01:06 UTC](https://discourse.nodered.org/t/convert-from-celcius-to-fairenheit/34477/1 "2020-10-19T01:06:12Z")

</div>

I have set a Sonoff TH10 with the AM2301 temperature sensor. The flow I have is working well, with one exception. I can not figure out how to convert the celcius that the AM2301 outputs to Fahrenheit. I have a switch node parsing out the temp and humidity. I have the Humidity displaying on a chart and a Gauge.I have the temp also displaying on a chart and a gauge.I have tried a function node with this : var temp=msg.payload. AM2301 .Temperature;  
msg.payload = (temp \* 9/5 + 32).toFixed(2);  
return msg;  
I know the formula is correct because it is working in another flow.  
Can someone help this newbee?

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [19 October 2020 03:20 UTC](https://discourse.nodered.org/t/convert-from-celcius-to-fairenheit/34477/2 "2020-10-19T03:20:01Z")

</div>

Have you tried using [https://flows.nodered.org/node/node-red-contrib-unit-converter](https://flows.nodered.org/node/node-red-contrib-unit-converter).

It is written by a well known gent who hangs out here (and does some great work as well).  
Thanks @BartButenaers

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [19 October 2020 06:05 UTC](https://discourse.nodered.org/t/convert-from-celcius-to-fairenheit/34477/3 "2020-10-19T06:05:13Z")

</div>

Can we see a debug of the msg before the function node?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [19 October 2020 13:18 UTC](https://discourse.nodered.org/t/convert-from-celcius-to-fairenheit/34477/4 "2020-10-19T13:18:41Z")

</div>

> [@AD2TM](#):
>
> Sonoff TH10 with the AM2301

If you are using Tasmotta, you can get this directly, you don't need to convert unless you want both measures.

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)\
**Post date:** [19 October 2020 13:32 UTC](https://discourse.nodered.org/t/convert-from-celcius-to-fairenheit/34477/5 "2020-10-19T13:32:51Z")

</div>

> [@AD2TM](#):
>
> I can not figure out how to convert the celcius that the AM2301 outputs to Fahrenheit.

It can also be done using jsonata in a change node.  
See example at the end of [Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![AD2TM](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@AD2TM](https://discourse.nodered.org/u/AD2TM)\
**Post date:** [19 October 2020 16:54 UTC](https://discourse.nodered.org/t/convert-from-celcius-to-fairenheit/34477/6 "2020-10-19T16:54:05Z")

</div>

Thanks Bobo. I installed the convert units node,using the node manager in Node Red.  
Took me about two minutes to look it over and set it up. Working just great,  
Thanks again.Tom, AD2TM

---

<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:** [18 December 2020 16:54 UTC](https://discourse.nodered.org/t/convert-from-celcius-to-fairenheit/34477/7 "2020-12-18T16:54:10Z")

</div>

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