MIDI not working with ESP32 S3 with Serial2

Hi I'm using both an ESP32 WROOM 32 and a ESP32-S3-DevKitC-1 for some MIDI projects with Arduino.
The code I'm using is the one below and for both board I'm using the following wiring to the 5 din connector and using resistors for 3,3volt.
https://eu-central-1-02860049-view.menlosecurity.com/c/0/i/aHR0cHM6Ly93d3cubWlkaS5vcmcvaW1hZ2VzL3NwZWNzL1NjcmVlbl9TaG90XzIwMjAtMDctMThfYXRfMTIuMjAuMDhfUE0ucG5n

By using pin 17 as Tx I get the code working on the WROOM board only, I can upload the code with no errors on the S3 board as well but no MIDI message are sent from pin 17.
Is there anyone using the S3 for MIDI over Serial2 that can help me on `this?
Thanks!


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

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

MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial2, DIN_MIDI, Serial2MIDISettings);

void setup() {
Serial.begin(9600);
DIN_MIDI.begin(MIDI_CHANNEL_OMNI);
delay(300);
DIN_MIDI.setHandleProgramChange(handleProgramChange);
}

void loop() {
DIN_MIDI.sendProgramChange(42, 10);
delay(100);
}

I'm sure that using HardwareSerial is wrong. What does the instance creation require at that position? Perhaps a properly initialized serial port instead of the entire ESP32's uninitialized serial class?

Thanks for your quick reply, Unfortunately I’m not an expert un programmation, can you please help me a little bit more? How would you change the code? Thanks for your help!

Did you try using the Midi example? Did you get the example working? I don't use Midi but I can see that the basic use of the constructor is MIDI_CREATE_DEFAULT_INSTANCE(); from arduino_midi_library/Basic_IO.ino at master · FortySevenEffects/arduino_midi_library · GitHub

From looking at arduino_midi_library/MIDI.h at master · FortySevenEffects/arduino_midi_library · GitHub one can see the various constructor options.

Anyways that's the extent of my knowledge with all thing Midi. Good luck.

Where did you get this example? I don't think TxPin is a valid setting: https://github.com/FortySevenEffects/arduino_midi_library/search?q=TxPin
You'll have to set the right pin yourself in the setup() function.

PieterP,
I tried to simplify the code, see below, but again it works perfectly on the WROOM board and there's no message coming from the S3, :sweat:

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

MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, midi2)

void setup() {
  Serial.begin(31250);
  midi2.begin(MIDI_CHANNEL_OMNI);
}

void loop() {
  midi2.sendProgramChange(42, 10);
  delay(100);
  Serial.println("LOOP");
}

Using Serial 1 pins the code works on S3 board as well, I checked if the pin of the dev kit board are connected to the esp3 s3 module pins and I confirm they are so I think there’s some bug in Serial2

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.