Overview

In the previous exmples, we saw how read I/O values using the Read node and Input node.

Write to an Output Channel

Writing an I/O value is very similar to reading.

To write to a digital or analog output channel:

  1. Place a groov I/O Write node onto your flow.
  2. Connect an Inject node to the input port of the groov I/O Write node. You do not need to connect a Debug node to the output port.
  3. Double-click on the groov I/O Write node to open the “Edit groov i/o write node” view.
  4. For the Device field, confirm that a configured device is selected.
  5. For the Data Type field, select either Digital Output Channel State or Analog Channel Value.
  6. For the Module Index, enter the module location you’d like to use. The indexes are zero-based, so 0 is for the first slot on the chassis.
  7. For the Channel Index, enter the channel you’d like to use. The indexes are zero-based, so 0 is for the first channel on the module.
  8. For the Value field, select Value from the dropdown and enter a value to write to the output channel.
  9. Click Done.
  10. Click Deploy.
  11. Click the Inject node’s button. The value should be written to the output.
  12. Go to groov Manage and confirm that the value was written to the output channel.

Write a channel's value

Write to an Output Channel from an Incoming Message Object

The value to write can also come in a property on the msg object injected into the flow by the Inject node. Continuing from the previous section:

  1. Double-click on the Inject node.
  2. For the Payload field, select “number” or “boolean” from the dropdown list. If writing a number, enter a number you wish to write to your groov I/O. If writing a boolean, select True or False from the dropdown.
  3. Click Done.
  4. Double-click on the existing groov I/O Write node from above..
  5. Change the Value field from Value to msg.payload.
  6. Click Done.
  7. Click Deploy.
  8. Click the Inject node’s button.
  9. Go to groov View and confirm that the value was written to the tag.

This is just a preview of the power within Node-RED to build complex and dynamic solutions.

Conclusion

This concludes our Getting Started with Node-RED for groov I/O section.

There’s also a quick introduction to Node-RED on the official website, with tutorials for a first and second flow.

Please explore the other material available on the Opto 22 Developer site for additional information, including the section on Node-RED resources.