I'm programming a control system for a motorbike powered by a 68V battery. From this battery I have a shunt resistor whose voltage is amplified by an op amp and fed into an analog pin of the MEGA2560, this works fine.
I then connect the battery to a basic voltage divider with 2 resistors (33k and 430k for a x14 division). This is where it behaves "weirdly". I want to use a voltage regulator to power the op amp and the arduino and make it all standalone. When I close the system to the ground of the battery with the regulator powering the arduino and the op amp I get a fixed reading from the voltage divider (should be oscillating a bit) on the Arduino which is wrong (Using a LCD screen).
I checked the voltages between the ground of the battery and the divider's output and it is fine. The arduino is not sensing the input voltage properly from the divider. Now, when I plug the arduino to my laptop using a USb cable and keep everything plugged as is (regulator+ op amp + divider), it works perfectly fine! I am not sure what is the cause of this, if anyone has any idea it would be greatly appreciated! Thank you for your help!
TO sum up: When my system is not plugged to the USB laptop it gives out wrong readings when its inputs apear to be correct. As soon as it is plugged on my laptop it all works fine!
This is the schematic of the circuit where the arduino returns the wrong value for the voltage divider (A4)
This is the schematic where it all works fine:
Don't hesitate to tell me if this is not clear enough, I will draw them again.