Connect arduino aun to arduino mega 2560

Hi all, I need to connect two Arduinos (Yun and Mega2560) the problem is that the arduino yun has reserved the pin D0 and D1, how serious the best way to connect them? I want her Mega read data through Wifi by the and a. Thank you very much to all

If you are familiar with serial communication between two Arduino's, then I'd suggest just using the SoftwareSerial library for the Yun, which will let you use any of the digital pins as a TX and a select few of the digital pins as an RX.

The Mega could then send commends/requests over to the Yun, which it could execute and return the data from.

Thank you for answering , I'm a little new to arduino . what I want is that the mega arduino works with sensors and from yun porder view data via wifi , is it possible? thank you very much

I'm a little unclear on the goal, but this is possible:

-Sensor connected to Mega.
-Mega sends sensor readings to Yun over serial using one of the Mega's several serial pins.
-Yun receives sensor readings using SoftwareSerial on one of the allowed digital pins.
-Yun creates a network accessible webpage showing the sensor value.
-Webpage can be viewed anywhere on the network that the Yun is connected to.

To accomplish the second half, I'd recommend following this tutorial:

But instead of having the Yun get the sensor value from an analog pin:
int sensorValue = analogRead(A1);
You will have it retrieve the sensor value from the SoftwareSerial RX buffer