# Conversion Temperature (Celsius) to RGB Value

**URL:** <https://discourse.nodered.org/t/conversion-temperature-celsius-to-rgb-value/34548>\
**Category:** General\
**Created:** [20 October 2020 09:22 UTC](https://discourse.nodered.org/t/conversion-temperature-celsius-to-rgb-value/34548 "2020-10-20T09:22:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noschvie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/noschvie/32/21425_2.png) [@Noschvie](https://discourse.nodered.org/u/Noschvie)\
**Post date:** [20 October 2020 09:22 UTC](https://discourse.nodered.org/t/conversion-temperature-celsius-to-rgb-value/34548/1 "2020-10-20T09:22:29Z")

</div>

Hello  
is there a function available to convert a temperature value (range 10° Celsius up to 90°) to a RGB value representing the colour ? The calculated colour / RGB value shall be used to controll a LED.  
Thanks!

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 October 2020 12:55 UTC](https://discourse.nodered.org/t/conversion-temperature-celsius-to-rgb-value/34548/2 "2020-10-20T12:55:52Z")

</div>

The range node might work

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 October 2020 12:58 UTC](https://discourse.nodered.org/t/conversion-temperature-celsius-to-rgb-value/34548/3 "2020-10-20T12:58:12Z")

</div>

A quick search of the forum reveals....

> [@"Colour mapping" - help needed to create RGB value](https://discourse.nodered.org/t/colour-mapping-help-needed-to-create-rgb-value/33364/13):
>
> Here is an adaption of that code. As you didnt specify how you want RGB to be represented, I just spit out a whole bunch of different values (r,g,b,val,hex) in the payload object. Ignore the pink image nodes at the bottom - they are to demonstrate it working. [{"id":"e17b05ed.383be8","type":"inject","z":"f057b3e5.0b042","name":"","topic":"","payload":"30","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":140,"wires":[["bfca8794.36a6e8"]]},{"i…

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [20 October 2020 15:28 UTC](https://discourse.nodered.org/t/conversion-temperature-celsius-to-rgb-value/34548/4 "2020-10-20T15:28:08Z")

</div>

Nice, I as going to just set up a ratio, since RGB is 0-255 and Celsius is 0 to 100. Of course you could weight the ratio per color by percentage, to get some nice colorization. So a nice red, that is not just all red, could be red 75%, 10% green and 15% blue, once you establish the ratio for red for example.

---

<div class="post-metadata">

**Author:** ![Noschvie](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/noschvie/32/21425_2.png) [@Noschvie](https://discourse.nodered.org/u/Noschvie)\
**Post date:** [20 October 2020 16:22 UTC](https://discourse.nodered.org/t/conversion-temperature-celsius-to-rgb-value/34548/5 "2020-10-20T16:22:31Z")

</div>

Perfect, seems to do what I want, thanks!

---

<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:** [3 November 2020 16:22 UTC](https://discourse.nodered.org/t/conversion-temperature-celsius-to-rgb-value/34548/6 "2020-11-03T16:22:37Z")

</div>

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