Codey OnlineArduino- & ESP32-Komponentenbibliothek › MAX485 TTL to RS485 Converter Module
MAX485 TTL to RS485 Converter Module
Kommunikation

MAX485 TTL to RS485 Converter Module

Das MAX485-Modul ist ein halbduplexer RS-485-Transceiver, der TTL-UART-Signale in einen differentiellen RS-485-Bus umwandelt und umgekehrt. Es wird häufig für robuste serielle Kommunikation über längere Kabel und in störungsreichen Umgebungen verwendet, mit Logik-Pins zur Sende-/Empfangssteuerung und A/B-Anschlüssen auf der Busseite.

Breite: 41.2 mm

Pinbelegung — MAX485 TTL to RS485 Converter Module

Pin Signal Beschreibung
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.

Beispielschaltplan — MAX485 TTL to RS485 Converter Module

Von Nach Kabel
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

Arduino-Beispielcode — MAX485 TTL to RS485 Converter Module

Dieses Beispiel wurde für das arduino-uno geschrieben und kompiliergeprüft. Codey Online passt es für jedes andere unterstützte Board an.

// 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);
  }
}

Ähnliche Komponenten

Logic Level Shifter 4-channel

Logic Level Shifter 4-channel

Logic Level Shifter 8-channel

Logic Level Shifter 8-channel

Bau dein Arduino- oder ESP32-Projekt mit AI

Beschreib einfach, was du bauen willst. Codey Online schreibt den Code, zeichnet den Schaltplan, kompiliert alles und flasht dein Board direkt aus dem Browser.

Kostenlos starten