[SOLVED] Does Software Serial only works on Pins 10/11? (MEGA 2560)

I have a sketch of an arduino mega 2560 and Hm10, everything works with software serial on pin 10/11 but if i change the software serial pins, it won´t work, any ideas? i need to change the pins because i am using the sparkfun monster motoshield, and it blocks pins 10/11, also arduino mega has a lots of free pins.

Code:
#define BLYNK_PRINT Serial

    #include <BlynkSimpleSerialBLE.h>
    #include <SoftwareSerial.h>

    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "2d791e54c0404d8fb7d5407a25f268aa";

    SoftwareSerial SerialBLE(44, 45); // RX, TX

    BLYNK_WRITE(V1) {
      int x = param[0].asInt();
      int y = param[1].asInt();

      // Do something with x and y
      Serial.print("X = ");
      Serial.print(x);
      Serial.print("; Y = ");
      Serial.println(y);
    }

    WidgetLCD lcd(V0);

    void setup()
    {
      // Debug console
      Serial.begin(9600);

      SerialBLE.begin(9600);
      Blynk.begin(SerialBLE, auth);

      Serial.println("Waiting for connections...");
    }

    void loop()
    {
      Blynk.run();
    }

SOLVED, using hardware serial on RX1 TD1, found here Trouble connecting bluetooth to Mega with Android

Serial1.begin(9600);  // via BT Module
Blynk.begin(Serial1, auth);  // Connect to App via BT

Software Serial should work on many otherwise unused/compromised digital pin (see below)… However as you have noticed, on the Mega you actually have another three Hardware Serial pin/pairs (14-19) that are the preferential ports to use for extra serial communication.

https://www.arduino.cc/en/Tutorial/MultiSerialMega

https://www.arduino.cc/en/Main/arduinoBoardMega

EDIT - Relevant to the original question - there are some limitations for SoftSerial on differing Arduinos.

https://www.arduino.cc/en/Reference/softwareSerial

1 Like

yes, hardware serial works better than swsr, also here is the answer about why software serial only worked on pins 10/11 for me.

The library has the following known limitations:
If using multiple software serial ports, only one can receive data at a time.
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).
Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
On Arduino or Genuino 101 the current maximum RX speed is 57600bps
On Arduino or Genuino 101 RX doesn't work on Pin 13