MyPi Integrator Board Combo I/O Card Setup

The MyPi I/O Card is comprised of three types of I/O all of which are isolated from the main card and so useable in an industrial environment.

These are :

4 x Double ended opto-isolated digital inputs, these can be driven from 5V upwards

4 x Digital outputs in the form of N/O Relay contacts rated for 24VDC/1A or 125VAC/0.5A

4 x Double ended ADC inputs, input scale of 0-2.048V, primarily for the reading of 4-20mA sensors via the on-board 100R 0.1% current shunts.


The ADC in use is the common MCP3424 device for which many example C and Python code samples exist, see link below to an example Git repository with demos and libraries for C and Python.I

To load and configure the kernel module run the following commands as root user, this installs the driver and then tells the system the MCP3424 ADC device is present on the I2C bus at address 0x6E

# modprobe mcp3422
# echo "mcp3424 0x6e" >/sys/bus/i2c/devices/i2c-1/new_device


We have created a setup file called  which configures the ADC kernel module, GPIO exports for input/output as well as and setting up several /dev shortcuts for all the I/O channels in one go. You can download this from the link at the bottom of this page.

root@raspberrypi:~# chmod +x ./
root@raspberrypi:~# ./
Usage: ./ [options]
           og = Original Integrator Board
           nt = Integrator Board NT (CM3+/CM4S)
           xt = Integrator Board XT (CM4)

root@raspberrypi:~# ./ xt
[info] Configuring MyPi IO Card.
[info] Creating MyPi I/O Card /dev shortcuts.

This will create the below shortcuts :

root@raspberrypi:~# ls /dev/dig*
/dev/diginput0  /dev/diginput1  /dev/diginput2  /dev/diginput3  /dev/digout0  /dev/digout1  /dev/digout2  /dev/digout3

root@raspberrypi:~# ls /dev/dig*ls -l /dev/i2cadc/*
ls: cannot access '/dev/dig*ls': No such file or directory
-r--r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/dev
-rw-r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/in_voltage0_raw
-rw-r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/in_voltage0_scale
-rw-r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/in_voltage1_raw
-rw-r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/in_voltage1_scale
-rw-r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/in_voltage2_raw
-rw-r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/in_voltage2_scale
-rw-r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/in_voltage3_raw
-rw-r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/in_voltage3_scale
-rw-r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/in_voltage_sampling_frequency
-r--r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/in_voltage_scale_available
-r--r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/name
-r--r--r-- 1 root root 4096 Jan  1 00:11  /dev/i2cadc/sampling_frequency_available
lrwxrwxrwx 1 root root    0 Jan  1 00:11  /dev/i2cadc/subsystem -> ../../../../../../../bus/iio
-rw-r--r-- 1 root root 4096 Jan  1 00:09  /dev/i2cadc/uevent


As an example a +1.8V supply has been attached to ADC Channel 0 to then read the ADC channel run the following commands :

$ cat /dev/i2cadc/in_voltage0_raw
$ cat /dev/i2cadc/in_voltage0_scale

So 1790 x 0.001000000 = 1.790V - which in comparison to a DVM reading of 1.793 is pretty good.


Changing the sample frequency affects the accuracy of the ADC reading taken, as taking fewer samples leads to a higher resolution conversion, which is especially important when working with low voltage or slowly varying signals. Changing the sample frequency will also alter the available scaling factors.

The first step is checking the available sample frequencies and then echo the chosen one into the input sample frequency controller

# cat /dev/i2cadc/sampling_frequency_available
240 60 15 3
# cat /dev/i2cadc/in_voltage_sampling_frequency
# echo 15 >/dev/i2cadc/in_voltage_sampling_frequency
# cat /dev/i2cadc/in_voltage_sampling_frequency
# cat /dev/i2cadc/in_voltage0_raw
# cat /dev/i2cadc/in_voltage0_scale
# cat /dev/i2cadc/in_voltage_scale_available
0.000062500 0.000031250 0.000015625 0.000007812

So here the lower sample rate has given way to a more accurate reading, and using the same input voltage as before :

28635 x 0.000062500 = 1.7896875V


Likewise the input scaling multiplier can be altered in a similar fashion

# cat /dev/i2cadc/in_voltage_scale_available
0.001000000 0.000500000 0.000250000 0.000125000
# echo 0.000125000 >/dev/i2cadc/in_voltage0_scale
# cat /dev/i2cadc/in_voltage0_raw

If the scaling is set too high, the amplifier stage is before the converter stage within the device, then the voltage presented to the ADC stage for conversion will be greater than the 2.048V internal reference and as a result you'll just see the max value (FSD) of the ADC i.e. 2047 (2.047V)


Note that you do not need to be root user to read these values, but only the root user can alter the sample or scaling factors


To change a relay state :

$ echo 1 >/dev/digout0
$ echo 0 >/dev/digout0


To read a digital input state :


$ cat /dev/diginput0
$ cat /dev/diginput0


For convenience we have added a +5V_ISO and 0V_ISO to pins 9 & 10 of the digital input connector (roughly 10-20mA capacity) for driving the digital inputs and so can be used with volt-free contacts (e.g. pulse input) or for powering a led pulse detector sensor. Setup File


 MCP3424 C/Python Examples


 MCP3424 ADC Datasheet

Contact us now to discuss your project

Ready to order, contact us today for pricing or samples

Contact Us