ArduinoTroubleshooting

Arduino MEGA 2560 with the RS232 Shield

userHead juvebogdan 2023-08-30 20:02:23 118 Views1 Replies

Hello,

 

I am a total beginner for Arduino. I am trying to connect the RS232 Shield to my Arduino MEga and send and receive messages to/from device that is connected to the DB9 of the shield. As soon as i connect the shield i lose the Serial interface of my Arduino. Is there any possibility to have that?

 

I read in docs here https://wiki.dfrobot.com/RS232_Shield that i have to switch off shield and then program board and then switch it on. How can i debug what is happening?

 

What is the simplest code i can use to send something to device and receive the response?

 

When i do for example this:

  uint8_t i, buffer[2];


 

  buffer[0] = '$';

  buffer[1] = '?';


  for (i = 0; i < sizeof(buffer); i++)

  {

    Serial.write(buffer[i]);

  }

  Serial.write('\n');

 

I can see the TXD LED blink on the shield and I also see in the Serial written '$?' 

 

But when i do Serial.printl I see nothing in the serial and RXD LED blinks on shield

 

Thank you

2023-08-31 14:50:58

I think this is normal, because the USB interface on the Arduino and the RS232 are connected to the Arduino hardware Serial (RX-0, TX-1) at the same time. And this interface can only be opened by one port (ComPort) at the same time.If you need to monitor the running of the program at the same time, you can only use SoftwareSerial library for print() output.

 

https://www.arduino.cc/en/Reference/softwareSerial

userHeadPic Yeez_B