Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Arduino & Microcontrollers

Arduino RS485 Serial Communication: Long-Distance Data Transfer Tutorial

Arduino RS485 Serial Communication: Long-Distance Data Transfer Tutorial

March 11, 2026 /Posted byJayesh Jain / 0

The Arduino RS485 tutorial you’ve been looking for: a complete guide to implementing reliable, long-distance serial communication between multiple Arduino nodes using the RS485 differential signalling standard. Unlike TTL UART or I2C — which max out at a few metres — RS485 can drive a single twisted-pair cable up to 1200 metres at 100 kbps, or 15 metres at full 10 Mbps. It’s the backbone of industrial automation, SCADA systems, Modbus RTU networks, and multi-room sensor networks. Let’s build one from scratch.

Table of Contents

  • Why RS485? Understanding the Advantages
  • Components Required
  • RS485 Theory: Differential Signalling Explained
  • Wiring the MAX485 Transceiver to Arduino
  • Arduino Code: Master and Slave Nodes
  • Implementing Modbus RTU Protocol
  • Troubleshooting RS485 Networks
  • Frequently Asked Questions

Why RS485? Understanding the Advantages

When a project requires communication between two Arduino boards a few centimetres apart, plain UART TTL works fine. But real-world installations are different: a sensor on a factory floor talks to a controller 50 metres away in a control panel; a weather station at the end of a farm talks to a data logger inside a building; an RS485-based home automation system runs cables through wall conduits across multiple floors.

Here’s how RS485 compares to alternatives:

Standard Max Distance Max Speed Nodes Topology
TTL UART ~1 m 115,200 bps 2 Point-to-point
RS232 15 m 20 kbps 2 Point-to-point
I2C ~1 m (bus cap) 400 kbps 127 Bus
CAN Bus 500 m@1Mbps 1 Mbps 128 Bus
RS485 1200 m 10 Mbps 32–256 Bus/Multidrop

RS485’s key advantages are noise immunity (differential pair cancels common-mode interference), long cable runs, and multidrop topology (many devices share one pair of wires). It’s why Modbus RTU — the most widely used industrial protocol — is built on RS485 at the physical layer.

Recommended: 12V Modbus RTU 1-Channel Relay Module with RS485 MCU for Arduino — A ready-made RS485 slave device with Modbus RTU support. Connect it to your Arduino master and control AC loads over long distances immediately.

Components Required

  • 2× Arduino Uno (or any ATmega328P-based board) — one master, one slave
  • 2× MAX485 or MAX485E transceiver modules (also called RS485 to TTL modules)
  • 1× Twisted-pair cable (CAT5/CAT5e works perfectly — use one pair)
  • 2× 120 Ω termination resistors (for both ends of the bus)
  • Breadboards, jumper wires
  • Optional: 12V power supply for relay modules

The MAX485 IC is available for ₹10–₹20 bare or ₹30–₹60 on a breakout module with headers. Get the module version for easier prototyping — it has the coupling capacitors and LED indicators built in.

RS485 Theory: Differential Signalling Explained

RS485 uses a differential pair — two conductors called A (non-inverting) and B (inverting). When a logic 1 is transmitted, A is positive relative to B; for logic 0, B is positive relative to A. A receiver detects the voltage difference between A and B, not the absolute voltage.

This matters enormously in noisy industrial environments. An electromagnetic pulse (from a motor starting or a fluorescent light ballast) adds the same noise to both conductors simultaneously. The receiver sees the noise on A and the same noise on B, so the differential voltage (A–B) remains the same. The noise is cancelled — this is common-mode rejection.

RS485 specifies a minimum differential voltage of ±200 mV for reliable detection, with the MAX485 capable of operating correctly with common-mode voltages ranging from –7 V to +12 V. In practice, this means you can run RS485 on inexpensive CAT5e cable through an industrial environment with 24V motors running nearby and still get reliable communication.

Half-Duplex vs Full-Duplex RS485

The MAX485 uses half-duplex operation — transmit and receive share the same wire pair but cannot happen simultaneously. The DE (Driver Enable) and RE (Receiver Enable) pins control direction:

  • DE HIGH + /RE HIGH → Transmit mode (driver active, receiver disabled)
  • DE LOW + /RE LOW → Receive mode (receiver active, driver tri-stated)

