OLIMEX MOD-IO2 User Manual page 11

Extension board
Table of Contents

Advertisement

OLIMEX© 2024
Some examples for setting/reading MOD-IO2's peripherals in Linux using i2c-tools:
- Turning on the relays:
i2cset –y 2 0x21 0x40 0x03
,where
i2cset – command for sending data;
-y
– to skip the y/n confirmation prompt;
2
– board's hardware I2C number (typically 0 or 1 or 2);
0×21 – board address (0×21 should be used for writing);
0×40 – Turn on or off relay operation (as seen in the firmware README.pdf);
0×03 – should be interpreted as binary 011 – turns on both relays (0×02 would turn only second relay,
0×01 only the first, 0×00 would turn both off – 0×03 again would turn them off also);
Expected result: a specific sound would occur and relay LED would turn on.
- Reading the status of the relays (available since MOD-IO2's firmware revision 3.02):
i2cset –y 2 0x21 0x43
and then the read command
i2cget –y 2 0x21
,where
i2cset – command for sending data;
-y
– to skip the y/n confirmation prompt;
2
– I2C number (usually 0, 1, or 2);
0x21 – board address (0x21 should be used for writing);
0x43 – read relay operations (as seen in the firmware README.pdf;
Expected results: 0x00 – meaning both relays are off; 0x03 – should be interpreted as binary 011, e.g.
both relays are on; etc.
- Reading ADC:
i2cset –y 2 0x21 0x10
and then the read command
i2cget –y 2 0x21
,where
0x10 – the first analog IO (AN0 at GPIO0), the second is 0x15 and the third 0x16;
The big thing here is that to read you actually have to write ("that you would read"). Read is a
combination of i2cset and i2cget!
Page 11 of 28
MOD-IO2 user's manual

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the MOD-IO2 and is the answer not in the manual?

Table of Contents