Arduino I2C MIDI Interface

This is one of those “I wonder if…” projects.  There is little reason for anyone to really do this, but I have a board that only has I2C for IO and naturally I got wondering if it was possible to do MIDI over the I2C interface. This is starting simply, trying it with a standard Arduino Uno.

  • In this post, I’m looking at the rather interesting IIC to dual UART module from DFRobot.
  • In part 2, I’ve developed a generic “raw” I2C MIDI transport.
  • In part 3, I’ve shown how to use that as a Serial MIDI to I2C MIDI relay.
  • In part 4, I show one I2C MIDI controller sending data to two I2C MIDI peripherals.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

These are the key tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

Parts list

The Circuit

ArduinoIICserialMIDI_bb

The DFRobot module provides two serial ports (UART 1 and UART 2) accessible over I2C (IIC) via one of the DFRobot “Gravity” connectors.  These connectors are largely compatible (but not always – see this comparison) with other I2C connector systems such as Adafruit’s Stemma and QT system, and Sparkfun’s Qwiic.

IMG_5656

I’m using a 4-pin JST PH connector (at the “gravity” end) to four header jumpers at the Arduino end, and then jumper headers to connect the two UART ports to two Ready-Made MIDI Modules.

The Code

I’ve created a “IIC serial MIDI transport” for the Arduino MIDI Library, which is pretty much a copy of the built-in “hardware serial” transport with some tweaks to use the DFRobot IIC Serial Library.

I’ve included an example that creates two instances of the iicSerial MIDI transport, one for each UART, and routes anything received on UART 1 to UART 2, and anything received on UART 2 to UART 1.

In the video, I’ve attached my Hobbytronics USB MIDI module to UART 2 and my Datapoint 5-pin DIN serial MIDI module to UART 1, which it connected through to my MT-32.

So I’m using a USB MIDI Controller to play my MT-32 via the Arduino, over I2C!  No, I’m not sure why I’d want to do this either, but it does seem to work 🙂

Find it on GitHub here.

Closing Thoughts

Off the top of my head, I’m struggling to think why you’d want to do this with an Arduino, but it is interesting that it seems to work.

In principle, you can connect four of the Gravity IIC dual UART modules to the I2C bus, as there are four I2C address possibilities.  That would give access to eight MIDI ports plus the Arduino’s built-in serial port (and any software serial you might want to try too), but I’m really not sure the processing power would really be up to it.  At the very least it would need some MIDI event filtering I think – either by channel or message type.  At this point, I think you’re much better off with something like a Teensy or even a Pico.

But I was interested in this as I was wondering if it was possible to have a Stemma/QT compatible MIDI module, and so far, the answer seems to be “yes”.

As an aside, it has also now got me wondering what it would take to do MIDI directly over I2C…

Kevin

IMG_5655

Leave a comment