Demonstrating println problem.
Here we go:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
char string[] = "AT\r\n";
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
mySerial.begin(115200);
Serial.println("arduino");
for (byte i = 0; i <= strlen(string) - 1; i++) {
mySerial.write(string[i]);
Serial.print(string[i], DEC);
Serial.print('\t');
Serial.println(string[i]);
delay(1);
}
//mySerial.write("AT");
Serial.println("Esp");
}
void loop() { // run over and over
while (mySerial.available()) {
Serial.write(mySerial.read());
}
}
output:
arduino
65 A
84 T
13
10
Esp
AT
OK
now with serial.print
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
//char string[] = "AT\r\n";
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
mySerial.begin(115200);
Serial.println("arduino");
mySerial.println("AT");
//delay(100);
//mySerial.write("AT");
Serial.println("Esp");
}
void loop() { // run over and over
while (mySerial.available()) {
Serial.write(mySerial.read());
}
}
output:
arduino
Esp
A⸮⸮⸮
and with 100ms delay added after serial.print
arduino
Esp
A⸮⸮⸮
exact same output.