SCHEMATICS
If you follow these schematics, you could technically make your own MIDI Goblin from scratch! But if you want to save yourself a headache, you can always pre-order a MIDI Goblin instead. This page is intended to give you more information on the MIDI Goblin’s hardware and make things easier for those of you who are intending on modding your goblin or even using the Goblin as a starting point for your own project. MIDI Goblin is a dead simple device (physically) and if you exclude the encloser and buttons, it’s really made up of only a handful of affordable, widely available parts.
A DOIT ESP32 DEVKIT V1 (ch340)
A 1.35” SPI oled screen
A 16 channel multiplexer
15 momentary push buttons
A 360 degree encoder (with built in push button)
Two 5-Pin MIDI DIN connectors
micro sd card reader
The DOIT ESP32 DEVKIT V1 is connected to the MIDI Goblin’s PCB using two rows of 15 pin headers (1 for each pin of the ESP32) and is removable. The other components are soldered directly to the MIDI Goblin’s PCB. The specific model of the esp32 was chosen because its affordable, powerful and allows for easy flashing (I found that ch340 versions of this ESP32 flash a bit quicker than the CP2102)
In the above image, you can see how each pin of the ESP32 is connected to each component. Each pin was chosen to connect to their respective component’s pins for a variety of reasons: the capability of each pin, weather or not the pin had internal resistors on the eps32 itself, spi lanes (hspi for sd card, vspi for the oled), leaving some pins available for future projects and avoiding strapping pins (connecting components to strapping pins could cause the esp32 not to start up, or require the esp32 to be removed from the enclosure in order to be flashed…yuck)
If you are used to looking at arduino pinouts, esp32 pinouts can seem a bit confusing due to the way that the pins are numbered. This version of the pinout was taken from circuit state but I rotated and flipped it horizonally to make it easier to read. The way you see it in this image, is the way you will see it if you open up your MIDI Goblin and look…at it. This pinout shows you all the pins and all the whacky things each one is capable of.
In the above image, you can see how the multiplexer(CD74HC4067) is connected to the esp32’s pins and the MIDI Goblins buttons.
The 15 buttons and encoder’s built in button are connected to the esp32 through this 16 channel multiplexer(mux). The mux allows you to connect many devices to the esp32 while only occupying a few pins on the esp32 itself. It’s quite handy. I chose to add a decoupling capacitor near the MUX’s VCC pin (although this was probably not necessary, having a decoupling capacitor near the IC is intended to prevent noise). The mux is connected to the esp32 as such…
mux sig to esp32 pin D34
mux s0 to esp32 pin D27
mux s1 to esp32 pin D14
mux s2 to esp32 pin D13
mux s3 to esp32 pin D12
In this image you can see how each of the buttons (and encoder button) are connected to each pin on the mux. It’s worth noting that I chose to use pull-down resistors rather than pull-up resistors. Although pull-up resistors for buttons can be a bit more reliable for reading, I find the logic of pull-down easier to understand. I experimented both up and down wiring options for the buttons and didn’t find any difference at all in terms of noise or false readings. If this was a more complicated project I may have gone with pull-up resistors.
You can also see how the encoder A and B pins (top right circuit) are connected to the ESP32’s VN and VP pins (with pull-down resistors). More often than not, people will wire the bottom middle pin of an encoder to ground but since I was using pull down resistors for all the other buttons this opposite approach made the most sense. VP and VN were also un-used and can be used as digital read pins so it worked out perfectly.
This is how to wire up the SPI oled screen to the esp32. Worth noting that the esp32 has two spi lanes (VSPI and HSPI) the oled screen and sd card reader are wired up to pins that relate to these two lanes. (SD card to HSPI pins and OLED to VSPI pins)
Here is how the SD card is wired to the esp32…ignore the words “top view”
And lastly, here we have the midi input and output circuits. I tried to make this readable (sorry…its still ugly)
The input circuit is quite a bit more complicated than the output circuit. This is because the input is basically being run through a 6N138 optocoupler and some resistors. This input diagram is pretty much exactly what you would find in a MIDI textbook but there is one minor change - a small decoupling capacitor next to the optocouplers pin 6. The purpose of this is to reduce noise (may or may not have been necessary)
If you ignore all the extra components, basically the input connects to the esp32’s pin D35 and the output connects to the esp32s RX2 pin. It might sound like a strange choice - but it works.
note: I had originally used rx0 and tx0 for the input and output (like any sane person) but it turns out those are strapping pins which could interfere with flashing.