Node-Red Inject and Debug


Introduction to Node-Red Inject and Debug

Node-Red Inject and Debug are two nodes that I use most often for testing and debugging a flow. On one hand, the Inject node allows you to send a message to another node. On the other hand, debug will show the payload coming out of a node. For example: You might inject a message into an Alexa routine to ensure it is operating as expected. Comparatively, the debug node will show the output of a node, such as a function.

In this example, we’ll inject a Celsius value into a function. Likewise, we’ll use a debug node to verify the code is working properly.

Inject Node

Here, we’ll add an inject mode into our flow. Then, double click the inject mode to populate the required fields. In this case, we’ll simply inject a number. We need to choose the type of data as “number” from our drop down list.

By the same token, we’ll fill out the other fields. I’ll just inject the numeric value of 100 into a function. Here is our final result for the inject node.

Function Node

The function node allows us to manipulate and store data. I’ll add a function node to the flow. At this time, we’ll enter the formula to convert the Celsius value to Fahrenheit.

Debug Node

Finally, we’ll add the debug mode to our flow. There is not much configuration to the debug mode. I’ll simply add the node, and configure the options as follows:

I’ll check all of the check boxes in the configuration. This will show the data in the debug window (on the right). Additionally, the debug node will send messages to a runtime log. By turning on the node status, we will be able to see the data received below the debug node in our flow. Keep in mind, there is a button on the right side of the node. This allows you to enable or disable the debug node.

Summary for Node-Red Inject and Debug

Let’s tie our flow together, and deploy the project. The deploy button is in the upper right corner of the Node-Red interface.

When you click the button on the left side of the Inject node, the value of 100 will be sent to the Function node. After that, the function node converts the value of 100 to 212. It then sends the result to the debug node.

For more information, visit the Node-Red Category Page!

— Ricky Bryce

Leave a comment

Your email address will not be published. Required fields are marked *