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?
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.
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.