Need some serious guidance here - I am a developer by trade. The electronics side of this is what is getting my goat....
I have two Arduinos that I need to communicate via Serial, but it isn't working, and I am wondering if the common ground is not being referenced correctly? The ultimate goal is to have the MEGA control the 3 UNOs via serial connections, but I cannot make it work with even one.
I have the UNO set to read from the Serial, and my commands are all programmed. It works fantastically when it is connected to a USB cable and a local Serial Monitor where the input is entered from the monitor. When I connect it to the MEGA and receive the same command - nothing.
The first Arduino is an UNO powered by a 12v DC power supply through the 2.1mm connector.
The second Arduino is a MEGA, powered by the USB cable connected to my computer. I am using Serial1 on the MEGA for the communications so I can use the serial monitor to view things.
I have both sides set to 38400.
I have connected the grounds of the Arduinos together to make a common ground.
Is this the correct way to make a common ground in this scenario? Everything I have read says to do this, but it is not working.
A common mistake is to connect RX to RX and TX to TX.
Is it possible that you've done this?
Should be RX to TX and TX to RX.
If your connections are fine, perhaps you can post minimal code for both ends that illustrates the problem?
(Please place it between [code]code tags[/code].)
Ok - checked the RX/TX. it is fine - doesn't work either way... Interestingly enough, on the MEGA, if I unplug the USB Cable, it stays powered... it is getting enough power from the UNO through the serial line to light the onboard LEDs....I do not understand why this is happening. From my understanding, it should not. If I power up the MEGA first, and then the UNO (which is on direct DC power), the led display connected to the UNO does not power. If I power the UNO first, it comes up, but then I have the weird power issue with the MEGA. This can't be that difficult - it is only three wires after all. I just do not understand how the MEGA is getting power over a serial connection...
javagod:
Ok - checked the RX/TX. it is fine - doesn't work either way...
As I suggested in my last post, "If your connections are fine, perhaps you can post minimal code for both ends that illustrates the problem?
(Please place it between [code]code tags[/code].)"
Interestingly enough, on the MEGA, if I unplug the USB Cable, it stays powered... it is getting enough power from the UNO through the serial line to light the onboard LEDs....I do not understand why this is happening. From my understanding, it should not. If I power up the MEGA first, and then the UNO (which is on direct DC power), the led display connected to the UNO does not power. If I power the UNO first, it comes up, but then I have the weird power issue with the MEGA. This can't be that difficult - it is only three wires after all. I just do not understand how the MEGA is getting power over a serial connection...
Not weird at all. It's often called "phantom power". I happens because the line from the UNO is high, supplying 5V to the input pin on the Mega. Because the chip has internal protection diodes from the pins to the +5V rail, the Mega gets it's power via the diode. This is a situation to be avoided. It can damage the diode, then potentially cause the chip to fail. CMOS chips should never have a voltage applied when they're not powered. Although the diode is providing temporary protection, it's only rated for about 1mA continuous. If the LEDs are lit, there's a lot more than 1mA flowing. Is it possible to power boards both from the same supply, so that power is applied/disconnected to/from both boards at the same time?