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

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.

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?

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

There is a YouTube video 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.

1 Like

Here is a copy of @dynamicdave project that @jbudd was referencing
control_leds_using_temp_value.pdf (297.9 KB)

1 Like

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.

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

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