Hi all,
I have an Opta RS485. With or without anything connected to the RS485 terminals I get an echo back using the following code:
#include <ArduinoRS485.h>
// RS485
constexpr auto baudrate{ 9600 };
// Calculate preDelay and postDelay in microseconds for stable RS-485 transmission
constexpr auto bitduration{ 1.f / baudrate };
constexpr auto wordlen{ 9.6f }; // OR 10.0f depending on the channel configuration
constexpr auto preDelayBR{ bitduration * wordlen * 3.5f * 1e6 };
constexpr auto postDelayBR{ bitduration * wordlen * 3.5f * 1e6 };
void setup() {
Serial.begin(115200);
// RS485 init
RS485.begin(baudrate);
RS485.setDelays(preDelayBR, postDelayBR);
// Enable data reception
RS485.receive();
}
void loop(){
String val = "";
Serial.println("Sending: 0XA;G0?");
RS485.beginTransmission();
RS485.println("0XA;G0?");
RS485.endTransmission();
if (RS485.available()) {
auto peeked = RS485.peek();
while (peeked != -1) {
char c;
uint8_t b = RS485.read();
c = (char)b;
val += c;
peeked = RS485.peek();
}
}
Serial.print("Received: ");
Serial.println(val);
delay(1000);
}
Has anyone come across anything similar?
Yes, post your annotated schematic be sure to show all connections, power, ground, power sources and any additional components in the systemn
Hi, thank you - bare Arduino Opta, no wires attached, only USB-C connected for serial and power.
Without spending an hour looking at the data sheet it runs in half duplex, I will take a SWAG and say it is monitoring its own transmission as part of the hardware design and possibly an error detection scheme. Look at the following drawing:

From this we can see it is a differential bus, and can only allow one device to talk at a time without causing errors. With the transceivers you separately enable TX and Rx to the bus.
1 Like
Ah okay, thank you! I seemed to have resolved the issue then by adding RS485.noReceive();
and RS485.receive();
around the the transmission.
This is the complete code:
#include <ArduinoRS485.h>
// RS485
constexpr auto baudrate{ 9600 };
// Calculate preDelay and postDelay in microseconds for stable RS-485 transmission
constexpr auto bitduration{ 1.f / baudrate };
constexpr auto wordlen{ 9.6f }; // OR 10.0f depending on the channel configuration
constexpr auto preDelayBR{ bitduration * wordlen * 3.5f * 1e6 };
constexpr auto postDelayBR{ bitduration * wordlen * 3.5f * 1e6 };
void setup() {
Serial.begin(115200);
// RS485 init
RS485.begin(baudrate);
RS485.setDelays(preDelayBR, postDelayBR);
}
void loop(){
String val = "";
Serial.println("Sending: 0XA;G0?");
RS485.noReceive();
RS485.beginTransmission();
RS485.println("0XA;G0?");
RS485.endTransmission();
RS485.receive();
if (RS485.available()) {
auto peeked = RS485.peek();
while (peeked != -1) {
char c;
uint8_t b = RS485.read();
c = (char)b;
val += c;
peeked = RS485.peek();
}
}
Serial.print("Received: ");
Serial.println(val);
delay(1000);
}