# How to turn on RGB LED based on Temp from BME below 20 C

**URL:** <https://discourse.nodered.org/t/how-to-turn-on-rgb-led-based-on-temp-from-bme-below-20-c/74916>\
**Category:** General\
**Tags:** function-node\
**Created:** [8 February 2023 23:19 UTC](https://discourse.nodered.org/t/how-to-turn-on-rgb-led-based-on-temp-from-bme-below-20-c/74916 "2023-02-08T23:19:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kstenek](https://avatars.discourse-cdn.com/v4/letter/k/dbc845/32.png) [@kstenek](https://discourse.nodered.org/u/kstenek)\
**Post date:** [8 February 2023 23:19 UTC](https://discourse.nodered.org/t/how-to-turn-on-rgb-led-based-on-temp-from-bme-below-20-c/74916/1 "2023-02-08T23:19:34Z")

</div>

I am a teacher and pretty new to NR. I was given a curriculum that has a challenge that I am not sure how to complete. We want our RGB LED to turn on when the temperature reading from a BME280 is below a certain point. We had used a msg payload to display the temperature but I am unsure what flow we would use to get the temperature to turn the RGB on or off depending on the temp. Basically we want a warming light if the temp is too cold. Any help would be greatly appreciated especially with pics of flow and code if needed.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [9 February 2023 00:48 UTC](https://discourse.nodered.org/t/how-to-turn-on-rgb-led-based-on-temp-from-bme-below-20-c/74916/2 "2023-02-09T00:48:14Z")

</div>

Hello @kstenek, welcome to Node-red.

Are you using a Raspberry Pi, or some other computer?

What sort of RGB LED do you have - is it just an LED with 4 wires, or a little board that includes resistors?

> [@kstenek](#):
>
> We had used a msg payload to display the temperature

So you already have a way to get the temperature reading into Node-red.

Now you need to test if it's below your certain temperature, using a Switch node and a couple of Change nodes to chage the payload value to 0 (for off) or 1 (for on).  
Finally a GPIO-out node actually controls the GPIO pin.

Something like this

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/c/4c7a2b5953c37f235ba84754adf4d387d6ea70e4.jpeg)

There is a [YouTube video](https://www.youtube.com/watch?v=P0tqWYL7eSo) showing how you can wire up and control the LED. He uses an RGB led on a small board, which is easier to manage than a bare wires LED.

A regular contributor here, @dynamicdave, has a lot of projects with his local school computer club. I know he has one to control LEDs according to a temperature measurement, maybe he can point you to it.

---

<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:** [9 February 2023 01:35 UTC](https://discourse.nodered.org/t/how-to-turn-on-rgb-led-based-on-temp-from-bme-below-20-c/74916/3 "2023-02-09T01:35:35Z")

</div>

Here is a copy of @dynamicdave project that @jbudd was referencing  
[control\_leds\_using\_temp\_value.pdf](https://discourse.nodered.org/uploads/short-url/pIX5KUIEn9AoVQhI7ZPXqPsvIJ0.pdf) (297.9 KB)

---

<div class="post-metadata">

**Author:** ![kstenek](https://avatars.discourse-cdn.com/v4/letter/k/dbc845/32.png) [@kstenek](https://discourse.nodered.org/u/kstenek)\
**Post date:** [9 February 2023 20:49 UTC](https://discourse.nodered.org/t/how-to-turn-on-rgb-led-based-on-temp-from-bme-below-20-c/74916/4 "2023-02-09T20:49:35Z")

</div>

We are using a RPi 4. And we know how to wire both sensors with what we have, just were unsure which nodes to use. Information i had read said you cannot send 1 and 0's with msg payload.

---

<div class="post-metadata">

**Author:** ![kstenek](https://avatars.discourse-cdn.com/v4/letter/k/dbc845/32.png) [@kstenek](https://discourse.nodered.org/u/kstenek)\
**Post date:** [9 February 2023 20:54 UTC](https://discourse.nodered.org/t/how-to-turn-on-rgb-led-based-on-temp-from-bme-below-20-c/74916/5 "2023-02-09T20:54:32Z")

</div>

Thank you so much. using the switch and change nodes makes perfect sense now.

---

<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:** [10 April 2023 20:54 UTC](https://discourse.nodered.org/t/how-to-turn-on-rgb-led-based-on-temp-from-bme-below-20-c/74916/6 "2023-04-10T20:54:35Z")

</div>

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