Error code while trying to receive data with RS485/Modbus RTU to arduino - from arduino to CanBus

It should be like this

#include <ModbusMaster.h>
#include <SoftwareSerial.h>

// Define software serial RX and TX pins
#define RX_PIN 2
#define TX_PIN 3

#define MAX485_DE      8
#define MAX485_RE_NEG  7

// Create a SoftwareSerial instance
SoftwareSerial mySerial(RX_PIN, TX_PIN);

ModbusMaster node;

void preTransmission()
{
  digitalWrite(MAX485_RE_NEG, 1); // DE = 1 to enable driver (transmit mode)
  digitalWrite(MAX485_DE, 1);
}

void postTransmission()
{
  digitalWrite(MAX485_RE_NEG, 0); // RE = 0 to enable receiver (receive mode)
  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);
  mySerial.begin(9600); // Initialize software serial port

  node.begin(1, mySerial); // Use software serial for Modbus communication
  
  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);
}

void loop()
{
  uint8_t result;
  
  // Adjust to read input registers starting from address 30000
  result = node.readInputRegisters(0x7530, 16);
  
  if (result == node.ku8MBSuccess)
  {
    Serial.print("mass flow: ");
    Serial.println(node.getResponseBuffer(0x04));  // mass flow address 30004
    Serial.print("temp: ");
    Serial.println(node.getResponseBuffer(0x06));  // temperature address 30006
  } 
  else 
  {
    Serial.print("Modbus Error: ");
    Serial.println(result);
  }

  Serial.println("\n ------------  \n ");

  delay(1000);
}

With the code u've corrected ı'm getting this error.

RO pin goes to 2 which is RX

Ok.
And de/re pins to 7 and 8?
Control all wiring has tight connections.
And you are powering rs485 converter at 5V

here's my wiring:

226 = 0xE2
which means:

    /**
    ModbusMaster response timed out exception.
    
    The entire response was not received within the timeout period, 
    ModbusMaster::ku8MBResponseTimeout. 
    
    @ingroup constant
    */
    static const uint8_t ku8MBResponseTimedOut           = 0xE2;

so either your wiring is wrong or the settings of the device do not fit to your code.

show real pictures with your current wiring.
We should also see the clearly the connection between the Device and the RS485 sensor.

also this note can be found int the manual

In addition to the D0 and D1 signal lines the bus MUSTMUSTMUSTMUST include a "Common" signal line to act as a
ground reference point for the data signals

Step 1. connect the Arduino ground to the ground, or (-), of the device, and retry your code.

Device settings

Server Address: 001
Baud rate: 9600
Frame Format: 8E1
Transmission Mode: RTU
Transmission Delay: 00
Endianness of Strings: Normal
Endianness of 2-Byte Data: AB
Endianness of 4-Byte Data: ABCD
Endianness of 8-Byte Data: ABCD

I asked in post#18 to set parity to No.
Would be 8N1

I wasnt aware that the frame format meant parity , my bad.I changed it but ı still get error 226

In the manual you linked, there was separate setting for parity, not frame format.
Is your device different from that manual?

Also, when you change settings, you might need to repower that device.

not the device in the picture but ıt has the same datasheet when ı try to download it.Here's another datasheet ı could find:https://cdn.krohne.com/pick2/tagged_docs/AD_MFC400_ER2.x_Modbus_en_220803_4007655203_R03.pdf

Device name Optimass 6400.

Nothing strange there.
Did you control your wiring, every single jumper wire needs to be tight, replace if doubts.
Did you add gnd between device and rs485 (or arduino) gnd pin?

I can't identify your rs485 voltage from your photo, neither from wiring diagram.
So I ask second time, is it 5V?

device has its own gnd and vcc inside ı guess cus ı couldn't see anything even when ı opened it.

rs485 voltage connected to arduino's 5v

Next to A and B connectors, there should be Com. Connect that to free arduino gnd pin.

ı'm not at the office right now so ı cant do that but ı'll try it on Monday and let u know if it works.

Your setup should receive something from device already.
I suggest you to replace all the jumper wires with new ones to eliminate some odds.
Good weekend!

Thank you.
I tried again and ım receiving data but not the exact numbers.When ım supposed to receive 4 from the device ı get 16512 but when ı set the device 0 ı get 0 as well.I also tried 8 and ım receiving 16640.Something's wrong but ı couldn't find it.

Finally, congratulations!
If you don't get modbus errors, your'e fine.
16512 is 0x4080 in hex.
Show me your code and output.