Can't READ from additional serial ports but can send data through them on Mega

Hello people, i am working on a project and so far i was sending data to my arduino mega through the usb port so Serial0. Now, we'd like to use a usb to TTL converter to connect to it and since the RX0 and TX0 are taken over by the adafruit motor shield (which does not use them however :0) we'd have to use the other serial ports that mega provides....

And here start the problems.

First of all, if i just touch my rx and tx cable from the TTL on the header of 0 and 1 pins, it works as normal. So a desperate measure would be to solder those wires on the motor shield, but that's an ugly solution.

So, let's say i use RX1 and TX1 on ports 18 and 19 respectively.

I use the following code to initialize the Serial communication

Serial1.begin(9600);

this to send something through it

Serial1.println("blah blah");

and this to read from it:

Serial1.read();

I can receive FROM the arduino, but when i try to send something TO arduino, arduino does not read it (no serialEvent(), nothing).

The TTL cables and usb converter work as they should i must remind you, since i am reading and sending from "Serial" just by touching them to the pins 0 and 1.

Has anyone any idea what could be wrong??

Thanks in advance...

let’s take the official SerialEvent example from the Arduino IDE and change Serial to Serial1.

String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

void setup() {
  
  // initialize serial:
  Serial1.begin(9600);
  // reserve 200 bytes for the inputString:
  inputString.reserve(200);
}

void loop() {
    Serial1.println("Hej");
    delay(700);
  // print the string when a newline arrives:
  if (stringComplete) {
    Serial1.println(inputString); 
    // clear the string:
    inputString = "";
    stringComplete = false;
  }
}

/*
  SerialEvent occurs whenever a new data comes in the
 hardware serial RX.  This routine is run between each
 time loop() runs, so using delay inside loop can delay
 response.  Multiple bytes of data may be available.
 */
void serialEvent() {
  while (Serial1.available()) {
    // get the new byte:
    char inChar = (char)Serial1.read(); 
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    } 
  }
}

This, will keep printing “Hej” every 700 milliseconds, but will NOT print whatever i send it through the serial port… :///

Anyway never mind i solved it. I should be using serialEvent1() if i want to receive from Serial1 etc instead of serialEvent.... :sweat_smile: