Mqtt with adafruit io

hi all,
i embed dashboard with mqtt node bu i don't know how to use payload data to switch led

Hi @mani2411

you'll need to describe lots more about what you have working and what you have tried. You are leaving us to guess a lot about what you are doing. Are you running this on a Raspberry Pi or similar device? How have you got the LED connected?

Do you know how to control the LED at all? Once you know that, it will be a question of passing a message in the right format to the right node.

You can use the Debug node to see what messages you are getting from the MQTT node.

yes i am using raspberry pi and blinked a led with inject node here is the image of configuration and debug node

i am passing these messages from a web server

hi please help me i really need to do this

Am I understanding correctly, you have a message with payload "ON" or "OFF" and you want to use that to turn an LED on/off? Also you are able to drive the led with an inject node successfully?
If so then the question you are asking is 'how do I convert a payload containing ON or OFF to one containing the inject values?'.
So the first question is what values are you injecting to turn the LED on/off?

YES this is the thing i want to do

You didn't answer the question, what values do you need to turn the led on/off?

oh sorry
1 and 0 in numbers


so when you get an 'OFF' payload from the MQTT node, you need to send a 0 to the GPIO node. And when you get an 'ON' payload from the MQTT node, you need to a 1 to the GPIO node.

You could use a Function node with a little bit of JavaScript to check the value of the payload and set it to the required value before passing it on.

i am a newbee to this and don't know about js so i tried if loop to do so but not working but its giving error kindly assist me with function node code

Again, if you shared more details on what you have tried, we can help you better.

A Function node along the lines of the following would do it.

if (msg.payload === "ON") {
   msg.payload = 1;
} else if (msg.payload === "OFF") {
   msg.payload = 0;
} else {
   // Don't recognise ON or OFF, so return nothing
// Return the updated message
return msg;

it worked thanks alot for help

Hello, I'm really interested in your project. I would like to get your configuration node, so I can import it into mine...