0

Sorry for bothering. I have a problem with my project and I can't fine someone who can help me yet.

I need the next configuration: PC --------------USB cable-----------------MegaA---------------USB cable----------------MegaB

I need serial communication with USB cable in both boards.

I have now solved the ( PC --------USB cable------MegaA) part.

And the other part, I have done PC------------------USB cable------------------MegaB

But I need do that like the first schematic. I don't have access to the MegaB because this is inside a machine, I can't access to its pines, I need connect to it by USB Cable. Is possible do that with ARDUINO MEGA ADK in the MEGA A position? or I need other kind of board or add one shield (like USB host)? I need send one thing from the pc to MegaA and Mega A send the same thing to MegaB. Is it possible? because I can't find some way to specify that I need recieve the information from one serial port, and send it to another different serial port. I need help, is very important. Excuse my english Thanks

1
  • Does MegaA have to relay your thing to MegaB? Couldn't you just use a USB hub to plug both of them into the PC?
    – brhans
    Commented Jun 18, 2015 at 12:35

3 Answers 3

1

You would need a USB host shield to achieve what you want.

The Arduino by itself is not capable of connecting to both a PC and another Arduino through USB without the addition of extra hardware. In this case the USB Host Shield as detailed on the Arduino website:

http://www.arduino.cc/en/Main/ArduinoUSBHostShield

In the list of supported devices is:

  • USB to serial converters: FTDI, PL-2303, ACM, as well as certain cell phones and GPS receivers.

The magic word there is ACM - that (or more specifically CDC/ACM) is what the Arduino USB Serial interface is.

2
  • I think that Hot shield is the answer, but I don't know If I can use both ports at the same time ( if one of them not cancel the other one) and how i can indicate the port to receive and the port to send, all the programs that I have found using the serial pins, and when it define the serial communication using the pins number to differentiate the receive part of the send part.
    – Set
    Commented Jun 20, 2015 at 11:26
  • You seem to be a bit confused about what a host shield does and how it connects to the Arduino it is stacked on. There won't be any confusion in your program as the Host operations will be quite distinct. It is possible you will eventually end up with a "HostSerial" or something class you can use to talk to the slave Arduino, but it will be up to you to proxy messages arriving on "Serial" through to that when appropriate. To be honest, what you want to do seems beyond the realm where Arduino is a sensible choice. Commented Jun 20, 2015 at 13:42
0

A USB host is far beyond what an AVR Mega handle. You could add a 'daugther' board of some kind, but that would be a computer far more powerfull than the Mega itself (think of a RaPi, or a fat 32-bit micro-controller), so it would be a bit weird.

You might physically patch the first USB through to the second one, using for instance a relay. That would allow the PC (but not the first Mega) to talk to the second Mega.

2
  • The USB Host Shield, which will do the job fine, is not "a computer far more powerful than the Mega itself". The Arduino is perfectly capable of performing the task with that small addition of a single SPI interfaced USB host chip.
    – Majenko
    Commented Jun 19, 2015 at 0:17
  • @Majenko - on the contrary, most hosts are in fact computers more powerful than the mega. But the real solution is to replace the hosting mega itself - for example with a $3.30 KL25Z Commented Jun 20, 2015 at 13:39
0

You don't actually need to use serial-over-usb, the two devices can communicate more simply. The simplest way would be to Serial1, which uses pins D18 and D19; connect Serial1 on MegaA to either the serial or serial1 on MegaB. Since MegaA's transmit is MegaB's receive, you need to cross-over the wires (i.e. connect MegaA's TX to MegaB RX and vice versa).

Complete details can be found at: http://www.arduino.cc/en/Tutorial/MultiSerialMega

Make sure the two Megas have a common ground - the easiest way is to use one power supply (in your case, the USB) - you should just be able to wire GND and +5V from one board to the same pins on the other. If you use two different power supplies (e.g. two USB ports, even on the same PC), they may have different ground levels, and you can get a current flow directly out of one ground, and in to the other, damaging your PC.

1
  • 2
    "I don't have access to the MegaB because this is inside a machine, I can't access to its pins" - so how does he go about that then?
    – Majenko
    Commented Jun 19, 2015 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.