MAX485 + AltSoftSerial problem

Hello,
I have nano board and MAX485
RO is connected to D8
DI is connected to D9
RE closed to DE and connected to D10

my code is

void setup() {
  pinMode(10, OUTPUT);
  altSerial.begin(38400);
  digitalWrite(10, HIGH);  // Enable RS485 Transmit
  delay(1);
  altSerial.println("Hello World");
  digitalWrite(10, LOW);  // Disable RS485 Transmit 
  delay(1);
}

void loop() {
     digitalWrite(10, HIGH);  // Enable RS485 Transmit
     altSerial.println(millis());
     digitalWrite(10, LOW);  // Disable RS485 Transmit 

  
   if (altSerial.available()) {
    byteReceived = altSerial.read();
    Serial.println(byteReceived);
  }
    delay(100);

so, I receive "Hello world" message from max, but altSerial.available() always return 0... so I no incoming packages...
what is wrong?

Setup() function runs only once - just after restart or powering on arduino. Do you have 2 arduinos connected over RS485? Both of them run the same sketch? You should use delay() BEFORE turning enable pin of.

at the moment I have one arduino.
I want to communicate via re-485 with some 3rd party device, but now I connect arduino via max485 to moxa 485-232 converter to pc to emulate communication.
so, on pc side I see "hello world" message send by arduino, also each 100msec I see on pc side line with millis from arduino.
but then I send smth from pc side to arduino - nothing appears

I tried to use SoftwareSerial first, in this case I was able to receive data from pc, but with lost and send back to pc with very huge lost... once one of 20 packages was received on pc side... with altsoftserial each package is received on pc side, but nothing on arduino (

You're toggling enable pin very fast - faster than serial data is arriving. Look at Blink without delay egzample - every second send Millis() value to PC. Then set control pin low and wait for serial data. It's not a perfect solution but it will give you idea. Or make arduino respond to PC only when it gets certain command - send letter R from PC and arduino Wil send some data back.

idea is clear, but it still doesn't work...
this code

void setup() {
  pinMode(10, OUTPUT);
  altSerial.begin(38400);
  digitalWrite(10, HIGH);  // Enable RS485 Transmit
  delay(10);
  altSerial.println("Hello World");
  digitalWrite(10, LOW);  // Disable RS485 Transmit 
  delay(10);
}

void loop() {
   if (altSerial.available()) {
    byteReceived = altSerial.read();
    Serial.println(byteReceived);
  }

prints nothing on console ((
so, at setup stage I write to rs485 and switch it into receive mode, but nothing looks to arrive...

 altSerial.println("Hello World");
 digitalWrite(10, LOW);  // Disable RS485 Transmit 
delay(10);

You shut down the link somewhere in the middle of the start bit of the "H" being transmitted because the string is buffered and Serial.print() returns immediately, long before any chars have been transmitted. Ideally you have to wait until all characters are gone but AFAIK there's no way to tell that on an Arduino, so move your delay() before the digitalWrite() and play with the value until you see all characters.


Rob