Arduino Opta RS-485 Port Issue - Constant Timeout, Fails Loopback Test

Hi everyone,

I'm hoping for some help diagnosing a persistent issue with my new Arduino Opta WiFi. I'm trying to communicate with a wind direction sensor via Modbus RTU, but I'm consistently getting a timeout error. I believe I have exhausted all standard troubleshooting steps and suspect a hardware failure.

Main Code (Opta as Modbus Client)

This is the primary code I am using on the Opta, which results in a timeout. It uses the official ArduinoModbus library and is configured according to the sensor's datasheet (9600 bps, 8N1, Slave ID 1, Register 0x0017).

#include <ArduinoModbus.h>
#include <ArduinoRS485.h>

#define SLAVE_ID 1
#define BAUD_RATE 9600
#define SERIAL_CONFIG SERIAL_8N1
#define WIND_DIRECTION_REG 0x0017

void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println("--- Modbus RTU Client for Opta + Wind Sensor ---");

  pinMode(LEDB, OUTPUT); // Blue LED for diagnostics
  digitalWrite(LEDB, LOW);

  if (!ModbusRTUClient.begin(BAUD_RATE, SERIAL_CONFIG)) {
    Serial.println("Failed to start Modbus RTU Client!");
    while (1);
  }
}

void loop() {
  digitalWrite(LEDB, HIGH); // LED ON to indicate a request is being sent
  
  Serial.print("Requesting data from slave 1, register 0x0017... ");

  if (!ModbusRTUClient.requestFrom(SLAVE_ID, HOLDING_REGISTERS, WIND_DIRECTION_REG, 1)) {
    digitalWrite(LEDB, LOW);
    Serial.print("Error! Description: ");
    Serial.println(ModbusRTUClient.lastError());
  } else {
    digitalWrite(LEDB, LOW);
    if (ModbusRTUClient.available()) {
      uint16_t value = ModbusRTUClient.read();
      Serial.print("Success! Value: 0x");
      Serial.println(value, HEX);
    } else {
      Serial.println("Request successful, but no data in response.");
    }
  }

  delay(2000);
}

Diagnostic Steps & Results

To isolate the issue, I performed the following tests.

1. Baseline Test (R4 Works Perfectly)

  • Setup: Arduino R4 + external RS485 converter + the sensor.

  • Result: This setup works 100% correctly. I can read the wind direction from register 0x0017 without any issues.

  • Conclusion: This confirms the sensor, its Modbus parameters, and the general program logic are all correct.

2. Loopback Test on the Opta (FAILED)

  • Method: I disconnected the sensor and shorted the A(-) and B(+) terminals on the Opta with a wire. The Opta was powered by the 12V PSU.

  • Result: TEST FAILED. The Opta is unable to receive the data it sends itself. The serial monitor consistently shows ERROR! No response received.

#include <ArduinoRS485.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println("--- RS-485 Loopback Test ---");
  RS485.begin(9600);
}

void loop() {
  Serial.print("Sending: PING...");
  RS485.print("PING\n");
  delay(100);

  String received = "";
  RS485.receive();
  while (RS485.available()) {
    received += (char)RS485.read();
  }
  RS485.noReceive();

  if (received.length() > 0) {
    Serial.print(" Received: ");
    Serial.println(received);
  } else {
    Serial.println(" ERROR! No response received.");
  }
  delay(3000);
}

3. Opta (as Slave) vs. a known-good R4 (as Master) Test (FAILED)

  • Method: I used my working R4 setup as a Modbus Master to poll the Opta, which was configured as a Modbus Slave. All devices shared a common ground.

  • Result: TEST FAILED. The R4 master reports a Timeout. The Opta slave correctly waits for a request (confirmed on its serial monitor) but never receives it. This was tested with A/B lines in both orientations.


You need to Provide Clear Documentation, Since we can’t see your project, share an annotated schematic (best) or a clear drawing of your setup. Clear Pictures are welcome, but avoid using Fritzing diagrams as they are wiring diagrams, not schematics, and are not ideal for troubleshooting. Also share your code to make it easier to find your problem.

Thanks for the helpful feedback on my post. I've updated it with the code and schematic to make it clearer. I appreciate the guidance!

You can't do a loopback on RS485 like that, you need to use two RS485 ports to do a loopback. Hopefully you have not damaged the OPTA by shorting those pins.

Fritzing diagrams are fine

and it doesn't work

Did you connect a 120 ohm terminating resistor between A and B

Have you tried the server code in this tutorial?
https://docs.arduino.cc/tutorials/opta/getting-started-with-modbus-rtu/

yes

I'll order it and see. I thought that since I have a short cable, I wouldn't need it.

Maybe not for the R4 to OPTA test but you should have it if the wind sensor is on a long cable.

I don't have a OPTA so I can't help with any further debugging.

Without the information requested in my post #2 I can not be of much help. Good Luck!

I'm new here, so I'm not entirely sure what else to add. If you could explain it to a new user, I'd be grateful.

Start with an annotated schematic. Be sure it is exactly how you have wired your project.

An electronic schematic is a graphical representation of an electrical circuit that uses symbols to represent components and lines to show how they are connected. It serves as a blueprint for designing, building, and troubleshooting electronic systems.

I simply connected the cable marked B to B on the Arduino and A to A, GND to GND, and everything to a 12V 3A power supply.

That does not sound correct as if you placed 12V on the processor you would have fried it. A and B on what to what?

B on opta to B from my sensor, and A on opta to A from my sensor. I connected the sensor to 12v, and the optical cable instead of USB-C is from normal 12v cables.

Chances are high, you have to invert them. Standard calls A- but most devices use A+

Without the schematic I cannot help you, Good Luck!