In most designs, DE and /RE are tied together to a single Arduino pin: HIGH to transmit, LOW to receive. This is the approach we’ll use below.

Wiring the MAX485 Transceiver to Arduino

MAX485 Module Pinout

MAX485 Pin Arduino Pin Description
VCC 5V Power supply
GND GND Ground (also connect cable shield here)
DI (Driver In) Pin 1 (TX) Arduino UART transmit → RS485 input
RO (Receiver Out) Pin 0 (RX) RS485 output → Arduino UART receive
DE + /RE (tied) Pin 2 Direction control: HIGH=TX, LOW=RX
A (non-inverting) — Bus wire A Connect all nodes’ A together
B (inverting) — Bus wire B Connect all nodes’ B together

Termination: Place a 120 Ω resistor between A and B at each end of the bus. If you have 5 nodes spread over 100 metres, the termination goes at the two physical ends of the cable — not at every node. For short prototype cables under 1 metre, termination is optional but harmless.

Recommended: 12V Modbus RTU 4-Channel Relay Module with RS485 MCU for Arduino — Add industrial-grade RS485 relay control to your network. This module acts as a Modbus slave, controllable from your Arduino master over the RS485 bus.

Arduino Code: Master and Slave Nodes

We’ll use a simple custom protocol: the master sends a request frame, the slave replies. Each frame starts with a node address byte, a command byte, data bytes, and a checksum.

Master Sketch

// RS485 Master — Arduino Uno
#include <SoftwareSerial.h>

#define RS485_DIR_PIN 2
#define DE_RE_TX HIGH
#define DE_RE_RX LOW
#define SLAVE_ADDR 0x01
#define CMD_READ_SENSOR 0x10
#define TIMEOUT_MS 100

// Use hardware Serial for RS485 (Pins 0/1)
// Disconnect RS485 when uploading!

void rs485_send(uint8_t *buf, uint8_t len) {
  digitalWrite(RS485_DIR_PIN, DE_RE_TX);
  delayMicroseconds(50); // Driver enable settling
  Serial.write(buf, len);
  Serial.flush(); // Wait for TX complete
  delayMicroseconds(50);
  digitalWrite(RS485_DIR_PIN, DE_RE_RX);
}

uint8_t checksum(uint8_t *buf, uint8_t len) {
  uint8_t sum = 0;
  for (uint8_t i = 0; i < len; i++) sum += buf[i];
  return ~sum + 1; // Two's complement
}

bool rs485_request_sensor(uint8_t addr, float *temperature) {
  uint8_t req[4];
  req[0] = addr;
  req[1] = CMD_READ_SENSOR;
  req[2] = 0x00; // No payload
  req[3] = checksum(req, 3);
  rs485_send(req, 4);

  // Wait for response: [addr][status][temp_hi][temp_lo][checksum] = 5 bytes
  unsigned long start = millis();
  while (Serial.available() < 5) {
    if (millis() - start > TIMEOUT_MS) return false;
  }
  uint8_t resp[5];
  Serial.readBytes(resp, 5);
  if (resp[0] != addr || resp[1] != 0x00) return false;
  // Verify checksum
  uint8_t calc_cs = checksum(resp, 4);
  if (resp[4] != calc_cs) return false;
  int16_t raw = ((int16_t)resp[2] << 8) | resp[3];
  *temperature = raw / 100.0;
  return true;
}

void setup() {
  pinMode(RS485_DIR_PIN, OUTPUT);
  digitalWrite(RS485_DIR_PIN, DE_RE_RX);
  Serial.begin(9600); // RS485 baud rate
  // Optional second serial for debug:
  // Use SoftwareSerial on pins 10/11 for Serial Monitor
}

void loop() {
  float temp;
  if (rs485_request_sensor(SLAVE_ADDR, &temp)) {
    // Send to debug serial / LCD
    // Debug: Serial.println(temp);
  }
  delay(2000);
}

Slave Sketch

