Using Arduino Due for Serial Communication

Hi guys,

I am trying to get my Arduino DUE to send a serial signal over its TX/RX ports to a device that reads RS485.

I wrote a segment of code to do so;

// the setup routine runs once when you press reset:
void setup() {
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  
    Serial.write(0x1A);
    Serial.write((byte)0);
    Serial.write((byte)0);
    Serial.write(0x1F);
    Serial.write((byte)0);
}

I am having difficultly getting the Arduino to do so.
I uploaded the same code to an Arduino Uno and it worked seamlessly however the Due doesn't.

when I change the above code to serial1 or serial2 or serial3 it doesn't output anything at all.

Could someone please help me fix this?

I am trying to send the HEX sequence 1A, 00,00,1F,00

I would avoid using Serial because pins 0 and 1 are also connected to the Programming Port of the Due.

When you switched to Serial1, did you also move the connection to pins 18 and 19 on the Due?

Yes and there was no output

The Due is a 3.3 V device, while the Uno is a 5 V device. Normally, outputting a 3.3 V signal to a 5 V device will work find because 3.3 V is within the voltage range that produces a HIGH level. However, that is not guaranteed. You should check the datasheet of the device you have connected to the serial lines of the Due to see if it is compatible with a 3.3 V output. If not, use a level shifter to convert the 3.3 V logic level to 5 V.

One thing you should be very careful of is that outputting a 5 V signal to a 3.3 V device will damage or destroy that device unless it has been specifically designed to be 5 V tolerant (which will be clearly documented in the datasheet). The Due is not 5 V tolerant so if you get a 5 V signal on the RX pin then it will be a very bad thing. You need to use a level shifter to convert the 5 V logic level to 3.3 V.

My DUE's UART1 Port and UNO's SUART Port work well!

DUE-Sender Codes

void setup()
{
  Serial1.begin(9600);

  {
    Serial1.write(0x1A);
    Serial1.write((byte)0);
    Serial1.write((byte)0);
    Serial1.write(0x1F);
    Serial1.write((byte)0);
  }
}

void loop()
{

}

UNO-Receiver Codes:

#include<SoftwareSerial.h>
SoftwareSerial SUART(2, 3); //SRX = DPin-2, STX = DPin-3

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

void loop() 
{
  byte n = SUART.available();
  if(n != 0)
  {
    byte x = SUART.read();
    if(x < 0x10)
    {
       Srial.print('0');
    }
    Serial.print(x, HEX);
  }
}

Screenshot:
sm-3.png

sm-3.png