RS232 - problem on MEGA ADK using Serial3

I have a MEGA ADK and using Serial3 - so am connecting rs 232 data to pins 14 as Tx and 15 as Rx.

My problem is that I can not read any rs232 external inbound strings at all.

I have proved that by using the test program ( at bottom of this msg ), that if I short Tx & Rx pins 14 & 15 together, then the data sent by the test sketch, comes straight back in, as is to be expected. ( A loopback test ) This tells me that arduino ports are functioning ok, and by shorting and removing I can interrupt the flow of rs-232. So board and serial port appear ok.

If I now connect RS232 data in from either: a bluetooth modem, or a GPS unit, into the RX pin then nothing is displayed in my test prog !

I have converted the data levels from both the GPS, and the modem through a MAX232 circuit to be of 5V TTL levels. ( ie arduino compatible )

To ensure that both of these devices are really sending data and to make sure my baud rate is as I expected; I have connected these 2 devices through a USB to RS-232 converter into my PC, and my PC sees the serial data streaming when I use Putty , I can see both GPS data NMEA strings or an OK response to an AT if sent to the bluetooth modem. So both my devices definitely send out RS232 strings at 4800 Baud.

I have built several MAX232 circuit boards, and to ensure they are working, I have connected 2 boards back to back so my RS-232 goes from + - 12v through a MAX 232 to become 5v levels then connected into another MAX232 and back out as + - 1 2 V This back to back circuitry I have connected into my PC USB to RS-232 and it shows that data from a GPS unit is converted by max232 to 5v then converted again to + - 12v then streamed into my RS232 - USB dongle and data comes into PC. So I feel confident that my MAX232 conversion circuit is functioning as expected and providing a 5v TTL signal into Rx Pin 15

Sadly when I connect my external data into Pin 15 Rx nothing ever appears in my test prog

Having tried the tests above, I have run out of ideas of what to test next as to why the arduino can not see any inbound RS232 data.

I would be very grateful to hear your suggestions of what to try next. Code below Many Thanks Les

// This prog works fine when Serial3 Pins 14 & 15 are shorted but fails to talk to BTooth Modem

int incomingByte = 0; String msg ="";

void setup() { Serial.begin(9600); Serial3.begin(4800); Serial.println("Setup"); }

void loop() {

Serial3.println("AT");

if (Serial3.available() > 0) { Serial3.println("AT"); Serial.println("IN Loop");

// send data only when you receive data: if (Serial3.available() > 0) { while(Serial3.available() > 0 ) // have more data { msg += char(Serial3.read()); delay(350);

// say what you got: Serial.print("I received: "); Serial.println(msg); } } } }

Code tags, please.

How to use this forum

// This prog works fine when Serial3 Pins 14 & 15 are shorted but fails to talk to BTooth Modem

int incomingByte = 0;
String msg ="";

void setup()
{
  Serial.begin(9600);
  Serial3.begin(4800);
  Serial.println("Setup");
}

void loop()
{
   
  Serial3.println("AT");

  if (Serial3.available() > 0)
  {
  Serial3.println("AT");
  Serial.println("IN Loop");

  // send data only when you receive data:
        if (Serial3.available() > 0)
        {
           while(Serial3.available() > 0 )  // have more data
           {
            msg += char(Serial3.read());
            delay(350);
             
               
                // say what you got:
                Serial.print("I received: ");
                Serial.println(msg);
        }
     }
  }
  }

Code tagged as requested.

Is there a good ground between the devices? Just checking...

 if (Serial3.available() > 0)
        {
           while(Serial3.available() > 0 )  // have more data
           {
            msg += char(Serial3.read());
            delay(350);
             
               
                // say what you got:
                Serial.print("I received: ");
                Serial.println(msg);
        }
     }

Huh? What's the delay for?

http://www.gammon.com.au/serial

It was there as a modem settle down time, but agree it serves no function in this test, I read before that HC06 bluetooth prefers it that way.

Many thanks to all for your advice especially to Surfertim, it turned out to be a problem caused by a flakey connection. Breadboards and these plugin cables are not the most reliable connections. Thank You.