IO Expander Breakout uses a Nuvoton MS51 microcontroller and I2C to give you 14 additional input/output pins to connect things up to. Eight of the pins are hooked up to an Analog to Digital Converter and six of the pins can be used as (up to 16-bit) PWM outputs.
This library is also used to power our other Nuvoton-based boards and breakouts!
Stable library only (no examples) from PyPi:
python3 -m pip install pimoroni-ioexpander
In some cases you may need to install pip with: sudo apt install python3-pip
Stable library, with latest examples from GitHub:
git clone https://github.com/pimoroni/ioe-python
cd ioe-python
./install.sh
Latest/development library and examples from GitHub:
git clone https://github.com/pimoroni/ioe-python
cd ioe-python
./install.sh --unstable
In order to use the IO Expander, you need to enable the I2C interface of your Raspberry Pi. This can be done in the terminal by running:
sudo raspi-config nonint do_i2c 0
Alternatively, you can enable the I2C interface by:
sudo raspi-config
and enabling the option under Interfacing Options.You may need to reboot after enabling I2C for the change to take effect.
The first version of the Raspberry Pi uses SMBus 0 instead of 1. The ioe-python library uses SMBus 1 by default.
You can change the SMBus that is used by adding smbus_id=0
to your calls to io.IOE(...)
. If you want your code to run on multiple revisions of the Pi without having to change your code depending on the Raspberry Pi revision, you can make your code check the Revision
part of /proc/cpuinfo
and set the SMBus accordingly. Revisions 0002
and 0003
use SMBus 0. All others use SMBus 1.
There are various examples to get you started with your IO Expander. With the library installed on your Raspberry Pi, these can be found in the ~/Pimoroni/pimoroni-ioexpander/examples
directory.
To take IO Expander further, the full API is described in the library reference, with additional feature specific information found in the docs folder.
To uninstall the library only (keeping all examples):
python3 -m pip uninstall pimoroni-ioexpander
Or if you have grabbed the library from Github:
cd ioe-python
./uninstall.sh