RS485 Modbus Arduino Uno Reading Wind sensor

I have a question if anyone would be willing to help me. I am learning ModBus and Arduino IDE, so I am still pretty new. I am currently trying to read a wind sensor for my internship through a Modbus protocol they use for it. I have a Metro adafruit (similar to Arduino Uno) with an ATmega328 processor. I'm using a DSD TECH SH-U12 RS485 to TTL 5V Board with MAX13487 chip for the communication between the wind sensor and the metro board. Most people that i have asked for help on this have recommend reading up on modbus. I have done a considerable amount of research, but I'm still not understanding how i can correlate the knowledge to an Arduino library via the Arduino ide. I'm trying to use ModbusMaster library with Arduino IDE (ModbusMaster: Modbus Function Codes for Holding/Input Registers) library for the coding. All I'm trying to do is read registers I don't need to write anything. From what I understand I need to read an input register based on the spec sheets that was given to me from my internship.
Below is the spec sheet for the wind sensor. It lists address 201 register 202 as the wind speed in m/s. For starters all I want to do is read this register but I'm not sure how I put that into the method in the library code.
In the documentation listed on the website that I provided, it shows there is a method for reading input registers.
My question is, what is the correlation between the registers and addresses on the spec sheet versus what is supposed to be inputted into the method.
Here is my code that I have used so far:

#include <ModbusMaster.h>

ModbusMaster modBus;

void setup()
{
  Serial.begin(19200);

  modBus.begin(1, Serial);
}

void loop()
{
  modBus.readInputRegisters(201, 1);
}

From what I understand the parameters in the readInputRegisters method need to be in the form of Hexadecimal but I'm not quite understanding how to do that when I'm only given numbers 200-209 on the spec sheet. Hopefully that is enough information for someone to give any insight or with helping me understand a little bit more about these concepts. I greatly appreciate any advice!

Registers for Wind Sensor.pdf (93.9 KB)

Based on my personal experience, <ArduinoModbus.h> library worked fine for me.
In that library, there is an example in RTU subdirectory, called ModbusRTUTemperatureSensor.
Replace "HOLDING_REGISTERS" with "INPUT_REGISTERS" in the "requestfrom", the same principle.
This is good to see if you can poll anything.

Good luck,
Pew

I appreciate you taking the time to try and answer my question. But I'm still not seeing how your reply answers my question. I understand I need to read an input register. I'm not understanding the correlation between the required parameters in the method of being a hexadecimal number versus what is on the spec sheet. Are you saying that 0x00 is equivalent to register 200, 0x01 = 201, 0x02 = 202? I tried the provided code in the example you recommended and I'm still having that same question and just getting errors.

#include <ArduinoModbus.h>

float systemStatus;

void setup() {
  Serial.begin(19200);
  while (!Serial);

  Serial.println("Modbus Wind Sensor Velocity");
  // start the Modbus RTU client
  if (!ModbusRTUClient.begin(19200)) {
    Serial.println("Failed to start Modbus RTU Client!");
    while (1);
  }
}

void loop() {

  // send a Holding registers read request to (slave) id 1, for 2 registers
  if (!ModbusRTUClient.requestFrom(1, INPUT_REGISTERS, 0x00, 1)) {
    Serial.print("failed to read registers! ");
    Serial.println(ModbusRTUClient.lastError());
  } else {
    // If the request succeeds, the sensor sends the readings, that are
    // stored in the holding registers. The read() method can be used to
    // get the raw temperature and the humidity values.
    short systemStatus = ModbusRTUClient.read();


    // To get the temperature in Celsius and the humidity reading as
    // a percentage, divide the raw value by 10.0.

    Serial.println(systemStatus);
  }

  delay(5000);
}

Serial monitor:
⸮⸮⸮⸮́Wind Sensor Velocity
1 ⸮failed to read registers! Connection timed out

I whipped up a fritzing diagram of my wiring. This is exactly how i am wiring my boards.

Any other thoughts or documents someone can refer me to, to study up on these concepts? I could really use some help. I have tried everything I know how to do so far, before coming here to the forums. I hope someone can at least point me in a new direction?

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