Two shield and several sensors for an Arduino only: how to?

Hi everybody,
I'm working to a project on my car that has to respect these requirements:

  • to take data from CAN module;
  • to take data from my sensors;
  • to communicate it in wireless to a remote station (about 500 m far).

I have chosen Arduino Mega for my work, because of its several analog and digital Pin; the CAN module is necessary for read from the Control Unit of my car.
For wireless communication I have chosen an XBee module.

The problem I have is on sensors and module managing. Id est:

  • Can I read data from CAN and communicate it by Xbee module using the same Arduino Mega?
  • If no, how can I respect the requirements above?

Budget is not a problem, even if economic solutions are preferred: so if you have a solution that -for example- needs two Arduino, please report it!
If I can use smaller Arduino (for example Arduino Mega + Arduino Nano), is better!

Thank you for your support

First question : what kind of CAN module are you using on the Arduino? Is it SPI based or something else (like a serial port as with EDM327 chip)

If it is SPI based, you can perfectly share it with XBee module (since the XBee uses serial port for communication). There will be no conflict.

Now, if you need to share multiple SPI devices on the same Arduino, it's also perfectly possible. Make sure that the Arduino is SPI Master, and connect MISO, MOSI and SCLK of all devices to the matching lines on the Arduino.

The key is simply to use two different IO pins for the selection (SPICS). When a SPI device is deselected, the MISO line goes in high impedance. Another SPI device can then drive the MISO line.