Codey OnlineArduino & ESP32 component library › MAX485 TTL to RS485 Converter Module
MAX485 TTL to RS485 Converter Module
Communication

MAX485 TTL to RS485 Converter Module

The MAX485 module is a half-duplex RS-485 transceiver that converts TTL UART signals to a differential RS-485 bus and back. It is commonly used for robust serial communication over longer cables and noisy environments, with logic-side pins for transmit/receive control and bus-side A/B connections.

Width: 41.2 mm

Pinout — MAX485 TTL to RS485 Converter Module

Pin Signal Description
RO RX TTL receiver output from RS-485 bus — connect to MCU UART RX.
RE enable Active-low receiver enable — pull low to receive RS-485 data.
DE enable Driver enable — drive high to transmit onto the RS-485 bus.
DI TX TTL driver input — connect to MCU UART TX for RS-485 transmit data.
VCC power Module logic power input, typically 5V for the MAX485 transceiver.
B CAN-L RS-485 differential bus line B, commonly the inverting/negative line.
A CAN-H RS-485 differential bus line A, commonly the non-inverting/positive line.
GND ground Ground reference for module power and TTL interface.

Example wiring diagram — MAX485 TTL to RS485 Converter Module

From To Wire
board:5V x1:VCC red
board:GND x1:GND black
board:D3 x1:DI green
board:D2 x1:RO blue
board:D4 x1:DE yellow
board:D4 x1:RE purple
x1:A board:D0 cyan
x1:B board:D1 magenta

Example Arduino code — MAX485 TTL to RS485 Converter Module

This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.

// MAX485 TTL to RS-485 Converter Module
// Arduino Uno example using SoftwareSerial (Uno has no Serial1).
// Wiring used:
// Arduino 5V  -> VCC
// Arduino GND -> GND
// Arduino D3  -> DI
// Arduino D2  -> RO
// Arduino D4  -> DE and RE (tied together)
// RS-485 bus A -> Arduino D0
// RS-485 bus B -> Arduino D1

#include <SoftwareSerial.h>

const byte PIN_RO = 2;
const byte PIN_DI = 3;
const byte PIN_DE_RE = 4;

// SoftwareSerial(rx, tx)
SoftwareSerial rs485(PIN_RO, PIN_DI);

void rs485Transmit(const char *text) {
  digitalWrite(PIN_DE_RE, HIGH);  // Enable transmitter, disable receiver
  delay(2);

  rs485.print(text);
  rs485.print('\n');
  rs485.flush();

  delay(2);
  digitalWrite(PIN_DE_RE, LOW);   // Return to receive mode
}

void setup() {
  pinMode(PIN_RO, INPUT);
  pinMode(PIN_DI, OUTPUT);
  pinMode(PIN_DE_RE, OUTPUT);
  digitalWrite(PIN_DE_RE, LOW);   // Start in receive mode

  Serial.begin(9600);
  rs485.begin(9600);

  Serial.println("MAX485 RS-485 example started.");
  Serial.println("Type a line in the Serial Monitor and press Send.");
  Serial.println("The Arduino will transmit it over RS-485.");
}

void loop() {
  // Send anything typed in the Serial Monitor to the RS-485 bus.
  if (Serial.available()) {
    String line = Serial.readStringUntil('\n');
    line.trim();
    if (line.length() > 0) {
      Serial.print("Transmitting: ");
      Serial.println(line);
      rs485Transmit(line.c_str());
    }
  }

  // Print any received RS-485 bytes to the USB Serial Monitor.
  while (rs485.available()) {
    char c = (char)rs485.read();
    Serial.print(c);
  }
}

Related components

Logic Level Shifter 4-channel

Logic Level Shifter 4-channel

Logic Level Shifter 8-channel

Logic Level Shifter 8-channel

Build your Arduino or ESP32 project with AI

Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.

Start for free