Corrupted Serial Input

I've been having trouble with getting serial input from my board while it is receiving power from a battery pack. I've tried multiple USB cables to root out those being damaged, and am printing my test output in decimal, hex, etc to make sure I'm not doing something wrong with encoding. When I run the attached test code with the battery pack plugged in, it just displays 0s or another random character (sometimes different between the same inputs). If the battery pack is not plugged in it works perfectly fine.

I'm assuming this is some kind of hardware issue, but figured it'd be best to ask here just in case it's something obvious I'm missing.

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

void loop()
{
  while (Serial.available() > 0)
  {
    char comdata = char(Serial.read());
    delay(2);
    Serial.println(comdata);
    Serial.println(comdata, DEC);
    Serial.println(comdata, HEX);
    Serial.println(comdata, OCT);
    Serial.println(comdata, BIN);
    Serial.println("_____");
  }
}

test.ino (416 Bytes)

If you post your code as described in the how to use this forum sticky more members will be able to see it.

Formatting data (HEX,DEC,BIN) does not fundamentally change the data. You have another issue.

What are the specs of the battery pack? How is the battery pack connected to the board? What Arduino board?

Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

blh64:
Formatting data (HEX,DEC,BIN) does not fundamentally change the data. You have another issue.

I was doing this to see how the data was being read, if at all. While the battery was on, most bytes would be read as just 0 when printed in binary. Occasionally they would display as other characters, but there didn't seem to be any consistency, even when I sent the same character multiple times.

groundFungus:
What are the specs of the battery pack? How is the battery pack connected to the board? What Arduino board?

Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

I'm using the board at the url below, which I'm aware as being a clone. My IDE detects it as an Uno. The battery pack is plugged into the board's power jack, and takes two 3.7 V batteries.
https://www.amazon.com/4WD-Smart-Support-IOS-Bluetooth-Creative-Education/dp/B07QQP4W9H

Does the board behave correctly when the battery pack is unplugged and you are only use the USB cable?

blh64:
Does the board behave correctly when the battery pack is unplugged and you are only use the USB cable?

Yes

When

hgy39477:
I'm using the board at the url below, which I'm aware as being a clone. My IDE detects it as an Uno. The battery pack is plugged into the board's power jack, and takes two 3.7 V batteries.

Are those batteries in series so you are appying 7.4V at the barrel jack? Since this is not a standard UNO, they may have done something different that does not work well with the battery pack and the USB cord. Since it is intended for a robot, I would guess they don't intend to have a USB cord attached during normal operation. Also, since there is a BLE module on board, they tend to run at 3.3V. Maybe the entire board runs at 3.3V.

Just guessing here...