The RS-485 module is a communication device that adheres to the RS-485 serial communication standard. It is designed for long-distance data transmission over a differential twisted pair cable, allowing multiple devices to communicate with each other in a network. This module is commonly used in industrial environments, building automation, and other applications where a robust and reliable communication link is required.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply input (3.3V to 5V) |
2 | A | Non-inverting receiver input and driver output |
3 | B | Inverting receiver input and driver output |
4 | GND | Ground reference for power and signals |
5 | RO | Receiver output |
6 | RE | Receiver enable (active low) |
7 | DE | Driver enable (active high) |
8 | DI | Driver input |
Q: Can I connect more than 32 devices to an RS-485 bus?
Q: What is the maximum distance I can achieve with RS-485?
Q: Can RS-485 modules be used for full-duplex communication?
#include <SoftwareSerial.h>
// RS-485 Module connection pins
#define RO_PIN 10
#define DI_PIN 11
#define RE_DE_PIN 12
SoftwareSerial rs485(RO_PIN, DI_PIN); // RX, TX
void setup() {
// Initialize RS-485 communication
rs485.begin(9600);
pinMode(RE_DE_PIN, OUTPUT);
digitalWrite(RE_DE_PIN, LOW); // Enable receiver by default
}
void loop() {
// To transmit data
digitalWrite(RE_DE_PIN, HIGH); // Enable transmitter
rs485.write("Hello RS-485");
digitalWrite(RE_DE_PIN, LOW); // Disable transmitter to receive data
// To receive data
if (rs485.available()) {
String received = rs485.readString();
// Process received data
}
// Add a delay between transmissions
delay(1000);
}
Note: The example code provided is for illustrative purposes and may require modifications to work with specific RS-485 modules and Arduino boards. Always refer to the module's datasheet and the Arduino's documentation for accurate pin assignments and configurations.