Im currently in the process of building a drone with a Raspberry Pi Zero 2W for the camera, and an Arduino Nano to receive signals and control the motors. My current issue is that my GY-521 MPU-6050 accelerometer only works when i power it over USB, but when I plug in my LiPo battery and run the same code, it hangs after it prints out a few pieces of data.
I'm suspecting something to do with power, but I don't understand why, because the battery supplies much more than the USB
(ALL ESC CONNECTED THROUGH PWM TO ARDUINO)
4s lipo battery------------------- 50amp fuse------FL ESC --------- FL Motor
- -----FR ESC --------- FR Motor
- --BL ESC --------- BL Motor
- ---BR ESC --------- BR Motor
-
--5 amp fuse---5v Buck Converter ----- ---Raberry Pi Zero 2w ---------- Camera
---------------- Arduino Nano
-------------- HC12 Radio Module
---------------MPU6050 GY-521 Accelerometer
My code currently is basically only testing the MPU when I press a button. The same phenomenon happens when I run the example code. I'm using the Adafruit MPU6050 but have tried another with the same result. crashes on this line every time.
Nanov3.0
mini560 Buck Converter
void testMPU() {
sensors_event_t a, g, temp;
Serial.println("BEFORE");
mpu.getEvent(&a, &g, &temp);
Serial.println("After");
Serial.println("MPU read successful");
} //always prints BEFORE then hangs when battery connected
TESTS I DID
USB acclerometer prints out data fine
USB + battery hangs
Battery hangs
battery only (able to run pi and camera and stream to my laptop)
Tested another MPU6050 board on the arduino uno over usb and it never hangs. if it gets disconnected it will just output zeros.
MEASURED VOLTAGES WITH MULTIMETER
3.8V-4V measured on buck converter output when over USB
5.14V measured on buck converter output when powered over LiPo
leading theory is that the voltage difference between USB and the battery is somehow either messing with the Arduino because I'm inputting directly to the 5V pin on the Arduino, NOT VIN, or it's messing with the accelerometer somehow, even though it should be able to take 5v. I would appreciate any help!
