2

I use 485 modules to transmit data serially from one arduino uno to another uno.

If I connect the 2 arduino boards directly without using the rs485 module, the data is sent and received without a problem. But when using the rs485 module, the transmission stops.

Tx code:

void setup() {
    Serial.begin(9600);
}

void loop() { Serial.write(200); Serial.flush(); delay(50); }

Rx code:

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() { Serial.begin(9600); }

void loop() { if (Serial.available()) { // If data has come in from Master int reply= Serial.read(); // Read the byte delay(10);

    lcd.print(reply);
}

}

I can't see what is the problem. I checked every thing wiring and the code is so simple. I'm just sending one number 200 and want to display it on the rx.

Please help. If anyone has an idea about this problem thanks any way.

the busybee
  • 2,408
  • 9
  • 18

2 Answers2

1

In modbus there are two pins which are as DE and RE which you need to set and reset while transmitting the data. Also you can check Modbus this library it has some examples which could be useful to you also in arduino Uno don't use software serial for transmitting the data use the hardware serial only I will suggest implement your code on arduino Mega if you have any and then port the code for Uno. Just go through the library you will find some helpful examples and it will solve your issue

Maaz Sk
  • 345
  • 3
  • 16
0

I polished my glasses, I did not find the schematic and parts list. It appears you have to enable the transmitter and or receiver to make them work. DE and RE are pins on the Max RSS 485 driver chip and others. They will not transmit or receive if these are wrong. Many connect the DE and RE together to simplify the switching. In your case you have to enable the transmitter on the transmitting Arduino and the Receive on the receiving Arduino. Do not enable the transmitter on the receive side as it wall cause bus contention and it will probably stop working. The receive can be enabled on the transmitter. This is done is some protocols to validate the message sent. Since you are only sending one way you can hardwire them to the correct logic level. Also you should terminate the buss, it may work without but best to add the resistors.

Gil
  • 1,863
  • 9
  • 17