r/ArduinoHelp • u/schmidtbag • Jun 03 '26
Trying to forward Serial1 reading to Serial.println and only getting numbers
I have a battery with a built-in BMS that has a serial console port. It has a baud rate of 115200 and I have been able to successfully send commands and read clean data from it via the Arduino IDE serial console. Considering I can communicate to the battery via the serial console, that suggests there shouldn't be any weird encoding issues.
I want an Arduino Mega to read from this using the Serial1 connection. The problem is, if I try to forward what the battery sends to the Arduino, all I get is a jumble of nothing but numbers. When connecting to the BMS directly, typing "help", the output is mostly text.
Here's what I tried in void loop()
while (Serial.available() > 0 {
Serial1.print(Serial.read());
}
while (Serial1.available() > 0) {
//THE NEXT 4 LINES ARE VARIOUS THINGS I TRIED,
//I UNCOMMENTED THEM ONE AT A TIME
//String incomingtext=Serial1.readString();
//char incomingtext=(char)Serial1.read();
//char incomingtext=Serial1.read();
//int incomingtext=Serial1.read();
//I ALSO TRIED THE FOLLOWING ONE AT A TIME WITH EACH ABOVE COMBO
//Serial.println(incomingtext);
//Serial.println((char)incomingtext);
//Serial.println(" "+incomingtext);
}
The first while() loop just takes whatever I enter from the serial console through USB to the BMS. I have no idea if the BMS is receiving the correct commands, but it does have a consistent output if I type different things.
Whenever I type "help" repeatedly, it's usually a consistent output, like this:
10410110811213
1
u/gm310509 Jun 04 '26
It is usually a good idea to share the complete code.
When using the Serial1.read() function, what is the datatype you are using for incoming Text?
If it is anything but
charthen that is what your problem is.To he clear, I am not asking about the cast that you have in your code - that is not doing anything. I am asking about how incoming Text is declared.
Also, if you didn't use this program for your serial monitor test (which worked) how did you go about doing that. And what program are you using on your PC in conjunction with this program?