Encomendado em dias úteis antes das 14:00 = enviado no mesmo dia e, em 98% dos casos, entregue no dia seguinte. Devolução gratuita 30 dias para refletir 1 ano de garantia

Esquema de ligação e exemplo de código

Como ligar o Módulo Conversor MAX485 TTL para RS485 a um Arduino UNO ou ESP32, com um sketch de exemplo que podes carregar já.

MAX485 RS-485 Transceiver Communication

This circuit interfaces an Arduino Uno with an RS-485 differential bus using the MAX485 transceiver. SoftwareSerial handles communication with the module, while digital pins control transmit and receive modes. Any message typed into the Serial Monitor is transmitted over RS-485, and incoming bus data is printed to the screen.

Esquema de ligação: Módulo Conversor MAX485 TTL para RS485 num Arduino UNO
Esquema de ligação · Clique para ampliar
Tabela de ligação: Módulo Conversor MAX485 TTL para RS485 num Arduino UNO
Tabela de ligação · Clique para ampliar
MAX485_RS_485_Transceiver_Communication.ino · compilado e testado
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : MAX485 RS-485 Transceiver Communication
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : MAX485 TTL to RS485 Converter Module
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <SoftwareSerial.h>

const byte PIN_RO = 2;   // Receiver Out (RX)
const byte PIN_DI = 3;   // Driver In (TX)
const byte PIN_DE = 4;   // Driver Enable (Active HIGH)
const byte PIN_RE = 5;   // Receiver Enable (Active LOW)

SoftwareSerial rs485(PIN_RO, PIN_DI);

unsigned long lastSend = 0;
int packetCount = 0;

void setTransmitMode() {
  digitalWrite(PIN_RE, HIGH); // Disable receiver
  digitalWrite(PIN_DE, HIGH); // Enable driver
  delayMicroseconds(50);
}

void setReceiveMode() {
  digitalWrite(PIN_DE, LOW);  // Disable driver
  digitalWrite(PIN_RE, LOW);  // Enable receiver
  delayMicroseconds(50);
}

void rs485Send(const String &msg) {
  setTransmitMode();
  rs485.println(msg);
  rs485.flush();
  setReceiveMode();
}

void setup() {
  pinMode(PIN_DE, OUTPUT);
  pinMode(PIN_RE, OUTPUT);
  setReceiveMode();

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

  Serial.println(F("MAX485 RS-485 Transceiver Demo"));
  Serial.println(F("Type a message and press Enter to send over RS-485."));
}

