Arduino RS232 Converter To PC

Hi !

I'm new with arduino! i have recently bought an Elegoo Mega2560 R3.
I have many communication pins :

  • TX0 & RX0
  • TX1 & RX1
  • TX2 & RX2
  • TX3 & RX3

How can i send a string of characters to my PC (RS232) ?

What hardware i will need? and what code i will need?

Thank you.

Best regards!

MisterEmine:
How can i send a string of characters to my PC (RS232) ?
What hardware i will need? and what code i will need?

Any reason you can't use USB. No extra hardware needed for that.

TX0/TX0 is internally connected to the USB<>Serial chip.
It's not just for uploading new sketches, but can also be used for serial comms.

Serial.print("send a string to the PC"); // prints the string on the serial monitor of the PC
Leo..

If you want to not use the USB or want to use tx1 etc , then you need a converter to raise the voltage levels to those of RS232. You can buy TTL
To RS232 converters of use a MAX232 chip

Hi !

I can't use USB connector, because my computer have only 1 free RS232 connector (DB9).
So i will buy TTL to RS232 converters of use a MAX232 chip. Thank you.


Arduino <==> TTL to RS232 Converters <==> RS232 (DB9 Connector) <==> Computer

  1. Any one can give me a code for sending the following string of characters?
    <25FK;AE;01>

  2. Can some one give a link to the TTL to RS232 Converters using MAX232 Chip?

Thank you :slight_smile:

MisterEmine:
I can't use USB connector, because my computer have only 1 free RS232 connector (DB9).

Absolute nonsense! I cannot believe you have a PC with no USB ports. You must have USB ports. :astonished:

Hie ye down to the local "dollar shop" and get a USB hub. Plug the keyboard and mouse into the hub - which is extremely convenient whenever you need to switch both keyboard and mouse to a different computer - and plug your Arduino into the free USB port.

I advise this rather than plugging the Arduino into the hub unless it is a powered hub. Keyboards and mice take very little current, so can be shared on a non-powered hub. If you had one of the better Dell keyboards, you would be able to plug the mouse into the keyboard itself anyway. :grinning:

MisterEmine:
...my computer have only 1 free RS232 connector (DB9).

386SX-25 with Win3.1 ?

So you don't have USB connectors on your PC?
How do you upload a sketch...

If you don't have enough USB sockets, can't you use a USB hub?
Leo..

I know i can use USB hub, but i don't have any USB ports.
It's an industrial terminal PC, and i don't have any USB ports, that's why i'm using the RS232 DB9 connector.

DB9.png

Wawa:
386SX-25 with Win3.1 ?

Closer to the truth, apparently!

Wawa:
So you don't have USB connectors on your PC?
How do you upload a sketch...

Apparently using a different computer.

I do see the point now - he is developing a device on a modern computer in order to interface to a piece of old industrial equipment.

Try Alice!

Paul__B:
Closer to the truth, apparently!
Apparently using a different computer.

I do see the point now - he is developing a device on a modern computer in order to interface to a piece of old industrial equipment.

Try Alice!

Thank you for the url link :slight_smile: i apreciate it!

and now ,can some one give me a code for sending the following string of characters?
<25FK;AE;01>

Thank you :slight_smile:

MisterEmine:
Thank you for the url link :slight_smile: I appreciate it!

Note that you will need to determine whether you need a "straight" or "crossover" cable.

MisterEmine:
and now ,can some one give me a code for sending the following string of characters?
<25FK;AE;01>

Including the angle brackets or just the part in between?

Paul__B:
Note that you will need to determine whether you need a "straight" or "crossover" cable.
Including the angle brackets or just the part in between?

I will need a programm to send this string of characters including the angle brackets :
<25FK;AE;01>

Thank you i will check if it's straight or crossover cable.

Thank you very much.

void setup(){
  Serial.begin(WhatEverBaudrateYouNeed);
  Serial.print("<25FK;AE;01>")
}

void loop(){
  
}

Using a Mega for that is a bit overkill but okay.

septillion:

void setup(){

Serial.begin(WhatEverBaudrateYouNeed);
  Serial.print("<25FK;AE;01>")
}

void loop(){
 
}




Using a Mega for that is a bit overkill but okay.

So what king of arduino you advice me to take?

A Nano or a Pro Mini would do the job fine :slight_smile:

I have another problem,
When i upload the programm into my arduino mega2560 R3, this code work fine,

String a = "<25FK;AE;01>";
String b = "<25FK;AE;06>";
void setup()
{
Serial.begin(9600);
}

void loop()
{
Serial.print(a);
delay(1000);
Serial.print(a);
delay(1000);
}

but when i unplug the usb connector all the programm is lost.

It's normal? i need to save the programm in my arduino and not upload the programm evey time i power on this arduino.

That's simply impossible :slight_smile: So what makes you think it behaves like that?

Also made some changes to the code

const char CommandA[] = "<25FK;AE;01>";
const char CommandB[] = "<25FK;AE;06>";

const unsigned int Baudrate = 9600;
const unsigned int SendDelay = 1000;

void setup()
{
  Serial.begin(Baudrate);
}

void loop()
{
  Serial.print(CommandA);
  delay(SendDelay);
  Serial.print(CommandB);
  delay(SendDelay);
}
  1. I assumed you wanted to send StringA and StringB :smiley:
  2. Used proper strings
  3. If you want to have variable names for the settings, which is good!, it makes sense to do it to everything
  4. And use useful variable names for it (or at least no single letter names)

And do you really want to send those commands alternating infinite?

@septillion

I wouldn't want to change your code but perhaps a blinking LED might help the OP troubleshooting :slight_smile:

Like this?

const char CommandA[] = "<25FK;AE;01>";
const char CommandB[] = "<25FK;AE;06>";

const unsigned int Baudrate = 9600;
const unsigned int SendDelay = 1000;

void setup()
{
  Serial.begin(Baudrate);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
  digitalWrite(LED_BUILTIN, HIGH);
  Serial.print(CommandA);
  delay(SendDelay);
  digitalWrite(LED_BUILTIN, LOW);
  Serial.print(CommandB);
  delay(SendDelay);
}

MisterEmine:
I have another problem,
When i upload the programm into my arduino mega2560 R3, this code work fine,

but when i unplug the usb connector all the programm is lost.

It's normal? i need to save the programm in my arduino and not upload the programm evey time i power on this arduino.

How do you know it is lost?
What is powering the mega when you disconnect the USB port?
Thanks.. Tom... :slight_smile:

I do see the point now..

Thats what happens when the whole setup/problem is not explained fully from the beginning..
It takes 8 posts/replies just to figure out whats really going on...