LiPo Battery Charger for UPS system

Hi to everyone. For a university Lab course i have to realize a UPS unit with a internal LiPo battery that i have to charge with a buck converter. I have tried to realize the software that control the charging operation and it works properly.

Few days after i verify that the code works properly i found a problem with the voltage that i measured with arduino, they floats and so the battery charger can't work properly since it can't keep the voltage constant during the constant voltage phase of the battery charging process.

I found that it happens when plug arduino into the USB port of the computer after i have started the PC, while it doesn't happen when i plug the USB cable of arduino and then start the PC. It seems to be a problem with the ground of arduino.

I'm using one arduino, on which i have upload the code of the UPS battery charger, and a second arduino to verify the output of the UPS unit (output of the internal inverter). I verify that the problem is not connected to the Inverter or other component of the UPS since i try the battery charger alone and i can still have the voltage floating of the analog pin from which i read the voltage of the battery and the voltage of the network (output of a AC/DC converter that we simulate with a 4AA battery pack).

Why this problem happens??

Probably something to do with your circuit, or wiring. But as you have not provided any usefull information, I guess at a missing GND connection.

I verify all the connection and all the GND are correctly connected. The circuit work well few days before and i used the same cable. I'm on breadboard, could it be the problem?

Going by the information supplied, my new guess is 'banana!'

The total circuit (network, buck converter, Lipo battery and inverter) is the following one

if necessary I can also upload the overall code and a photo of the real circuit, but due to the high number of cables it is not possible to see everything clearly ...

I make the circuit on tinkercad, with the same topology that i have realized on the breadboard.
The value of the resistor, inductance and capacito are the previous one that i have indicated on the draw... the 9V battery represents the LiPo battery of 3.7V (on tinkercad there's no a rechargeable battery model).

There's also a 10Ohm resistor that we placed here only to measure the current that is going to flow on the capacitor and on the LiPo battery. I read the network voltage (pin A0 is connected to the series of the two 4.7kOhm resistors, i read the voltage at the central node of the voltage divider and then i multiply the value for a factor 2, so i can measure the real voltage of the battery pack that will be around 6V), the resistor voltage and the battery voltage. I calculate the charging current as: (resistor_voltage - battery_voltage)/10.00

I also read the value on one side of the output resistor with the same arduino on which i have uploaded the total code of the UPS to apply a reaction and give the correct value of the output (3V peak-peak) while the battery goes down.

If necessary i will upload all the code, but i'm sure that it is correct...
The two arduinos are connected trought USB cable on the same laptop... i can't understand where is the problem...