This guide provides step-by-step instructions for setting up the hardware communication examples in this repository.
- 2× Arduino Uno boards
- 1× 10kΩ Potentiometer
- 1× I2C LCD Display (16x2)
- 2× 4.7kΩ Pull-up resistors
- Breadboard and jumper wires
- USB cables for programming
- 1× Arduino Mega 2560
- 1× Arduino Uno
- Jumper wires for serial connections
- USB cables for programming
- LED for testing (optional)
- 1× Arduino Mega 2560
- 1× Ethernet Shield (W5100 or W5500)
- Ethernet cable
- Router/Switch with available ports
- Computer for client testing
- Arduino IDE (version 1.8.19 or later) OR PlatformIO
- Required Libraries:
Wire.h(built-in)SoftwareSerial.h(built-in)Adafruit_LiquidCrystal.hEthernet.h(for Arduino Ethernet library)SPI.h(built-in)
- Download and install Arduino IDE from arduino.cc
- Install required libraries:
- Go to Tools > Manage Libraries
- Search for "Adafruit LiquidCrystal" and install
- Search for "Ethernet" and install Arduino Ethernet library
- Install PlatformIO IDE or VS Code extension
- Open the project directories containing
platformio.ini - Libraries will be automatically downloaded during first build
Master Arduino (Uno): Slave Arduino (Uno):
A0 → Potentiometer middle A4 → LCD SDA
A4 → Slave A4 (SDA) A5 → LCD SCL
A5 → Slave A5 (SCL) GND → LCD GND
5V → Pull-up resistors 5V → LCD VCC
GND → Common ground I2C Address: 4
Same as above, but slave address = 9
Arduino Mega: Arduino Uno:
Serial1 TX (Pin 18) → Pin 2 (SoftwareSerial RX)
Serial1 RX (Pin 19) ← Pin 3 (SoftwareSerial TX)
GND → GND
Pin 13 → LED (optional)
Arduino Mega + Ethernet Shield:
- Mount Ethernet shield on Mega
- Connect Ethernet cable to shield
- Connect to same network as computer
- Default IP: 192.168.31.177
-
I2C Communication:
- Open
baseI2C/bytewise/master_arduino.cpporbyteshift/master_arduino.cpp - Select Tools > Board > Arduino Uno
- Select correct COM port
- Upload to first Arduino (Master)
- Open corresponding
slave_arduino.cpp - Upload to second Arduino (Slave)
- Open
-
UART Communication:
- Open
baseUART/arduino-communication-mega/src/main.cpp - Select Tools > Board > Arduino Mega
- Upload to Arduino Mega
- Open
baseUART/arduino-communication/src/main.cpp - Select Tools > Board > Arduino Uno
- Upload to Arduino Uno
- Open
-
TCP/IP Communication:
- Open
baseTCP_IP/tcp_ip-arduino_mega_uart/src/main.cpp - Select Tools > Board > Arduino Mega
- Upload to Arduino Mega with Ethernet Shield
- Open
- Navigate to project directory containing
platformio.ini - Run:
pio runto build - Run:
pio run --target uploadto upload - Specify upload port if needed:
pio run --target upload --upload-port COM3
-
Hardware Check:
- Verify all connections match wiring diagrams
- Check pull-up resistors are connected
- Confirm power connections (5V, GND)
-
Software Testing:
- Open Serial Monitor (9600 baud) for both boards
- Rotate potentiometer on master
- Verify values appear on slave LCD and serial output
- Expected range: 0-255 (bytewise) or 0-1023 (byteshift)
-
Hardware Check:
- Verify TX/RX connections (crossed)
- Confirm common ground connection
- Check LED connection to pin 13
-
Software Testing:
- Open Serial Monitor for both boards (9600 baud)
- Send data through Mega's serial monitor
- Verify command reception and LED control on Uno
- Check for "checksum valid" messages
-
Network Check:
- Verify Ethernet cable connection
- Confirm network settings match local subnet
- Check Arduino gets IP address (serial monitor output)
-
Software Testing:
- Use telnet client:
telnet 192.168.31.177 23 - Compile and run C++ client applications
- Verify data transmission over network
- Check for connection status messages
- Use telnet client:
- No communication: Check pull-up resistors and wiring
- Garbled LCD: Verify LCD address and power connections
- Intermittent data: Check for loose connections
- No data received: Verify baud rates match (9600)
- Corrupted data: Check TX/RX wiring (must be crossed)
- Commands not working: Verify checksum values in code
- No network connection: Check Ethernet cable and network settings
- IP conflicts: Use unique IP address for local network
- Connection refused: Verify port 23 is not blocked
// In slave code, change address:
Wire.begin(4); // Change number for different address// Change in both master and slave:
Serial1.begin(9600); // Master
CommandSerialCom.begin(9600); // Slave// Modify in TCP/IP code:
IPAddress ip(192, 168, 1, 100); // New IP address
IPAddress gateway(192, 168, 1, 1); // Gateway
IPAddress subnet(255, 255, 255, 0); // Subnet mask- Baud Rate: 9600
- Line Ending: Both NL & CR
- Enable timestamps for debugging
I2C Master:
Potentiometer: 512
Transmitted: 128
I2C Slave:
Received: 128
Display value: 512
UART Communication:
Command received: ID=1, Data=1, Checksum=1
LED State: ON
TCP/IP Communication:
Network initialized: 192.168.31.177
New client connected
Data transmitted: 22 bytes
- Use different I2C addresses (0-127)
- Add more sensors or actuators
- Implement I2C multiplexing for many devices
- Add more command types
- Implement bidirectional communication
- Add error correction codes
- Implement UDP for real-time data
- Add web server functionality
- Integrate with IoT platforms
This setup guide ensures successful implementation of all communication protocols in the repository.