Pages: [1]   Go Down
Author Topic: Help: Serial Communication between two Arduino  (Read 1292 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
Can i establish a serial communication between two Arduino ICs ?
I want to send command from master to slave.
I have uploaded the circuit diagram, i wanted to know if it will work...


* Circuit 1.jpg (323.27 KB, 2264x1196 - viewed 67 times.)
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8524
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That should work, the GNDs have to be connected as well which is shown in the schematic but people are inclined to forget when the chips are separate.

How far apart will they be?

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot.. yes their grounds are connected.. they are on the same PCB
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Whilst that looks like it should work, I would be using I2C instead. That lets you do master/slave and can generate an interrupt when a "packet" of information has arrived. Whilst incoming serial generates interrupts you have to "poll" for Serial.available in your main loop.

Examples:

http://www.gammon.com.au/i2c

The fastest I2C rate is around 40,000 bytes per second, compared with around 11,520 bytes per second with serial running at 115200 baud.

All you would have to do is connect together SDA and SCL (and Ground). Unlike serial you do not swap them. Also read the part about it helping to use pull-up resistors.

This has the advantage that it leaves the serial port free for debugging, or uploading new programs with an FTDI cable.
Logged


nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8524
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, now that we know the chips are on the same board I'd also say use I2C.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Queens, New York
Offline Offline
Faraday Member
**
Karma: 99
Posts: 3632
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can do arduino to arduino with Bluetooth, that's easy. Knowing exactly what your sending and receiving may be a little tricky.

But it is possible, because I myself am using arduino to arduino with my robot.
Checkout my YouTube channel HazardOfExistance, I posted an update of my college seminar project that does just that.

The only downside with Bluetooth, is the range. Bluetooth's range is short, about 30 feet, in an open area. If you want range, then go with Xbee.
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

He did say they were on the same PCB.
Logged


Queens, New York
Offline Offline
Faraday Member
**
Karma: 99
Posts: 3632
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh my mistake, I only read the first post, and figured they were in separate locations.

Why have them on the same pcb then, unless you want to expand your I/O pins.
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Australia
Offline Offline
Sr. Member
****
Karma: 13
Posts: 446
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Out of interest, what is the longest practical length you can run I2C wires in a noiseless environment?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think it is governed by the capacitance of the wiring rather than the length, but in any case you can adjust the clock speed over a wide range, so there is probably no simple answer. Purely as an example, the Wii nunchuk uses I2C, and has about a 1m cable length from the device to the plug.
Logged


Australia
Offline Offline
Sr. Member
****
Karma: 13
Posts: 446
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Nick.

The only option for reasonable distance, high speed comms is RS485?

That's interesting about the nunchuk. I assumed that the switches/joystick were hardwired through to the console.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's my nunchuk connected to an Arduino using a nunchuk adapter board (from Sparkfun I think):



I think there are I2C extenders. Because of the way the protocol works I doubt that RS485 would work.

Example: P82B715

According to their datasheet:

Quote
It uses unidirectional analog current amplification to increase the current sink capability of I2C-bus chips by a factor of 10 and to change the I2C-bus specification limit of 400 pF to a 4 nF system limit. This allows I2C-bus, or similar bus systems, to be extended over long distances using conventional cables and without degradation of system performance.

But for Serial (and/or probably SPI) I think you could use RS485. I think I tested RS485 up to 20m but you could likely go further:

http://www.gammon.com.au/forum/?id=11428
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot everyone for replying..
I have connected two arduinos by establishing a serial communication between them and its working perfectly.  smiley
Logged

Pages: [1]   Go Up
Jump to: