2

I'm actually designing a electric guitar multi-effect.

To achieve this, I plan to use a raspberry pi (probably a Zero W) as a controller.

My problem is that I cannot connect all effects (home-made hardware) to the raspberry on a single I²C bus since there will quickly have address collision (e.g. rheostats only have 3 customizable bits for the I²C address).

I first took a look at I²C multiplexer and then home-made I²C multiplexer (cheaper as the component needed will be wildly used over the effect board). I keep those solutions as backup if I cannot do want I will explain in the lines below.

As I will use only few GPIO pins, I was wondering if I can create new I²C buses using the other GPIO pins and show them using i2cdetect command. This way, I can greatly reduce the hardware needs.

Thanks for reading me until there and for your replies/advices

2

You can use device tree to add additional I2C buses on spare GPIO.

See /boot/overlays/README for details.

You need 2 GPIO per bus, one for SDA and one for SCL.

Name:   i2c-gpio
Info:   Adds support for software i2c controller on gpio pins
Load:   dtoverlay=i2c-gpio,<param>=<val>
Params: i2c_gpio_sda            GPIO used for I2C data (default "23")

        i2c_gpio_scl            GPIO used for I2C clock (default "24")

        i2c_gpio_delay_us       Clock delay in microseconds
                                (default "2" = ~100kHz)

The configuration must be added to /boot/config.txt.

E.g. to use GPIO 5 for SDA and GPIO 6 for SCL make the following entry.

dtoverlay=i2c-gpio,i2c_gpio_sda=5,i2c_gpio_scl=6

Remember that each GPIO will need a pull-up to 3V3 for the bus to work. For reference the Pi uses 1k8 resistors.

Each additional bus will be identified by the next available number.

You will be able to use all the standard commands on the bus (i2cdetect, SMBus calls etc.).

  • I just test it with an RPI 3 and it works great. By the way, do you know where is the 2nd I2C bus? For my test, I used a 1k5 resistor as I haven't one of 1k8 – Cedric May 24 '17 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.