I've built a very simple project that outputs MIDI CC via a 5 Pin DIN based on a Waveshare ESP32S3. There's another ESP32C3 which has four buttons attached and which sends data to this board via ESP-NOW.
It works perfectly once powered on - no issues. However, when it first powers on it sends a bunch of what MIDI-OX shows as random MIDI messages. For this reason, I power it on before connecting to my TC Electronic Plethora X3 (multi-effect pedal.) This garbage happens without the other ESP32C3 device turned on so it's definitely originating just from this device.
What am I doing wrong to get this "MIDI garbage" (as I've heard it called) on power-up? Is this normal behaviour that could be remedied by using a relay to only connect the MIDI data line after a delay or should I somehow be clearing the serial buffer?
Espressif chips print some information to the UART when they first start up. You'll have to use a different UART, or map Serial to a different GPIO pin in your setup.
Right, joy of joys, it turns out that the pins are mislabelled on this board. The following code (simplified here just to show it works) works fine with the MIDI data wire physically connected to pin 2 whilst being defined as pin 4 in the code.
#include <MIDI.h>
// Define UART1 pins based on your ESP32-S3 Mini pinout
#define UART1_TX_PIN 4
#define UART1_RX_PIN 2
// Create a MIDI instance for UART1
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
void setup() {
Serial1.begin(31250, SERIAL_8N1, UART1_TX_PIN, UART1_RX_PIN);
MIDI.begin();
}
void loop() {
MIDI.sendControlChange(93, 127, 1);
delay(1000);
}