// RS485 Slave — Node Address 0x01
#define RS485_DIR_PIN 2
#define MY_ADDR 0x01
#define CMD_READ_SENSOR 0x10
#define LM35_PIN A0

uint8_t checksum(uint8_t *buf, uint8_t len) {
  uint8_t sum = 0;
  for (uint8_t i = 0; i < len; i++) sum += buf[i];
  return ~sum + 1;
}

void rs485_send(uint8_t *buf, uint8_t len) {
  digitalWrite(RS485_DIR_PIN, HIGH);
  delayMicroseconds(50);
  Serial.write(buf, len);
  Serial.flush();
  delayMicroseconds(50);
  digitalWrite(RS485_DIR_PIN, LOW);
}

void handle_request(uint8_t cmd) {
  if (cmd == CMD_READ_SENSOR) {
    int raw = analogRead(LM35_PIN);
    float voltage = raw * (5.0 / 1023.0);
    float temp_c = voltage * 100.0; // LM35: 10mV/°C
    int16_t temp_int = (int16_t)(temp_c * 100); // 0.01°C resolution
    uint8_t resp[5];
    resp[0] = MY_ADDR;
    resp[1] = 0x00; // OK
    resp[2] = (temp_int >> 8) & 0xFF;
    resp[3] = temp_int & 0xFF;
    resp[4] = checksum(resp, 4);
    rs485_send(resp, 5);
  }
}

void setup() {
  pinMode(RS485_DIR_PIN, OUTPUT);
  digitalWrite(RS485_DIR_PIN, LOW); // Default: receive
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() >= 4) {
    uint8_t buf[4];
    Serial.readBytes(buf, 4);
    // Verify address and checksum
    if (buf[0] != MY_ADDR) return;
    uint8_t cs = checksum(buf, 3);
    if (buf[3] != cs) return;
    handle_request(buf[1]);
  }
}
Recommended: LM35 Temperature Sensors — Use these reliable analog temperature sensors on your RS485 slave nodes. The linear 10 mV/°C output integrates perfectly with the slave code above.

Implementing Modbus RTU Protocol

For production systems and interoperability with commercial PLCs, HMIs, and SCADA software, implement Modbus RTU instead of a custom protocol. Modbus RTU is a well-defined standard that defines register addressing, function codes, and CRC error checking.

Modbus RTU Frame Structure

Every Modbus RTU frame consists of:

  1. Address (1 byte): Slave node address (1–247)
  2. Function Code (1 byte): 0x03 = Read Holding Registers, 0x06 = Write Single Register, etc.
  3. Data (N bytes): Register address, register count, or value depending on function code
  4. CRC (2 bytes): 16-bit CRC-16 (Modbus polynomial 0x8005)

Use the ModbusMaster library (for Arduino acting as master) or Modbus-Arduino library (for slave role). Install via Arduino IDE Library Manager: search “ModbusMaster” by Doc Walker.

Example Modbus master reading 2 registers from slave 1:

#include <ModbusMaster.h>
ModbusMaster node;

void preTransmission() { digitalWrite(2, HIGH); }
void postTransmission() { digitalWrite(2, LOW); }

void setup() {
  Serial.begin(9600);
  node.begin(1, Serial); // Slave ID 1
  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);
}

void loop() {
  uint8_t result = node.readHoldingRegisters(0x00, 2);
  if (result == node.ku8MBSuccess) {
    uint16_t reg0 = node.getResponseBuffer(0);
    uint16_t reg1 = node.getResponseBuffer(1);
  }
  delay(1000);
}

Troubleshooting RS485 Networks

No Communication at All

  • Check DE/RE wiring — most common mistake is inverting these signals
  • Verify baud rate matches on all nodes (default 9600 for beginners)
  • Disconnect and reconnect the RS485 module (check RO → Arduino RX, DI → Arduino TX)
  • Ensure common ground between master and slave (even with differential signalling, ground reference matters for the IC’s internal rails)

Garbled Data

  • Add termination resistors (120 Ω) at both ends of the bus
  • Reduce baud rate — start at 9600, work up to 115200 as the installation proves stable
  • Check for ground loops — separate cable shields properly
  • Add a 560 Ω pull-up on A and pull-down on B to define idle bus state

