Tips for using a Pi to read and write to I/O
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 modules, 0 is On and 1 is Off.
When you read and write to I/O modules, 0 is On and 1 is Off.
You can both read and write to output modules.
For input modules, you perform reads.
If you accidentally write to an input module, no problem—nothing will happen.
For input modules, you perform reads.
If you accidentally write to an input module, no problem—nothing will happen.
Before using a terminal emulator to read and write to an I/O module, you must configure its associated GPIO pin as an input or output.
The Opto 22 Pin-to-Module diagram can help.
If the GPIO pin is mapped to an input module, make sure to configure it as input; if it’s mapped to an output module, make sure to configure it as output.
If the GPIO pin is mapped to an input module, make sure to configure it as input; if it’s mapped to an output module, make sure to configure it as output.
Once you configure the GPIO pin, you don’t need to change it (unless you swap out the Pi or connect the same carrier board to a rack with different I/O).
You can use any Pi operating system and programming language to read and write to I/O points.
Examples
- Read and Write from a Terminal—Screenshots show LXTerminal
- The Pi Filesystem—Uses the sys/class/gpio library
- RPi-GPIO Library—Examples using the RPi.GPIO (Python) library
- Configure-Read-Write Script—A sweet Python script created by Opto 22 engineers to configure, read, and write to I/O modules
- Read and Write with Node-RED—This example can be used with or without the Digital I/O Carrier Board for Raspberry Pi
For more samples and tips, visit:
For a mapping diagram and overlay for your Pi, see Pin-to-Module Mapping.