Midi.h library, Reassigning Midi in out pin on ESP32

Hello everyone,

I've spent quite sometime studying the codes of Pedalino Mini project on Github, trying to learn(steal) some features from it but it just didn't work as I wished. I would like to connect D18 and D19 to a Pro Micro which acts as USB Host and D4 and D15 to DIN-5 ports for physical Midi IN OUT (Yeah, just like the schematics of Pedalino Mini), but I get nothing at all on those pins :frowning:

#include <Arduino.h>
#include <MIDI.h>
#include <esp_now.h>

struct Serial1MIDISettings : public midi::DefaultSettings
{
  static const long BaudRate = 31250;
  static const int8_t RxPin  = 18;
  static const int8_t TxPin  = 19;
};

struct Serial2MIDISettings : public midi::DefaultSettings
{
  static const long BaudRate = 31250;
  static const int8_t RxPin  = 15;
  static const int8_t TxPin  = 4;
};

MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial1, USB_MIDI, Serial1MIDISettings);
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial2, DIN_MIDI, Serial2MIDISettings);

void setup() {
  USB_MIDI.begin(MIDI_CHANNEL_OMNI);
  DIN_MIDI.begin(MIDI_CHANNEL_OMNI);
}

void loop() {
//  DIN_MIDI.read();
  DIN_MIDI.sendNoteOn(60, 127, 1);
  delay(100);
  DIN_MIDI.sendNoteOff(60, 0, 1);
  delay(100);
  USB_MIDI.sendNoteOn(60, 127, 1);
  delay(100);
  USB_MIDI.sendNoteOff(60, 0, 1);
  delay(100);
}

I have also tried using:

MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, MIDI);

with the ESP32 which does give me Midi In on Pin16 but no output at all on Pin 17. I have tested the Midi In out circuit, as well as all cables with Arduino Nano and they are fine. Anyone knows how to make it work? Thank you so much

Solved! Didn't realize ESP32 is 3.3V, had to change the resistors of the midi circuit :smiley:

please give more informations about resistor changing !
i'm able to send midi message but it seems impossible to receive, using a d1-mini or esp32 with esp32softwareserial.
i tried a lot of optoisolator configuration but esp32 seems to be deaf.
using mega2560 all works fine
so i think the problem is in the resistor configuration, like for your circuit.
your help is appreciated
many thanks

1 Like

athlonwai:
Solved! Didn't realize ESP32 is 3.3V, had to change the resistors of the midi circuit :smiley:

@athlonwai would you be able to describe exactly what you changed and why you changed it? TY!