Arduino UNO with wind Direction Sensor (modbus) through RS485 problem

I'm trying to connect to a wind direction sensor via the Arduino Uno.
This sensor supports Modbus protocol. Connect the device to the computer and the modbuspoll software output :

This code:

#include <SoftwareSerial.h> // GitHub - PaulStoffregen/SoftwareSerial: SoftwareSerial library used on Teensy

#define RX 10 //Serial Receive pin
#define TX 11 //Serial Transmit pin
#define RTS_pin 8 //RS485 Direction control
#define RS485Transmit HIGH
#define RS485Receive LOW

SoftwareSerial RS485Serial(RX, TX);

void setup() {

pinMode(RTS_pin, OUTPUT);

Serial.begin(9600);
Serial.println("Anemometer");

// Start the Modbus serial Port, for anemometer
RS485Serial.begin(9600);
delay(1000);
}

void loop() {

digitalWrite(RTS_pin, RS485Transmit); // init Transmit
byte Anemometer_request[] = {0x02, 0x03, 0x00, 0x01, 0x00, 0x02, 0x95, 0xf8}; // inquiry frame
RS485Serial.write(Anemometer_request, sizeof(Anemometer_request));
RS485Serial.flush();

digitalWrite(RTS_pin, RS485Receive); // Init Receive
byte Anemometer_buf[8];
RS485Serial.readBytes(Anemometer_buf, 8);

Serial.print("wind speed : ");
for( byte i=0; i<7; i++ ) {
Serial.print(Anemometer_buf[i],HEX);
Serial.print(" ");
}
Serial.print(" ==> ");
Serial.print(Anemometer_buf[4]);
Serial.print(" m/s");
Serial.println();
delay(1000);

}

This output:

I have a problems : I get error code 83

Provide a link to the datasheet for the sensor.

Your Modbus Poll screen picture shows 6 registers which are presumably 2 bytes in length, so 12 bytes in total.
Your Arduino code only deals with 8 bytes.

Where do you see the error code 83 message, in the Arduino Window or Modbus Poll?

Curious. Everything looks okay, not sure why you get the 83 error response.

Have you trying reading address 1 for 2 words with modpoll to duplicate your software serial request?

I will receive this error code in response to an Arduino request (picture 2)
2 83 3 F1 31 0 0

I put the modbus poll to test the registry address.
I put different addresses in the program, such as 0 to 1 or 1 to 2, and I also changed the crc code but the device sends the same error code

this is my sensor link :

ES106 Weather Station Sensor Datasheet _ WoMaster.pdf (755.8 KB)

By default Modbus Poll uses "base 0" addresses. If you change it to "base 1" to match the documentation you get 02 03 00 00 00 02 C4 38.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.