i want to read value of windspeed sensor rs485 using esp32 through max485 converter. the schematic of wiring is in the capture below. i tried using the program with modbus master library and the response is 226. and the datasheet of sensor is in link below.
datasheet : datasheet
#include <ModbusMaster.h>
#define MAX485_DE_RE 4
ModbusMaster node;
void preTransmission() {
digitalWrite(MAX485_DE_RE, 1);
}
void postTransmission() {
digitalWrite(MAX485_DE_RE, 0);
}
void setup() {
Serial.begin(115200);
Serial2.begin(4800, SERIAL_8N1, 16, 17); // baud, format, RX, TX
pinMode(MAX485_DE_RE, OUTPUT);
digitalWrite(MAX485_DE_RE, 0);
node.begin(1, Serial2); // Slave ID = 1
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
Serial.println("Start Reading Sensor");
}
void loop() {
uint8_t result;
int16_t windSpeed;
result = node.readHoldingRegisters(0x0000, 1);
if (result == node.ku8MBSuccess) {
windSpeed = node.getResponseBuffer(0); // Signed 16-bit
Serial.print("Windspeed: ");
Serial.println(windSpeed);
} else {
Serial.print("Error: ");
Serial.println(result);
}
delay(1000);
}

