Jitter when charging battery via USB xiao-esp32-c3

I get an increase in jitter on a connected joystick when I plug in a USB cable and start charging the battery.

The increased jitters go away once the battery is fully charged.

The device I’m inventing is a buttons and a joystick over wifi affair. The joystick had natural jitter, so I spent a lot of time with the sketch trying to suppress its effect so it wouldn’t send commands to the receiver when it was centered and nobody was touching it. I did that with it connected to my computer with a USB cable using serial monitor on Arduino IDE to get the raw numbers. Eventually, I had it mostly stable. Output to serial monitor was silent. Maybe there was a long spike every once in a while that got past the sample rate, but it was rare.

Then, I plugged in a battery. The jitters came back. Or, they were just increased past the dampening settings I established. I know, because serial monitor says so, but also because the LED I added to show transmissions flashes. The effect happens also when I’m connected to a wall charger. Not just when connected to computer. I only started having this problem when I switched to the seeed board because of the on-board charging to reduce size. I was using an external battery charging circuit with a different board before.

The effect happened with a 250 mah battery and a 2000 mah battery and on two separate builds of the device using different boards in each.

Here is the way I have it wired:

D0 button

D1 button

D2 VRY

D3 button

D4 packet sending LED

D5 button

D6 button

D7 wifi is connected LED

0.1 uf capacitor across GND and +5V on the joystick

220 nf capacitor across GND and D2 on the board

330 ohm resistor between VRY on the joystick and D2 on the board

330 ohm resistors between the pins and each LED

+5V on the joystick is wired to 3V3 from the board

The joystick is a generic mushroom cap thumb type you can get from amazon postings that say “blah blah for arduino blah blah” on all the listings.

Is this a known issue? My search of the forums didn’t find anything. How can I fix it?

Hi there,

And Welcome here…

Sounds like a cool project, and I think it’s been on here before, A thumb version with BLE, not wifi. So for prior art , your covered :grin: :+1:

The battery charger is noisy perhaps the draw on it is too high. You look to have a pretty beefy battery with high charge current req’s,
I would try to manage that better, stay with the smaller one, work with that until it is solved. add a big Supply bypass cap , close the the +vcc pin and GND, the WIFI is a power hog, and a transient maker..on the C3, and where is your antenna at? try one of the larger stub versions also, you may be surprised with the results.

Post up a picture of this amazing Apparatus, lots of smart folks on here willing to help.
and definitely watch those resistor values.
my first glance , recommends.

Others will certainly chime in :+1:

HTH
GL :slight_smile: PJ :v:

I think this must be a V Ref issue… but i dont know how to fix it.. unless using an ADC pin to run a caliberation map… maybe a capacitor on the power side of the sensor… IMO