After searching the internet and trying different examples, I always get the same wrong response in the serial monitor.

Picture 1 shows the wrong results. At first i thought it was decimal and I just had to convert it to ASCII. But that wasn't the problem.

Picture 2 shows the results that I expect. It's from the Logic Analyzer that sits on a breadbord to "sniff" the communication. I expect N+0000.0\r

Picture 3 shows the settings or the logic analyzer. Please ignore the "SPI MISO" it's just an old description.

I have no other approach left in my mind.

I would appreciate any hint. :) Thank you in advance.

You will find the Arduino sketch below the pictures.

Serial Monitor

Logic Analyzer

Settings Logic Analyzer

#include <SPI.h>
#include <Controllino.h>  /* Usage of CONTROLLINO library allows you to use CONTROLLINO_xx aliases in your sketch. */

const int numBytes = 20;
int incomingBytes[numBytes];   // for incoming serial data

void setup() {

  /* Initialize serial port for debug messages. */

  /* Initialize CONTROLLINO RS485 direction control DE/RE pins and Serial3 */
Serial3.begin(9600,SERIAL_8N2); //Initialisierung Serial Controllino(RS 485)
  //Beim Mega oder Maxi Zugang zum /OVL pin und RS458 /RE DE Pins
  //Zuweisung /RE (PJ5) DE (PJ6) pins als Ausgang (1). Für /OLV (PE7) als Eingang (0)
  DDRJ |= B01100000;
  DDRE &= B01111111;


  Serial.println("Recieving RS485...");

void loop() {


void DatenEmpfangen()
  static byte ndx = 0;
  int rc;
  PORTJ &= B10011111;//Empfangen MODUS
    if (Serial3.available() > 0)
     // digitalWrite(CONTROLLINO_D1, HIGH);
     rc = Serial3.read();

     incomingBytes[ndx] = rc;
  } while (Serial3.available() > 0);

void DatenAnzeigen()
  static byte count = 0;
  //int Xor = 0;
  //Xor = receivedIntegersA[0];
  for (count=0;count<9;count++)

  • first chage type of incomingBytes to byte (for printing). use println(incomingBytes [count] , HEX) – Juraj Jan 26 '19 at 18:44
  • @ Juraj - that doesn't work. The Hex Values are completely different compared to the correct output of the logic analyzer. – Huppel Jan 29 '19 at 10:03
  • @Majenko - i don't get any output at all. I uploaded the sketch here: github.com/AndreasNRW/WS_RS485 – Huppel Jan 29 '19 at 10:05
  • @Majenko - i'm sorry, your linked example works great. The terminating character in my case was \r not \n. Very nice blog post. Thanks a lot. – Huppel Jan 29 '19 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.