gy 521

I use the gy-521 to control some motors, but I’ve noticed that if I upload the program and I have the USB connected everything works fine, the problem is that when I connect the robot to the battery, the motors work but the gy-521 just send nan instead of the values. It’s like that part of the program it’s ereased.
Some ideas?

What is a GY 521?

What Arduino are you using?

What batteries are you using to power it?

Post your program. And please use the code button </>. See How to use the forum