- All comments, docstrings, and runtime messages in the source code are written in Portuguese
- This project was developed and validated in a simulated environment
This project implements a deterministic UART-based communication system between multiple Arduino nodes using a token-passing mechanism over a star topology.
A central node (ID 0) coordinates communication between peripheral routers:
- NORTE (NORTH)
- SUL (SOUTH)
- LESTE (EAST)
- OESTE (WEST)
Each router transmits only when it receives a TOKEN, ensuring collision-free communication.
All inter-router communication is mediated by the central node, meaning no direct router-to-router transmission occurs.
The project demonstrates several core embedded systems and networking concepts:
- Token-based medium access control over UART communication
- Star topology network with a centralized arbitrator
- Flit-based packet structure (ORIG / DEST / PAY)
- ACK-based reliable delivery with timeout and retransmission
- Buffer handling and flushing to prevent residual data corruption
- Multi-channel SoftwareSerial management on a single Arduino
Arduino_UART_Token-Based_Star_Network/
│
├── images/
│ ├── funcionamento_central.png
│ ├── funcionamento_norte.png
│ ├── funcionamento_sul.png
│ └── topologia_estrela_uart_arduinos.png
|
├── src/
│ ├── uart_central.ino
│ ├── uart_north.ino
│ ├── uart_south.ino
│ ├── uart_east.ino
│ └── uart_west.ino
│
├── License
│
└── README.md
- Central sends a
TOKENto the current node - The node replies with a 3-flit packet or
NADAif it has nothing to send - Central forwards the packet to the destination node
- Destination receives the packet and replies with
ACK - Central forwards the
ACKback to the origin - Central advances the
tokenonly after successful delivery or when the node reportsNADA - When all nodes reply
NADA, the session ends
Each message is split into 3 flits, sent sequentially over UART:
| Flit | Format | Description |
|---|---|---|
| 1 | ORIG:<name> |
Sender node name |
| 2 | DEST:<name> |
Destination node name |
| 3 | PAY:<text> |
Message payload |
| Message | Direction | Meaning |
|---|---|---|
| TOKEN | Central → Node | Node may now transmit |
| NADA | Node → Central | Node has nothing to send |
| ACK | Both directions | Packet received successfully |
Message flow from NORTE to SUL through the CENTRAL node.
- CENTRAL sends
TOKENto NORTE - NORTE transmits:
ORIG:NORTE
DEST:SUL
PAY:<message>
- CENTRAL receives the packet
- CENTRAL forwards the packet to SUL
- SUL sends
ACKto CENTRAL - CENTRAL sends
ACKback to NORTE - CENTRAL passes the
TOKENto the next router
If the destination router does not send an ACK:
- CENTRAL detects a
timeout - CENTRAL does not advance the
token - The origin does not receive an
ACKand automatically retransmits the packet within the same token cycle
This guarantees that:
- No packet is lost
- Delivery is confirmed before progressing
- Communication remains deterministic
Each peripheral node uses one dedicated TX pin and one dedicated RX pin on the Central Arduino via SoftwareSerial.
| Node | D2 (RX) Connected To | D3 (TX) Connected To |
|---|---|---|
| NORTH | Central TX (D3) | Central RX (D2) |
| SOUTH | Central TX (D5) | Central RX (D4) |
| EAST | Central TX (D7) | Central RX (D6) |
| WEST | Central TX (D9) | Central RX (D8) |
Note: Always connect GND between all boards sharing UART lines.
All timing constants must be consistent across Central and peripheral nodes.
Configuration Constants:
| Constant | Default | Description |
|---|---|---|
| BAUD_RATE | 2400 | Serial baud rate |
| DELAY_FLIT | 600–800 ms | Pause between consecutive flits |
| TIMEOUT_ACK | 12000 ms | Node timeout waiting for ACK from Central |
| TIMEOUT_ACK_DESTINO | 8000 ms | Central timeout waiting for ACK from destination |
| ESPERA_APOS_TOKEN | 2000 ms | Central wait after sending TOKEN |
| DELAY_APOS_ULTIMO_FLIT | 1500 ms | Extra wait after last flit before listening ACK |
To configure a peripheral node, edit the following section at the top of its .ino file:
const char MEU_NOME[] = "NORTE"; // This node's name
const char MEU_DESTINO[] = "SUL"; // Valid: SOUTH, EAST, WEST
const char* payloads[] = {
"Message 1",
"Message 2",
"Message 3"
};
int totalPacotes = 3; // Must match the number of entries in payloads[]- Centralized token arbitration in star topology
- Reliable delivery with ACK and automatic retransmission on timeout
- Buffer handling and flushing to prevent residual data corruption
- Flit misalignment detection and automatic reset
- Nodes marked as finished after replying NADA; token skips them
- Session terminates cleanly when all nodes are done
- Per-node serial monitor output for easy debugging
- Priority-based token scheduling
- Error detection (e.g., CRC)
- Fault tolerance (node failure handling, scalable networks)
This project is open-source and available under the GNU General Public License v3.0 (GPLv3).
Developed as an embedded systems and digital communication project.



