Arduino DUE read from Serial input MAX232 out as keyboard

Hi, I am trying to get data using a MAX232 Serial coming from a RS232 device, and outtputing this data as keystrokes via the native USB.
So far I have succeeded in inputting data but on output it only sends partial amount of the caracters or data.
I have it connected to pins TX18 and RX19 + GND. the Arduino gets power from the computer its connected to as keyboard and the system recognizes it as such. the MAX232 is powered externally but still referenced to the arduino due GND.
I did make sure that baud rate and pariety are the same 9600/8/none

#include <Keyboard.h>

void setup()
{
   Keyboard.begin();
  Serial.begin(9600);
  Serial1.begin(9600); // Open serial, 9600bps
}
void loop()
{
 
 if (Serial1.available() > 0) {
    char c = Serial1.read();
    SerialUSB.write(c);
    Keyboard.write(c);
    delay(50);
  
 }
}

Ideas anyone of why only partial data comes through. When using the progrming port as input all data comes through but I need to enter with pins
thanks

I'm not familiar with the Due. Are Serial and SerialUSB the same thing? Maybe change SerialUSB to Serial?

The MAX232 is a 5V device and your Due is a 3.3V device.

The Arduino docs for the Due state:

Warning: Unlike most Arduino boards, the Arduino Due board runs at 3.3V. The maximum voltage that the I/O pins can tolerate is 3.3V. Applying voltages higher than 3.3V to any I/O pin could damage the board.

when I change SerialUSB to Serial, the pc does no recognice the arduino as a keyboard

thanks for replying

thanks for replying, I think you might be right and I damaged mi board. I am awaiting a new board Arduino DUE
I have now tried with a signal level converter, and I do get readings consistently. wrong but consistent.
Example if I send HHHH i get HH, 123456789 I get 2468, always the same result, not random for each time I send.

I think you can power the MAX485 from the 5V on your DUE. I think that the DI, RE & DE signals from the DUE to the MAX485 should be ok as they are. The RO signal can go through a potential divider to get the 5V down to around 3.3V.

Of course, you can always look for a MAX3485 based module instead.

Hi again, I confirm that my DUE is fried!!
I did it with a MICRO, input from Hercules in a pc Via MAX232 to MICRO using a " RUNCCI-YUN 15 Psc 4 Channel IIC I2C Logic level Converter Bidirectional Module 3.3V a 5V Shifter, and output as keystrokes via the USB, everything works 100% in this config.

Now, when I connect the MAX232 to another RS232 device (also working in 5V) the conversor dies as it can not get power, even when I am feeding it with an external signal.

as soon

So,
I changed the max for this
image

and now I do get all the correct data.....Plus an unwanted letter at the end of every read "ñ"
I works consistently but still adds that caracter and I do not know where its coming from or how to flush it out. Any ideas?
thanks to all

Can that be a <CR> and/or <LF>? That will work on Serial but not on keyboard.

Do you mean coming from the external device? I don´t think so, its a scale and I also tried a barcode reader, they only send a number and . I have trying removing them but same result

Before printing out each character received, check to see if it is a printable character - i.e. 0..9, a..z, A..Z or one of the punctuation characters. If it is not a printable character, then print out the code for the character instead as that may give a clue as to what it is.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.