Windspeed sensor rs485 with max485 module converter esp32

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);
}

Hello

Welcome to the best Arduino forum ever :slight_smile:

Use a search engine of your choice and search the WWW for the above reference to get some ideas.

Your wiring looks good, your code looks good.
You get timeout, so there is no communication.
Flimsy wiring would be the first thing to check.
Also, what pin exactly you used for "VCC"? Since you don't have level shifter, you need to use 3.3V, not 5V.

i've try using both supply max485 from esp32 either 3.3V or 5V, still same error timeout

Post a photo of your wiring between esp and converter.
Don't use 5V, you will damage your esp.


this is my wiring, ok i will change the converter supply from external PSU

Just supply it from Esp 3.3V pin.

I have two things to suggest, try with direct wiring from Esp to converter without that adapter board.
If that doesn't help, try also crossing the A and B wires.

ok thank you

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