Works Close, Fails at Distance

  • Use proper twisted-pair cable — untwisted wires lose differential noise rejection
  • Reduce baud rate (lower baud = longer distance)
  • Separate RS485 cable from power cables (especially VFD motor cables)
  • Check that all nodes share a common signal ground reference
Recommended: Arduino Nano Every with Headers — The Nano Every with its ATmega4809 is excellent for RS485 slave nodes — it has two UART interfaces (one for RS485, one for debug) and fits in tight enclosures.

Frequently Asked Questions

Can I connect more than 2 Arduino boards on an RS485 bus?

Yes. Standard RS485 transceivers like the MAX485 support up to 32 unit loads (nodes) on a single bus. With 1/8 unit-load transceivers (like MAX3485), you can connect up to 256 nodes. All share the same two-wire bus using a master-slave protocol where only one node transmits at a time.

What is the maximum cable length for RS485?

The RS485 standard specifies a maximum cable length of 1200 metres (4000 feet) at 100 kbps. At higher baud rates, the distance is shorter: roughly 15 metres at 10 Mbps. For most Arduino projects, you’ll never hit this limit — 500 metres at 9600 baud is very achievable with quality twisted-pair cable.

Why do I need termination resistors?

Termination resistors (120 Ω) match the characteristic impedance of the cable and absorb signal reflections at the end of the line. Without them, transmitted pulses reflect back down the cable and interfere with subsequent bits, causing data corruption. For cable runs under 10 metres at baud rates under 100 kbps, you can often skip termination — but it’s good practice to include it.

Can RS485 be used with 3.3V Arduino boards?

Yes. The MAX3485 is a 3.3V-compatible variant of the MAX485. For 5V MAX485 modules connected to 3.3V boards like the Arduino Nano 33 IoT, use a level shifter on the DI (data in) and DE/RE lines — the RO (receiver output) from MAX485 at 5V can usually be connected directly to 3.3V Arduino inputs since most AVR and ARM inputs are 5V-tolerant, but verify your specific board’s datasheet first.

What is Modbus RTU and how does it differ from plain RS485?

RS485 is the physical layer standard (the electrical specification for the cable and signals). Modbus RTU is an application-layer protocol that runs on top of RS485. RS485 defines how bits are transmitted; Modbus RTU defines how nodes address each other, read/write registers, handle errors, and format response frames. A custom protocol like the one in our code above also runs on RS485 — Modbus is just a standardised version that commercial devices understand.

Conclusion

Arduino RS485 communication unlocks a whole class of projects that TTL UART simply cannot reach — multi-node sensor networks, industrial control systems, long-distance data loggers, and Modbus RTU compatible installations. The hardware is inexpensive (a MAX485 module costs less than ₹60), the software is straightforward, and the protocol is robust enough for real industrial deployment.

Start with the two-node setup above, verify reliable communication, then expand to a full multi-node network. Add Modbus RTU when you need interoperability with commercial PLCs or SCADA software.

Find all the components you need — Arduino boards, RS485 modules, relay interfaces, and sensors — at Zbotic.in’s Arduino & Microcontrollers collection.

Tags: Arduino RS485, industrial Arduino, long distance data transfer, MAX485, Modbus RTU, serial communication
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Arduino Sleep Modes: Reduce Po...
blog arduino sleep modes reduce power consumption to microamps 594824
blog arduino capacitive touch sensor no hardware needed 594829
Arduino Capacitive Touch Senso...

Related posts

Svg%3E
Read more

Arduino Batch Programming: Flash Multiple Boards Quickly

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Based Radar System with Ultrasonic Sensor

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Automatic Plant Monitor: Sunlight, Moisture, Temperature

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Lie Detector: GSR Sensor Polygraph Project

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading
Svg%3E
Read more

Arduino Metal Detector: Build a Treasure Finder

April 1, 2026 0
Table of Contents Introduction Components and Hardware Setup Wiring Diagram and Connections Complete Code with Explanation Customization and Improvements Troubleshooting... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now