void loop() {
  // Forward incoming Serial Monitor input to RS-485
  if (Serial.available()) {
    String input = Serial.readStringUntil('\n');
    input.trim();
    if (input.length() > 0) {
      Serial.print(F("Sending: "));
      Serial.println(input);
      rs485Send(input);
    }
  }

  // Forward received RS-485 data to Serial Monitor
  if (rs485.available()) {
    Serial.print(F("Received: "));
    while (rs485.available()) {
      char c = (char)rs485.read();
      Serial.print(c);
      delay(2);
    }
    Serial.println();
  }

  // Automatically send a heartbeat packet every 5 seconds
  if (millis() - lastSend >= 5000) {
    lastSend = millis();
    packetCount++;
    String packet = "Ping #" + String(packetCount);
    Serial.print(F("Auto-transmitting: "));
    Serial.println(packet);
    rs485Send(packet);
  }
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

MAX485 RS-485 Communication with ESP32

This project demonstrates sending and receiving data over an RS-485 bus using the MAX485 module and ESP32 UART2. The ESP32 switches the DE/RE pins HIGH to transmit a periodic heartbeat message and sets them LOW to listen for incoming RS-485 packets. A simple 1kΩ/2kΩ voltage divider safely drops the 5V TTL output (RO) of the module to 3.3V for the ESP32 RX pin.

Esquema de ligação: Módulo Conversor MAX485 TTL para RS485 num ESP32 DevKit V1
Esquema de ligação · Clique para ampliar
Tabela de ligação: Módulo Conversor MAX485 TTL para RS485 num ESP32 DevKit V1
Tabela de ligação · Clique para ampliar
MAX485_RS_485_Communication_with_ESP32.ino · compilado e testado
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : MAX485 RS-485 Communication with ESP32
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : MAX485 TTL to RS485 Converter Module
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

// MAX485 TTL to RS-485 transceiver demo with ESP32

const int CONTROL_PIN = 4; // Controls DE and RE (HIGH = Transmit, LOW = Receive)
const int RXD2_PIN = 16;
const int TXD2_PIN = 17;

unsigned long lastSendTime = 0;
int messageCount = 0;

void setup() {
  Serial.begin(115200);
  pinMode(CONTROL_PIN, OUTPUT);
  digitalWrite(CONTROL_PIN, LOW); // Start in receive mode

  // Initialize UART2 for RS-485 communication
  Serial2.begin(9600, SERIAL_8N1, RXD2_PIN, TXD2_PIN);

  Serial.println("RS-485 Transceiver Ready");
}

void loop() {
  // Send a message every 2 seconds
  if (millis() - lastSendTime >= 2000) {
    lastSendTime = millis();
    messageCount++;

    // Enable RS-485 transmitter
    digitalWrite(CONTROL_PIN, HIGH);
    delay(10);

    String msg = "Hello from ESP32 #" + String(messageCount);
    Serial2.println(msg);
    Serial2.flush(); // Wait until all outgoing bytes are transmitted

    // Return to receive mode
    digitalWrite(CONTROL_PIN, LOW);

    Serial.print("Sent over RS-485: ");
    Serial.println(msg);
  }

  // Check for incoming RS-485 data
  if (Serial2.available()) {
    Serial.print("Received via RS-485: ");
    while (Serial2.available()) {
      char c = (char)Serial2.read();
      Serial.print(c);
    }
    Serial.println();
  }
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Módulo Conversor MAX485 TTL para RS485

Módulo MAX485 com o chip MAX485, de baixo consumo de energia para comunicação RS-485. O RS485 é usado para comunicação serial a distâncias maiores do que RS232 ou TTL diretas e suporta várias unidades no mesmo barramento.

Especificações do módulo MAX485:
– Funciona em: 5V.
– Ligação onboard para fios RS-485.
– Dimensões: 44mm x 14mm.

Dimensões
Comprimento: 4,39cm
Largura: 1,41cm
Altura: 1,89cm

  • RS-485 communicatie
  • Laag stroomverbruik
  • Onboard aansluiting
  • 44 x 14 mm

Por que escolher este produto?

  • Lange afstand – Geschikt voor communicatie over langere afstanden.
  • Meerdere eenheden – Ondersteunt meerdere eenheden op dezelfde bus.
  • Laag verbruik – Heeft een laag stroomverbruik.
  • Onboard aansluiting – Voor RS-485 draden aanwezig.
Especificações
Largura1,41cm
Tensão de trabalho5V
Comprimento4,39cm
Altura1,89cm

Frequentemente comprados juntos

Total: € 11,85

Avaliações

★★★★★ 4,5/5 2 avaliações
  • ★★★★★Gerrit NijhofCompra verificada

    Parto do princípio de que funciona tão bem quanto o módulo Rs232. Encomendei este módulo 485 para, daqui a algum tempo, ligar um inversor híbrido easun a um arduino. Portanto, ainda não o utilizei.

  • ★★★★★AnoniemCompra verificada

    Padrão, o que há para dizer sobre isso?

Escrever uma avaliação
A tua avaliação

Envio & devoluções

Envio

  • Pacote com Track & Trace€ 6,20Alemanha 1-3, França 2-3, Espanha/Itália 2-4, outros países 3-5 dias úteis
  • Pacote com Track & Trace€ 7,35Alemanha 1-3, França 2-3, Espanha/Itália 2-4, outros países 3-5 dias úteis
  • Pacote com Track & Trace€ 8,50Alemanha 1-3, França 2-3, Espanha/Itália 2-4, outros países 3-5 dias úteis
  • Pacote com Track & Trace€ 9,15Alemanha 1-3, França 2-3, Espanha/Itália 2-4, outros países 3-5 dias úteis
Tudo sobre envios

Devoluções

Não ficas satisfeito? Tens 30 dias após a receção para devolver o produto.

Tudo sobre devoluções

Vistos recentemente