I have a project that will use a lot of Arduinos. I need to connect them one after another , each one of them will have an ID (stored probably in EEPROM), and I need to receive a string in the first one of them that show the order of the connected ids.
For example if I have 3 connected, it could be 1-2-3 or 2-3-1....
Any idea how can I do it - hardware wide and software wise.
Assuming you have at least two Serial ports - or use SoftwareSerial - it can be done quite straightforwardly. Say Serial1 gets connected to Serial2 (or Master) downstream, Serial2 gets connected to Serial1 upstream, and stick to that scheme.
Master queries Arduino1, gets ID from Arduino1.
Arduino1 queries Arduino2, gets ID from Arduino2, sends it to Master.
Arduino2 queries Arduino3, gets ID from Arduino3, sends it Arduino1, which sends it to Master.
Arduino3 queries Arduino4, realises there's no Arduino4, sends special character/number to Arduino2, which sends it Arduino1, which sends it to Master.
The master receives Arduino1 ID, Arduino2 ID, Arduino3 ID, terminator. Now you know the order in which they're linked, and how many there are in the chain.
Now of course the question: what are you actually trying to do here?
You can also do it on I2C if you use Arduino Dues. They have 2 I2C ports. One can be a slave and the other is master. Every one checks if it has any other connected to its output. If it is asked (as a slave) it can report its own number plus the others downstream.
Didn't we answer this quite thoroughly recently for someone with a complex MIDI daisy-chain project?