I2C problems.

Ok, so I've written some code so that my nano can send commands to my uno, and it works just as I want it to. However, the it only works when both are connected to my laptop via Serial. I don't have to have the serial monitor open on the uno, but as soon as I unplug it from the laptop, (and yes I do have it connected to an alternate power source) it doesn't respond to the commands anymore, and the TX light doesn't flash. Any ideas as to why this is happening?

I2C_Master.ino (1.04 KB)

I2c_Slave.ino.ino (1.14 KB)

Are both grounds connected together?

and the TX light doesn't flash

Well, the I2C communication doesn't involve Serial or the Serial to USB converter, so why would you expect the TX light to flash?

On the master, look at when it sends data to the slave. How do you expect that to happen when there is no serial data coming in? Without the connection to the laptop, where do you think the serial data is going to come from?

Please don't call 'Serial' or 'serv' in the receiveEvent() handler. I prefer to do that in the loop(). The receiveEvent() is an interrupt handler, and should be short and fast.
Do you want to transmit an integer via I2C ? then you have to rewrite the code.
Perhaps you could use a single format (for example a struct) of a fixed size for all commands.
Are the attached files the full sketches ? In the Master, you don't set 'target' to 8 for the address of the Slave.

Beside connecting the grounds, the current of the servo motor can make any project go haywire.
The moment a servo motor starts moving, it might need a peak of 500mA or even 1A. That will cause a drop in the power voltage. And the ground current from the servo could easily stop the I2C bus or reset an Arduino board.

You have to be careful with the peak currents and ground currents and the power supply for the servo motors. How did you connect it ? Can you make a photo ?

PaulS:
On the master, look at when it sends data to the slave. How do you expect that to happen when there is no serial data coming in? Without the connection to the laptop, where do you think the serial data is going to come from?

The master is still connected to serial, and the slave is not.

Byork:
Are both grounds connected together?

No they aren't. I think that's the problem.