Communication between software serial and hardware uart

Hi,

I'm trying to let 2 arduino's communicate to each other.
The sender, an arduino mega uses hardware serial1 UART, the receiver, an arduino pro mini uses a softwareserial on pin 11 and 12.
The message doesn't arrive on the pro mini using hard and software serial.

The moment I change the mega from hardware to software serial, it works fine.

Isn't it possible to combine a hardware serial sender with a software serial receiver?

Thanks in advance for your feedback!

Isn't it possible to combine a hardware serial sender with a software serial receiver?

Yes. That assumes, of course, that you change the wiring between the two boards.

Where is your code, for both ends? Where is the picture of your setup?

You connect the rx of one to the tx of the other, twice and then the grounds together. Try using al low baud rate 9600 when software serial is in use.

Mark

The code of the sender (mega):

void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}

void loop() {
Serial1.print("MSG");
Serial.println("MSG sent");
delay(5000);
}

The code of the receiver (pro mini):

#include <SoftwareSerial.h>

SoftwareSerial SS1(11, 12); // RX, TX

void setup() {
Serial.begin(9600);
SS1.begin(9600);
}

void loop() {
while (SS1.available() > 0) {
Serial.print("Data available in buffer (in bytes): ");
Serial.println(SS1.available());
}
delay(1000);
Serial.println("Incoming msg checked");
}


Rx1 of the mega is connected to pin 12 of the pro mini
Tx1 of the mega is connected to pin 11 of the pro mini

It's still not working.

Grounds are also connected to each other.

So what do you see on the monitor? Go on tell us, tell us, ......

Mark

Monitor Mega:

MSG sent
MSG sent
MSG sent
MSG sent
MSG sent
MSG sent

Monitor Pro mini:

MSG sent
MSG sent
MSG sent
MSG sent
MSG sent
MSG sent

but no "Data available in buffer (in bytes): "

As your getting the same output from both you have loaded them both with the same program, both are senders and you have no receiver.

Mark

I was mistaken:

monitor pro mini is
Incoming msg checked
Incoming msg checked
Incoming msg checked
Incoming msg checked
Incoming msg checked

I don't understand why the hardware/software combination isn't working, and this isn't causing your problem, but your receiver code isn't actually reading anything from the serial port so as soon as it receives the first byte it will spin printing the available count at the maximum speed of the serial port.

I don't see anything else wrong with the software and the hardware connections you describe seem correct, so I'd suspect a wiring fault/mistake as the most obvious explanation.

I hooked it up as you described and got:

Incoming msg checked
Incoming msg checked
Incoming msg checked
Incoming msg checked
Incoming msg checked
Data available in buffer (in bytes): 3
Data available in buffer (in bytes): 2
Data available in buffer (in bytes): 1
Incoming msg checked
Incoming msg checked
Incoming msg checked
Incoming msg checked
Incoming msg checked
Data available in buffer (in bytes): 3
Data available in buffer (in bytes): 2
Data available in buffer (in bytes): 1
Incoming msg checked
Incoming msg checked
Incoming msg checked
Incoming msg checked

I added an extra line to actually read the incoming byte, so the receiver is now:

#include <SoftwareSerial.h>

SoftwareSerial SS1(11, 12); // RX, TX

void setup() {
  Serial.begin(9600);
  SS1.begin(9600);
}

void loop() {
  while (SS1.available() > 0) {
    Serial.print("Data available in buffer (in bytes): ");
    Serial.println(SS1.available()); 
    SS1.read ();   // <------------ read that byte
  }
  delay(1000);
  Serial.println("Incoming msg checked");
}

I used a Uno instead of a Pro Mini for the receiver, but it should be the same.