Mega 2560 serial communication problem

problem looks like:
software serial rx on pin 2 , receiving data from another arduino (eq: “2 24 18 24 16”), it perfectly works on arduino UNO (tested on 2 different boards from robotdyn and but on arduino mega this is not working (also tested on 2 boards), only zeros are received. Does anybody know why?

#include <SoftwareSerial.h>
#include <Thread.h>
SoftwareSerial mySerial(19, 20); // RX(TX of the module should be connected), TX(not used)
Thread EXTboard = Thread();
int input_pin = 5;
int output_pin = 6;
int someData [5];
int sombodysId, sombodysOldId, tempIn, humIn, tempOut, humOut;
bool shouldbeignored = false;
unsigned long long mytime;
void setup() {
  pinMode(output_pin, OUTPUT); digitalWrite(output_pin, HIGH);

void loop() {
  if (EXTboard.shouldRun());
  if (digitalRead(input_pin))shouldbeignored = false; getSomeInfo(); shouldbeignored = true;

void getSomeInfo() {
  if (shouldbeignored) {
    shouldbeignored = false;
  } else {
    mytime = millis();
    digitalWrite(output_pin, LOW);
    if (mySerial.available()) {
      someData[0] = mySerial.parseInt(); someData[1] = mySerial.parseInt();
      someData[2] = mySerial.parseInt(); someData[3] = mySerial.parseInt();
      someData[4] = mySerial.parseInt();
    sombodysId = someData[0], tempIn = someData[1], humIn = someData[2], tempOut = someData[3], humOut = someData[4];
    shouldbeignored = false;
    digitalWrite(output_pin, HIGH);
    Serial.print(' ');
    Serial.print(' ');
    Serial.print(' ');
    Serial.print(' ');

There is no need to use SoftwareSerial on a Mega as it has 3 spare Hardware Serial ports. Use pin 18 and 19 as Serial1

...R Serial Input Basics - simple reliable ways to receive data.

already tried Serial1 , 2 and 3, no result

Thank you :) , dont know why but this time serial1 working, but on 2nd mega board is not :/ thank you anyway

Robin2’s advice to use hardware serial is the best but just in case you’re curious why software serial didn’t work, here’s the explanation from the SoftwareSerial library’s documentation:

Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).

denspie: already tried Serial1 , 2 and 3, no result

Can we see this program?

You are using the hardware serial pin and applying SoftwareSerial to it? Seems like the long hard way to do this. Not to mention you will run into problems with SoftwareSerial at some point, beyond the fact you have already not used an applicable pin on the MEGA.