If you don’t have the RPi-GPIO nodes, you can install them from a terminal emulator with this command: npm install rpi-gpio

In this flow:

The rpi-gpio in node reads the value (1 or 0) of pin 40. If the value changes, the msg.payload (debug) node writes a message to the Node-Red Editor’s debug tab.

For the rpi-gpio out node:

Every 2 seconds, the inject 1 (Off) node writes a “1”.

Every 3 seconds, the inject 0 (On) node writes a “0”.

Using this flow with digital I/O modules and Opto 22’s Digital I/O Carrier Board for Raspberry Pi®, the LED status indicator on the module at position 3 flashes off and on, because the two inject nodes are constantly changing its value.

You won’t notice any change to the LED on the module at position 0 because the rpi-gpio in node only reads the value. (It doesn’t write to the module.)

Steps

Important: Opto 22 I/O modules use negative true logic (a zero bit means On and a 1 bit means Off).
When you read and write to I/O points, 0 is On and 1 is Off.

If you’re using real I/O with this example, make sure on the rack there’s a digital input module (like the G4IDC5MA) in position 0, and a digital output module (like the G4ODC5) in position 3.