Newsoftserial (11 Beta) with Mega2560 Receive not working

Hi folks

Perhaps you can help me from pulling out the few remaining hairs that I have left. I have a problem, that must be very simple to solve, and it has me almost beat!!

Using an Mega2560 chip and Arduino 0022 suite, and everything works great. I love it. I’ve used up all my hardware serial ports (GSM, GPRS, External device, and want to keep Serial0 reserved for USB programming). No problem you might say, especially with the NewSoftSerial library - particularly nice as it’s interrupt driven allows me as the programmer more freedom to in my main loop to do things rather than continually polling for receive data on my softserial-port.

Only problem is, that I cannot for the life of me get it working. Wiring etc should all be fine, I’ve used the same cables with two hardware ports and everything ok. But as soon as I connect to my software-port (I’m using pins 2 & 3), I can only transmit from my board to the PC, but cannot receive data into my board from the PC.

I’m using the nice simple examples provided (serial data in on one port then pass it out on the other, and vice-vearsa).

Is there something I’m missing? Do I need to set the pins up as inputs and outputs (I’ve tried this). Or do I need to enable interrupts somewhere? I’m not using my proper build, I’m now down to the dozen line example, and I’m really stuck.

Baud rates seem ok (measured on the scope). Data definitely being transmitted by the PC. Just seems that my software port is deaf.

Code included in case there’s something obvious.
#include <SoftwareSerial.h>

SoftwareSerial mySerial(3, 2);

void setup()
Serial.println(“Goodnight moon!”);

// set the data rate for the SoftwareSerial port
mySerial.println(“Hello, world?”);

void loop() // run over and over
if (mySerial.available())
if (Serial.available())

Any help would be very much appreciated.

Many thanks


Thought I would shelve my frustration for a day, get on with the other code, and come back to my soft-serial port with fresh eyes and see what it was so stupid that I was doing.

Well - the first bit worked, got everything else up and going. Came back to my problem though, and still no joy. :-(

After a little probing around with the scope, I've noticed that the receive line (into my Arduino) is being held high, and when I transmit something from the PC, I would have expected to see the line toggle with the data, but it doesn't. When I unplug from my board, do the same test, the line toggles as expected. But once connected again it doesn't. Seems like some hardware setting on the Port is keeping the line high - anyone have any ideas?

Having a look through the code, it certainly seems that the NewSoftSerial code does everything for me (interrups, setting the line as INPUT etc), and I should only need to hook up some cables and get it going (which I'm sure is the case - I'm just missing some simple ingredient).

Anyone able to help?



And so it goes - it was something small, but not that easy to find. 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.



It's the simple things that can keep you smiling for while!! :-)

And my thanks to Paul Stoffregen for his useful code commenting!!


Is it possibble to use pin 15 (rx3) for software serial....

It suppodts PCI.. but omitted in the code ?