1

UPDATE : I still can't receive MIDI as of 2019/07/01.

Here goes so far : I'm trying to follow this schematics from instructables, using 6N138. To make it easier, I'm going to copy his schematics. enter image description here

===================================

I'm using Arduino Mega. I tried to find specific topic about this and can't find any.

The target is actually send and receive MIDI, then replace the whole Arduino Mega to ESP8266 (probably the ESP-01, or Wemos D1), but I'm afraid it is too specific.

Here's the code so far on PasteBin

Here's my work so far. enter image description here 6N138

The diodes were replaced with LED, because I don't have one Original guide here. But that schematics on that thread also didn't work for some reason.

  • What is the Mega supposed to do? The ESP8266 can easily handle all of that on its own. – tttapa Sep 21 '18 at 11:35
  • @tttapa I'm using the esp8266 only as the wifi module, mega for the rest – Rinaldo Jonathan Sep 24 '18 at 7:13
  • Define "the rest"? – tttapa Sep 24 '18 at 7:14
  • @tttapa mega would receive the power, receive midi connection, send midi back, and doing everything esp8266 is only for wifi shield replacement. – Rinaldo Jonathan Sep 24 '18 at 7:23
  • The ESP8266 can easily handle MIDI connections, as well as receiving power. Using an extra microcontroller is just making everything more difficult, and is a waste of time and resources, in my eyes. – tttapa Sep 24 '18 at 7:24
2

Most start at the midi site at playground.arduino.cc. But there are numerous web sites across the Internet. It is important to understand that the MIDI interface uses a current loop to send and receive data. While the Arduino normally uses voltage levels to communicate. As such, an electronic interface needs to be built or bought to convert between these two types of signals. Some interface designs are simple and limited. Others are complex and robust.

  • Thats a lot of read. I'll try to read them one by one. Thanks! – Rinaldo Jonathan Sep 21 '18 at 14:11
  • Use wikipedia as a reference (don't read it all, just what you need). The playground.arduino.cc site is likely your best source. The simple design isn't that simple and the complex not all that complex. I was looking more for examples of simple (direct connections) and better (optically isolated) ways to convert voltage levels to current loops. – st2000 Sep 22 '18 at 13:11
  • @RinaldoJonathan, your question has changed a lot. On some bread boards the power doesn't connect from one end to the other. In such a case you need to jumper the power bus together where they don't connect. Or move the power wires to the side where you are powering your chip. – st2000 Jul 1 '19 at 11:35
  • the other power line isn't used at all. – Rinaldo Jonathan Jul 1 '19 at 11:40
  • @RinaldoJonathan, that is not what I meant. On some bread boards like yours, there are 4 power bus lines. Two on each side. Broken in the middle. I see your bread board has uninterrupted blue and red lines. So I think your bread board only has 2 power bus lines. But it would not hurt to move where you supply power to the end of the board closest to where you use power just to check. Take a look at how the lines are painted on this bread board. – st2000 Jul 2 '19 at 12:21
2

There are plenty of MIDI circuits and most of them are quite simple, mostly an optocoupler (6N137 or 6N138, although I had better luck with H11L1), some resistors and that's mostly it. I also added ferrite beads for EMI protection, but this is not absolutely necessary.

To test your circuit, use a lot of data (e.g. by pitchbend/aftertouch), and play notes meanwhile. If you hear stuck notes (meaning the MIDI Note Off command is missed), you know the circuit is not full proof.

Regarding libraries: the FortySeven Effects library is really easy to use. I used it in the beginning before I moved on to STM32 and having to write my own, but this is a good starting point.

For the schematics I based my circuit of can be found at H11L1 optocoupler.

The best way is to read the official MIDI documentation, see page MIDI 1.0 Specification, than search for

Download the Complete MIDI 1.0 Detailed Specification Document (1996) 
(Please Register! It's Free!).
  • Do you have some example schematics? That would help alot. Thanks! – Rinaldo Jonathan Sep 21 '18 at 14:10
  • 1
    Note that there has been an addendum in 2014: Electrical Specification Update (CA-033) It adds a specification for 3.3V systems. – tttapa Sep 21 '18 at 14:23
  • 1
    @tttapa Thanks for that remark (didn't know about that addendum) – Michel Keijzers Sep 21 '18 at 15:20
  • just realized nobody sells 6N137/6N138, H11L1, or everything else I found at arduino.cc that can be used as alternative. – Rinaldo Jonathan Sep 24 '18 at 7:24
  • @RinaldoJonathan I buy them from AliExpress, no problems at all. – Michel Keijzers Sep 24 '18 at 8:47
1

How to connect 6N138 to Arduino :

enter image description here Schematics : enter image description here

Basically the above schematics and installation is already okay, but instead of 1k, I used 10k on 6N138 PIN 7 to GND. VCC to 470 ohm is on PIN 6, also RX out, connected in series.


Just in case you want to use 6N137 :

enter image description here

Schematics : enter image description here

  • Pin 5 of the MIDI DIN connector goes to pin 2 of the 6N137
  • Pin 4 of the MIDI DIN connector goes via 330 ohm resistor to pin 3 of the 6N137 (so the 6N137 pins and the resistor are connected in series)
  • You should also have a reverse connection protection diode between pins 2 and 3 of the 6N137 but I like living dangerously and rely on the diode inside the 6N137
  • Pin 8 and 7 are connected to VCC
  • Pin 6 is connected to RX
  • Pin 5 is connected to GND
  • 4.7 kohm pullup resistor between pin 8 and 6 (VCC and signal out)

Adapted from this blog post.


How to test it :

  1. I used Arduino Mega with this code.
  2. I then attached the Arduino Mega to Hairless MIDI, then to loopMIDI.
  3. Then I read the MIDI output using MIDIOX.


I might update it with H11L1 / PC900 later, if I have some time. Also, I'm going to put this thread in Indonesian in my blog later.

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.