OLIMEX© 2020
MOD-IO user's manual
2.8 Arduino with MOD-IO
We provide a ready-to-use library for Arduino IDE with an example code for turns on and off all relays of
MOD-IO. The code also allows the reading and printing of all digital inputs and all analog inputs over the
serial monitor. In order to set it up first download the archive from the link below:
https://www.olimex.com/Products/Modules/IO/MOD-IO/resources/MOD-IO-ARDUINO.zip
1. Extract the archive, copy and paste the folder "MOD-IO" into the "libaries" folder of your Arduino
IDE.
2. Start Arduino IDE
3. To load the example, navigate to File → Examples → MOD-IO → RELAYS-INPUTS
4. Remember to select your board and the COM port it uses for communication.
5. The demo uses serial communication, it is recommended to use the serial monitor in Arduino IDE (it
can be started from Tools → Serial Monitor).
The example was tested with OLIMEXINO-328 and MOD-IO with I2C address 0x58.
Refer to the comments inside the example for more information
2.9 OLinuXino boards with MOD-IO
You can connect MOD-IO to all OLINUXINO boards that have UEXT connector. Connect the two
boards using UEXT cable. After that boot the default Debian and use the program called “i2c-tools”. If it
is missing enter the following commands in the console of your OLINUXINO board to obtain it:
# apt-get update
# apt-get install i2c-tools
To set all relays use:
# i2cset -y -f 2 0x58 0x10 0x0F
,where:
i2cset – the part of i2c-tools that is used to for sending data over the i2c;
-y
– skips confirmation;
-f 2
– specifies the number of the I2C bus used; test with values “1” or “2”;
0x58 – the I2C address of the board that we want to send data to;
0x10 – the command to set relays (different commands have different code, refer to chapter 2.6 of
this manual);
0x0F – the state of relays is stored in the 4 least significant bits of the binary representation of
0x0F → 0b00001111 → affecting all 4 relays (other example → 0x05 → 0b00000101 →
affects relays 1 and 3).
To turn off all relays use:
# i2cset -y -f 2 0x58 0x10 0x0F
Page 14 of 30