Problem with Arduino + Xbee + Motors powering (?)

I don't know if the problem is the power supply, so i put a question mark in the title.
I have an arduino with a xbee shield and a xbee module that receive inputs commands from another arduino with xbee and controls a servo and two DC motors via two H-bridge. The whole project (at least the part that receive commands and runs the motors) is powered by two 12V, 4,5Ah batteries.
When i power the arduino via the USB and the motors via the batteries, it works perfectly and all commands are received perfectly.
Problems come when i try to power on also the arduino via the batteries, putting 12V in the Arduino Vin and GND from the batteries in the GND. The Arduino and Xbee shields power on, because I can see the leds blink, but it won't work with the commands sent by the other one.
What could I do?