Reading data from wind direction sensor with rs485 to TTL module

Hi,

I want to build a device that can measure the direction of the wind. I decided to go with the following wind direction measurement sensor:

I found out that the device communicates with rs485 protocol, so I also got the following rs485 module:

I don't have a lot of experience with this type of communication but still tried to program some code with the help of other similar posts to this. This is my code:

#include <SoftwareSerial.h>
#define RX        10    //Serial Receive pin --> connected to RXD of rs485 module
#define TX        11    //Serial Transmit pin --> connect to TXD of rs485 module

byte Anemometer_request[] = {0x02, 0x03, 0x00, 0x17, 0x00, 0x01, 0x34, 0x0E}; // request_frame
byte Anemometer_buf[7];                                                       // receive_frame

SoftwareSerial rs485serial(RX, TX); // SoftwareSerial initialisation

void setup() {
  Serial.begin(9600);
  rs485serial.begin(9600);
  delay(1000);
}

void loop() {
  rs485serial.write(Anemometer_request, sizeof(Anemometer_request));  // request
  rs485serial.flush();                                                // wait for the request to be sent
  delay(500);
  while(rs485serial.available()){
    rs485serial.readBytes(Anemometer_buf, sizeof(Anemometer_buf));      // read
  }
  
  Serial.println("Data: ");                                             // print out data

  for (byte i=0; i<7; i++){
    Serial.println(Anemometer_buf[i], HEX);
    
  }
  Serial.println(" ");
  delay(4000);
}

I hooked up an 11.1v lipo battery to a boost converter and set the voltage around 16 volts. This should be enough to power the wind direction sensor which is rated from 12v to 24v. I also, of course, hooked up the 485-A to A and 485-B to B. Here is the wiring from the rs485 module to my Arduino:

GND --> Arduino GND
VCC --> Arduino 5v
TX --> Arduino TX pin
RX --> Arduino RX pin

But instead of getting data, the Serial monitor outputs:

Data:
0
0
0
0
0
0
0

I'd be really grateful if somebody had an idea of what was going wrong here. One thing I find strange is, that my RS485 to TTL module doesn't have a receive enable and transmit enable pin. I guess it switches automatically? One thing that seems to be working is the TXD led on my rs485 module, whenever I send a request.

In the attachments, I have also added the manual for my wind direction sensor.

Thanks for reading this!

John

There's a discussion over on the Electrical Engineering section of StackExchange here that seems to be discussing the exact same RS485 module, along with a reverse engineered schematic.

The discussion seems to indicate that the module switches into transmit mode when you write out a byte to it. There's a small RC circuit that keeps the MAX485 in transmit mode when the TX input is active. After a period of inactivity, it switches back into receive mode.

Hopefully the RC circuit will timeout and switch the module back into receive mode before the device at the end of your RS485 bus starts talking back.

Another option might be to hack that module and put a 5-pin conn on instead of the 4-pin conn and route a wire direct to the RE & DE signals (isolating the other bits of the circuit that are connected to RE & DE). That way you will have control over the switching between TX & RX.

Thanks for the reply. I will be taking a look at the discussion you sent!