Go Down

Topic: Help: Serial Communication between two Arduino (Read 1 time) previous topic - next topic

sahir_ismail

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...

Graynomad

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
Rob Gray aka the GRAYnomad www.robgray.com

sahir_ismail

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

Nick Gammon

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.
http://www.gammon.com.au/electronics

Graynomad

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

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

HazardsMind

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.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

Nick Gammon

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

HazardsMind

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.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

lemming

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

Nick Gammon

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.
http://www.gammon.com.au/electronics

lemming

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.

Nick Gammon

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
http://www.gammon.com.au/electronics

sahir_ismail

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

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:

shortcuts: alt+s submit/post or alt+p preview