SoftwareSerial on Arduino Mega 2560

Hello everybody,

I know that Arduino Mega has 4 Serial ports but I want to use a software serial!
Why? Because I’m going to use a library developed for Arduino Uno with Arduino Mega. And this library uses SoftwareSerial so to avoid to write the entire code converting software serial in hardware serial, I prefer to make the software serial work.

I saw that I can use only pins that support change interrupt for RX like 11, but it doesn’t work.
Does anybody have good results with software serial on Arduino Mega?

TY
Marco

up :)

evildeejay: Because I'm going to use a library developed for Arduino Uno with Arduino Mega.

Minimal information would appear to generate a minimal response.

What library?

You’re right…
It’s a library (http://code.google.com/p/gsm-shield-arduino/) that I’m developing for GSM GPRS GPS Shield of Futura / Open-Electronics
(http://www.open-electronics.org/arduino-gsm-shield/).
Now I’m changing the entire library to use the HardwareSerial instead of SoftwareSerial.
I thought that changing the pins of the SoftwareSerial from 4 and 5 (for Arduino Uno) to 10 and 11 was enough… but probably it isn’t.
Is it possible that nobody used SoftwareSerial on Mega?

No doubt they have but why bother when you have so many hardware serial ports?

I thought that changing the pins of the SoftwareSerial from 4 and 5 (for Arduino Uno) to 10 and 11 was enough... but probably it isn't.

Why not try it and see?

[quote author=Nick Gammon link=topic=103424.msg776553#msg776553 date=1335655487] Why not try it and see? [/quote]

Of course I tried but it doesn't work... I tried with softwareserial because I thinked that was easier then re-write the entire library for convert the softwareserial in hardwareserial.

Well I would investigate a bit more. I tried this sketch on my Mega2560:

#include <SoftwareSerial.h>

SoftwareSerial foo (10, 11);  // Rx, Tx

void setup ()
   {
   foo.begin (115200);
   }
void loop () 
{
   foo.print ("Hello, world.");
   delay (200);
}

And checked with the logic analyzer:

Seems OK to me.

Thanks for help. Interesting... maybe the problem is in RX. Amazing the logic analyzer, can you give me the name? Marco

http://www.saleae.com/logic/

Thank you for pointing the right direction — and the right pins.

It seems all pins are not equal:

PeterMac: Digging around in the source code of the library, I came accross the following:

// Specifically for the Arduino Mega 2560 (or 1280 on the original Arduino Mega) // A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins) // Only pins available for RECEIVE (TRANSMIT can be on any pin): // (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me) // Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

So pins 2 & 3 won't work (for receive). Maybe this post can help someone else that has the same problem.

Found at http://arduino.cc/forum/index.php/topic,103424.msg776592.html#msg776592

I just found this post on a google search. I know it's only 5 years later, but - thank you for the information. This probably would have been useful to me if it were listed on the pages that explain software serial to begin with.

Well, that was maddening.

@Avenue33 is right. When I moved my RX port off of 15 to a supported port (50 for example) it worked!

The documentation for "SoftwareSerial Library" is at least partially wrong regarding valid RX ports on the MEGA 2560. https://www.arduino.cc/en/Reference/SoftwareSerial