I am using 2 ATMEGA 2560 boards for a large scale project. I have all the code more or less debugged for the first Arduino board. I was about to start the programming for the second board because this would be my first time setting up a Serial network of Arduinos. The second Arduino will be doing nothing other than compiling data for Arduino 1 from a bank of 3 position switches, effectively telling it the desired state of the machine and transmitting it via serial to Arduino 1. The issue is that ever since I plugged in the second Arduino into my USB hub, I have had no luck programming or reading serial data from either board ever since. Even if I remove the USB hub and directly connect only one board. All I am getting now in the Serial Monitor is bad print lines from old code running Arduino 1 and upload errors when I try to reupload fresh code. I was hoping someone might be able to shed some light on what is happening to me and help me get past this. I don't know if this is an issue with the IDE not liking something with the boards which is why I posted this in the IDE section of the forum.
For Reference:
Machine: Dell Workstation
CPU: Intel Xeon Class
RAM: 32GB
OS: Windows 10 Pro
This information was provided to rule out any incompatibility with new ARM based CPUs or possibly the ever buggy Windows 11.
TIA,
Zack
A point of clarification: Everything was working properly before plugging in the second ATMEGA 2560 board and both boards are ATMEGA 2560 based, but are not from the same manufacturer.
Hi, I had the same problem a short time ago, the problem lies precisely in the serial communication pins, pins 0 and 1.
through those pins the Arduino communicates with other devices in a serial way, including compure if connected in that way.
In order to program the board, during the programming phase, those pins must be free, otherwise if used as I/O pins or to communicate with other devices in serial mode they risk conflicting with the communications coming from the USB.
After programming the board it is possible to reconnect the serial communication pins.
Lastly, using 2 boards makes projects very complicated and unnecessarily complicated, if you have problems with the I/O pins you can use shift registers, they are very useful for greatly increasing the output pins of the micro controllers.
I hope I have been of help to you!
I just tried disconnecting the 0 and 1 pins. Even though there was not an active connection to the other board, and the other board was not even powered on, it was causing the issue. That was a very succinct and clean solution you provided. Thank you for the help. I am familiar with the concept of shift registers, but have never personally used them. I will look into them more deeply because I was never that big a fan of the Serial network of Arduino's to begin with, and this revelation would make it kind of a nightmare for any software updates I may need to implement on the final product.
You have to be careful with that. It can damage the boards. In this case the Tx line on the powered board will power the non-powered board through the Rx line.
If you want to be safe, you can put resistors in the signal connections between the two boards.
Tx --- ///// --- Rx
Rx --- ///// --- Tx
You can use 1kOhm resistor as is done on the (official) Mega for the communication between the serial-to-usb converter and the 2560.
It's not clear to me what the second board is that is communiting with the Mega. The Mega has 3 spare UARTs; use one of those for the communication with the other board. If both are Megas, use e.g. pins 16 (Tx2) and 17 (Rx2) and in the code use Serial2.
If your other board is a Pro Mini, Uno or Nano, you will not have a spare UART; in that case you can use SoftwareSerial for communication with the Mega.
You're welcome!
I've using the shift registers with normal I/O pins, you don't need to use pins 0 and 1, i don't use thats pins for shift registers.
I try not to use those pins also because if I use them as I/O pins and then use the serial monitor those pins mess everything up a bit because serial communication is also transmitted by those pins.
I would like to use them in the future to make the Arduino communicate with an ESP8266, so that I can interface it with the Arduino cloud and make a hydroponic culture with sensors and connected to the cloud.
Apart from this I don't think I will use those pins as normal I/O.
Last tip, maybe it's better to put resistors in those pins since you use them to make 2 cards communicate together. there could be problems if they were accidentally powered by different power supplies, or if for some reason the common ground was detached from one of the 2 boards.
you can probably use resistors ranging from 1KΩ to 5.6KΩ, maybe 5.6KΩ is a little high.
I hope I have been of help to you!
Have a nice day!