Trouble with RS232

Hello,

I'm fairly new to Arduino and I do not understand how to connect a rs232 to an Arduino uno board or the code needed to make it work in a program. I tried using the SoftwareSerialExample program located inside the Arduino IDE but its saying that it has an error connecting. The exact error is "Problem uploading to board. See https://support.arduino.cc/hc/en-us/sections/360003198300 for suggestions". The rs232 that I'm using says RS232-TTL-YL-97 on it. I found the pinout for it and it should be connected properly. I will recheck it to make sure that it's connected properly. Any suggestions for this problem would be greatly appreciated.

Thank you

I also tried using this code but it generated the same errors

//Created August 23 2006
//Heather Dewey-Hagborg
//http://www.arduino.cc

#include <ctype.h>

#define bit9600Delay 100  
#define halfBit9600Delay 50
#define bit4800Delay 188
#define halfBit4800Delay 94

byte rx = 6;
byte tx = 7;
byte SWval;

void setup() {
  pinMode(rx,INPUT);
  pinMode(tx,OUTPUT);
  digitalWrite(tx,HIGH);
  delay(2);
  digitalWrite(13,HIGH); //turn on debugging LED
  SWprint('h');  //debugging hello
  SWprint('i');
  SWprint(10); //carriage return
}

void SWprint(int data)
{
  byte mask;
  //startbit
  digitalWrite(tx,LOW);
  delayMicroseconds(bit9600Delay);
  for (mask = 0x01; mask>0; mask <<= 1) {
    if (data & mask){ // choose bit
     digitalWrite(tx,HIGH); // send 1
    }
    else{
     digitalWrite(tx,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
  }
  //stop bit
  digitalWrite(tx, HIGH);
  delayMicroseconds(bit9600Delay);
}

int SWread()
{
  byte val = 0;
  while (digitalRead(rx));
  //wait for start bit
  if (digitalRead(rx) == LOW) {
    delayMicroseconds(halfBit9600Delay);
    for (int offset = 0; offset < 8; offset++) {
     delayMicroseconds(bit9600Delay);
     val |= digitalRead(rx) << offset;
    }
    //wait for stop bit + extra
    delayMicroseconds(bit9600Delay);
    delayMicroseconds(bit9600Delay);
    return val;
  }
}

void loop()
{
    SWval = SWread();
    SWprint(toupper(SWval));
}

You are using word RS232 as if it were a thing. Basically RS232 is a protocol for asynchronous serial communication.

So can you give us a link to what this thing is? From the description it sounds like a RS232 to TTL converter board. What is it doing and how have you wired it up to the rest of the system?

No idea what that is. What does it do? Please post a link to the product page.

This is the best I could find. Currently its wired into my Arduino Uno with VCC going to 5V, GND to GND, RX to TX, and TX to RX. The way its wired to my computer is DB9 Male --> DB9 Female gender changer --> DB9 Male --> USB A --> Computers com port.

Actually, RS-232 is an ancient and well defined electrical specification for data communication. It's claim to fame is any or all pin connections can be shorted together for ever without causing problems with the attached equipment. It defines the maximum and minimum voltages that can be used as well as the shape (rise and fall) of the bipolar data signal pulses.
It has been used with all variations of data transmission from 5 bit to 8 bit words, async or sync.

What board?

Arduino Uno R3 specifically

  • Connect UNO via USB to PC

  • Select your board:

  • Select Tools/Port:

  • Compile & Upload:

image

The USB to Serial (USB-ttl) adapter is often used with homemade boards and clone boards that do not have USB-serial.

A picture tutorial:
Adafruit Learning System

The Rx and Tx pins on the UNO (usually identified as pins 0 and 1) are connected to the on board USB to serial interface and are used to communicate with the serial monitor in the IDE as well as upload sketches.

In order to use the interface board you have, you would need a software serial port - just use one of the software serial libraries that already exist. Connect the pins used by the software serial library to your RS232 interface module Rx and Tx pins and you should be good to go.

Note that with a software serial port, the baud rate is quite low, 9600 or 19200 baud max. No 115200 baud.

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