RS485 Modbus Arduino Uno Reading Wind sensor

I have a question if anyone would be willing to help me. I am learning ModBus, RS485, 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, you can also google search "57-6017 Rev I - DOC, Manual, WSD-1" for the entire spec sheet. 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 node;

void setup() {
  delay(3000);
  Serial.begin(19200);
  node.begin(1, Serial);
  
  Serial.println("Setup Complete");
}

void loop() {
  Serial.println(node.readInputRegisters(201, 1));
}

Output in Serial Monitor:

Setup Complete

???226

I also have a wiring diagram for my setup as well.

Registers for Wind Sensor.pdf (93.9 KB)

Please post a wiring diagram for engineering purposes. Fritzings are the property of ignorant sails people.
So often, maybe not here, powering is the main reason for trouble. The powering is never shown in Fritzings? Why? Powered by air forces? Joking.

The Serial port (RX, TX) can be used for debugging or module communication, but not for both at the same time. Either write debug output to a local (LCD...) screen or use SoftSerial for the Modbus communication. Or use an Arduino Mega with 4 distinct Serial ports.

RailRoader, Im glad you brought up power supply being a possible factor. I checked with a multimeter and arduino was powering about 4.8 volts to the windsensor. They recommend 5-24V DC. I'm using a 12 Volt power supply with a 5990 k ohm resistor to power the windsensor. They advise average current should be 2 mA for optimal performance but no more then 2.5 mA.

DrDiettrich, I have wired up an lcd to the arduino. I have it displaying the read input register to the LCD. I actually had it already wired up (because I'm using it and a few other things with this project as well.) It currently writes properly to the lcd but I'm not quite sure why I'm getting the output I'm getting.

Here is my updated Code:

#include <ModbusMaster.h>

#include <LiquidCrystal.h>

#define RSPin 12
#define RWPin 11
#define EnablePin 10
#define DS4 7
#define DS5 6
#define DS6 5
#define DS7 4

#define LCDColumns 20
#define LCDRows 2

LiquidCrystal lcd(RSPin, RWPin, EnablePin, DS4, DS5, DS6, DS7);

ModbusMaster node;

void setup() {
  delay(3000);
  Serial.begin(19200);
  node.begin(1, Serial);
  
  lcd.begin(LCDColumns, LCDRows);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Setup Complete");
  delay(2000);
  lcd.clear();
}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print(node.readInputRegisters(201, 202));
}

My output is on the LCD:
226

The odd thing that I find is that when I unplug the TX (pin1) wire from my Arduino, I still get 226 as an output. And in the serial monitor just ⸮qc (about every 2 seconds repeated continuously). It seems to me that I'm not getting a reading at all from my wind sensor. Am I not understanding the library correctly? or how the rs485 board is supposed to be wired or used? Any other thoughts on this project?

Gamand:
[My output is on the LCD:
226

The odd thing that I find is that when I unplug the TX (pin1) wire from my Arduino,

Tx to were? A wiring had been nice...

I still get 226 as an output. And in the serial monitor just ⸮qc

That looks like either mismatched baudrates or none ASCII characters snet.
(about every 2 seconds repeated continuously). It seems to me that I'm not getting a reading at all from my wind sensor. Am I not understanding the library correctly? or how the rs485 board is supposed to be wired or used? Any other thoughts on this project?

What is the data type given by node.readInputRegisters(201, 202)?

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