Most reliable method to communicate between 2 arduinos?

Hello, I am looking for the most reliable way to communicate between 2 arduinos. I need 1 way transmission of an number from 0 to 100. The distance between the two arduinos is about 15 feet and they are connected by a shielded wire. One is a nano and is driving a servo. The master control unit is a mega. I tried I2C but it is nowhere near reliable. The nano will be under an outboard engine cowling so the voltage input could be kinda dirty and obviously there will be spark plug wires nearby etc. With I2C the servo signals would mess with the I2C signal and then the mega would hang up due to a glitch in the I2C library. I am done with the I2C and need suggestions on what other protocol to use. Usually in this situation CANbus is used, but due to space limitations I can't fit a shield onto the nano.

UART Serial works well over that short distance. Twisted pair is all you need (plus ground).

I2C was designed to connect ICs on a single PCB, and can become unreliable with connections just a few cm long.

2 Likes

I would suggest hardware serial between the Nano and the Mega. It does not sound like the Nano will need the hardware serial pins for input from the monitor once the program is loaded. The Mega has multiple additional serial ports for you to use.

2 Likes

Can would work with about all of the Arduinos. The CAN module is not very expensive. Try this link to get an idea: Create Your Own CAN Network With MCP2515 Modules and Arduino I use Cory Fowler's mcp can, it works great and has everything you need to get started. CAN is a bit tricky but is very robust. The node sending a message needs it to be acknowledge in frame by one or mother other modules that are receiving the transmission. Simply you need a transmitter and receiver on the bus for it to work which you will have. Nice part you can use twisted wire.

1 Like

Another choice is RS485.

2 Likes

Is the Nano only used to control a servo?
Then can't you just sent that servo signal from the Mega with an opto coupler?
Leo..

  • CAN Bus: if you have space limitations... don't use a Mega + shield but a Nano +breakout board or even smaller an ESP32 with CAN transmitter.
  • RS485
1 Like

@vroomZOOM

1. TTL format of UART signal can travel upto 100-150 feet without any buffering; so, the UART communication should work well in your case of 15 feet distance. In a noisy environment, you may use shielded cable; but, the common ground line should be there.

2. A typical connection diagram between MEGA and NANO is shown below in Fig-1.
uartMegaNanox
Figure-1:

(1) At MEGA side, yo can use the hardware UART1 Port.

(2) At NANO side, you can use a software UART (SUART) Port leaving UART Port with PC/IDE for uploading/debugging. However, SUART works well at Bd = 9600. If you want higher Bd, then NANO could be connected with UART Port after the uploding of the sketch as suggested in poat #3 @cattledog.

1 Like

I have found the Adafruit Feather M4 CAN to be bullet proof. A little pricy but the seller support, speed, memory and small footprint (12mmX25mm) makes it worth the cost

1 Like

Hi everyone, I just ended up using plane jane serial, and it works wonderfully. i used shielded wire and a 4800 baud rate, and have no problems with the engine's ignition interfering with any of the components. Thanks to all!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.