Hi,
I have a problem with Serial comunication.
My components:
Arduino Mega
External device Serial config: 9600,8,1,0,0
each 10 sec send *XD,1234,1234,12,1234,1234,1234#
Device is grounded with arduino.
Similar result with any Serial port (1-3), i try SoftwareSerial too.
I expect some like this:
*XD,1234,1234,12,1234,1234,1234#
(char)Serial.read() I read some like this:
µęť•źŹk§ź—§źťŤ‘§źťźź§ź•źź§ź—•ź§ź›•Źą
Serial.read() I read some like this:
181 234 157 149 159 143 107 167 159 149 167 159 155 149 147 167 159 151 159 159 167 159 159 159 159 167 159 153 157 141 167 159 155 151 151 185
I use default SerialEvent sketch:
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
inputString.reserve(200);
}
void loop() {
if (stringComplete) {
Serial.println(inputString);
inputString = "";
stringComplete = false;
}
}
void serialEvent1() {
while (Serial1.available()) {
char inChar = (char)Serial1.read();
//delay(1); //no effect
//delay(10); //no effect
inputString += inChar;
Serial.print(inCahr);
//Serial.write(inCahr); //no effect
if (inChar == '\n') {
stringComplete = true;
}
}
}
Any Idea or solution?
THX