wired RS485 sensor network does not work

  • Hi,
    I build up the wired RS485 network with the gateway and motion sensor examples give on the website.
    Unfortunately it does not work. There is no commucation between the Gateway and the sensor.
    I only can capture nonsence.

    Connectins are :
    pin 8 (RX) to RO on RS485 brick.
    pin 9 (TX) to DI on RS485 brick.
    MY_RS485_DE_PIN to DE RE on RS485 brick.

    However if I check the connections with with this small program that used the same pins, the communication works correctly. What detail did I forget?

    #include <AltSoftSerial.h>
    AltSoftSerial altSerial;
    #define SSerialTxControl 2   //RS485 Direction control
    #define RS485Transmit    HIGH
    #define RS485Receive     LOW
    bool ReceiveOrSend = RS485Transmit;
    void setup() {
      Serial.println("AltSoftSerial Test Begin");
      pinMode(SSerialTxControl, OUTPUT);
      digitalWrite(SSerialTxControl, RS485Transmit);  // Enable RS485 Transmit    
      if (ReceiveOrSend ){
          Serial.println("send mode"); 
          digitalWrite(SSerialTxControl, RS485Transmit);  // Enable RS485 Transmit 
      } else
          digitalWrite(SSerialTxControl, RS485Receive);  // Enable RS485 Transmit 
          Serial.println("receive mode");
    void loop() {
      char receivedOnRS485;
      if (ReceiveOrSend ){
          altSerial.println(" Hello world");
      } else
      if (altSerial.available()) {
        receivedOnRS485 = altSerial.read();

  • @wimd Usually when you see RS232 or RS485 connections spitting out junk, the first thing to check is that you have your baud rate set the same on all ends/nodes.Also, sometimes if your baud rate is too high and if you have other things like debugging going on, this can cause it too. If you have full control over the baud rate, meaning if you don't have any devices that are preset to a certain rate, what I usually do is start out at 9600 baud at both ends and test the data connection. From there, keep increasing your baud rate until you have issues, then lower it by 1 level.

  • @dbemowsk Did all of these trail once again yesterday but without success.

  • @wimd When I built my RS485 thermostat bridge I used the SoftwareSerial library for the RS485 side which worked well for me. I see you are using the AltSoftSerial library. I have never used that one, but it looks like others have used that library with success. Can you post the sketch that doesn't work so that we can compare with the sample sketch you posted above? A few other questions, I can assume that at least one of your nodes is an arduino node, are both nodes arduino nodes? If so, are they both using the same sketch? If you have different sketches for each interface, we would need to see both sketches. If your second node is something other than an arduino node, can you elaborate on what i is?

    We will help you figure this out, we just need more information to do so.

  • @dbemowsk Thank you for the reply. I searched in the meantime and found on the form that 'rs485 on nano' topic describes exactely the same issue I have. I see that you are involved there.
    I will join that chat as more people are involved.

Log in to reply

Suggested Topics

  • 11
  • 8
  • 5
  • 2
  • 2
  • 11
  • 7
  • 35