Skip to content

GPIO MIDI interface

Dale Whinham edited this page Feb 23, 2021 · 5 revisions

You can build a simple circuit based on an opto-isolator, a diode, and a few resistors. If mt32-pi does not detect any USB MIDI devices present on startup, it will expect to receive input on the UART RX pin (pin 10).

πŸ’‘ Tip: You can disable detection of USB MIDI interfaces by setting usb = off in the config file. This can shave off a couple of seconds of boot time as USB initialization is then skipped on startup.

Schematic

Breadboard example

6N138 opto-isolators: why not?

There are many schematics around the internet that suggest using a 6N138 opto-isolator in MIDI circuits for microcontrollers such as the Arduino [1].

Sadly, there are also many schematics that suggest connecting them to the Raspberry Pi in a dangerous fashion (i.e. that could cause permanent damage to your Raspberry Pi). Whilst they can be used with a Raspberry Pi with appropriate level shifting or connecting the RX pull-up resistor to 3.3V instead of 5V [2], we do not recommend using them for the following reasons:

  • They are designed to run from a 5V power source, but the connection to the Pi's RX pin must not exceed 3.3V otherwise damage can occur, so extra care is needed when hooking them up.
  • Some schematics suggest running them from 3.3V, which may work, and would avoid the need for level shifting, but is technically out-of-spec and not allowed by the datasheet of the 6N138.
  • The 6N138 has a slow switch-off time, which means it requires an extra pull-down resistor to ensure reliable data transmission.

The H11L1 is a superior component for this application as it can be be powered from a 3.3V power source and does not require the pull-down resistor, hence why we recommend using it instead [3].

Clone this wiki locally