JXBS-3001-FS series wind direction sensor with MAX 485 ttl to RS485

Hi guys!, I am having a trouble display the exact values for my wind direction sensor. Here is my connections:

Wind Direction Sensor
Black Wire to 12-24v Power Supply
Brown Wire to 12-24v Power Supply
Yellow Wire to A green terminal block
Blue Wire to B green terminal block

MAX485 ttl to RS485 Module to Arduino Mega
VCC to VCC
GND to GND
DI to TX0
DE to 4
RE to 5
RO to RX0

below is the code im using

#include <ModbusMaster.h>

#define MAX485_DE      4
#define MAX485_RE_NEG  5


ModbusMaster node;

void preTransmission()
{
  digitalWrite(MAX485_RE_NEG, 1);
  digitalWrite(MAX485_DE, 1);
}
void postTransmission()
{
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);
}
void setup()
{
  pinMode(MAX485_RE_NEG, OUTPUT);
  pinMode(MAX485_DE, OUTPUT);

  
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);

  Serial.begin(9600);
  
  // Modbus slave ID 2
  node.begin(2, Serial);
  

  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);
}
//bool state = true;
void loop()
{
  uint8_t result;

  node.readHoldingRegisters(0x0017, 1);

  
  if (result == node.ku8MBSuccess)
  {
    Serial.print("Vbatt: ");
    Serial.println(node.getResponseBuffer(0x00));

  }
  delay(100);
}

and below is the display
display

need your help to resolve this problem, Thanks in advanced!

It's not very clever to run the Modbus serial on the same interface you use to communicate the values to the PC (and for debugging). The Mega has 4 (!) hardware serial interface so I recommend to use another one than the PC connection (p.e. Serial1 and TX1/RX1).

Post a link to the manual of your wind direction sensor. Many Modbus sensors use a parity bit to further enhance the reliability of the Modbus connection. If you do this wrong you won't get a response from the sensor.

Hi Sir, what do you mean to use another one than the PC connection? Sorry just a newbie.
and below is the manual








Oh, i see. Already connected RO to RX1 and DI to TX1 also RX2-3 and TX2-3, still the same display

Did you change the Modbus serial to Serial1 too (RO to RX1 and DI to TX1)?

i have the same problem with the same sensor

Did you do the suggested changes?

If yes, post the code you're using as well as the wiring you're using together with the serial output you get!

hey there, i did what u suggested

here is the code

#include <ModbusMaster.h>

#define MAX485_DE      4
#define MAX485_RE_NEG  5


ModbusMaster node;

void preTransmission()
{
  digitalWrite(MAX485_RE_NEG, 1);
  digitalWrite(MAX485_DE, 1);
}
void postTransmission()
{
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);
}
void setup()
{
  pinMode(MAX485_RE_NEG, OUTPUT);
  pinMode(MAX485_DE, OUTPUT);

  
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);

  Serial.begin(9600);
  
  // Modbus slave ID 2
  node.begin(2, Serial1);
  

  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);
}
//bool state = true;
void loop()
{
  uint8_t result;

  node.readHoldingRegisters(0x0017, 1);

  
  if (result == node.ku8MBSuccess)
  {
    Serial.print("Vbatt: ");
    Serial.println(node.getResponseBuffer(0x00));

  }
  delay(100);
}

wiring---
Wind Direction Sensor
Black Wire to 12-24v Power Supply
Brown Wire to 12-24v Power Supply
Yellow Wire to A green terminal block
Blue Wire to B green terminal block

MAX485 ttl to RS485 Module to Arduino Mega
VCC to VCC
GND to GND
DI to TX1
DE to 4
RE to 5
RO to RX1

and the serial output is blank.

I'm not sure if this will help or hinder you, but I did find another datasheet for your sensor. It was in chinese but google translate had a go at providing an english version:
2010191808_Ubibot-JXBS-3001-FS_C843317 (1).pdf (520.2 KB)
This manual indicates that the device address is 01 and that the wind speed and direction are in the 2 consecutive registers starting at 0x0000.

One of the manual pages you copied into the thread says the slave address is 0x01 but in the following example it is 0x02. Try both (bad manual means more work for you).

I would try to read register 256 (0x0100) as it should contain the device address if the returned value matches the address you used for the request you got the right one.

It works now, i only changed the modbus ID
node.begin(2, Serial1);
to
node.begin(1, Serial1);
Anw, thanks for ur ideas and help sir!

it reads 0 to 15 values

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