SlideShare a Scribd company logo
Implementing RS-232 Serial Ports
On An Arduino

DESERT CODE CAMP 2012.1
               Presented by Don Doerres
               Embedded Pro Guy
               don@azlaborlaw.com
TODAY’S TAKEAWAYS

 The Arduino has a ―Low Level‖ serial
  connection; many electronic devices have
  higher voltage serial connections called RS-
  232
 This class will explain
     The basics of the serial connection
     What the low and high level signals look like

     How to convert between the types of signals

     Some generalized RS-232 interfacing
      suggestions
LET’S PICK A CHARACTER FOR AN EXAMPLE

 Let‘s use capital ‗C‘ for Code Camp
 Look this up on an ANSI Chart

 Dec: 67, Hex:43, Binary, 8 bits: 01000011
THE BASIC SERIAL PROTOCOL 1

 The bits of the characters come one at a
  time, through a single wire.
 The wire ―idles‖ at a ‗1‘ level to show that it is
  alive
 The bits come out low order bit first

 We will program for bytes of 8 bits each
THE BASIC SERIAL PROTOCOL 2

 We know the wire is alive because it idles at
  ‗1‘, the higher voltage level
 We know in advance how fast bits will be
  coming out of the wire; this is called the
  ―baud rate‖
 So, our Arduino is sampling the incoming
  wire for a transition from ‗1‘ to a ‗0‘
THE BASIC SERIAL PROTOCOL 3

 So now we have one start bit
 This will be followed by 8 bits of the byte

 And, to keep this straight, we will have 1
  extra bit of 1 at the end of the string of bits to
  guarantee that a ‗1‘ to ‗0‘ transition can take
  place to indicate the start of a next byte
PUTTING IT ALL TOGETHER

 1 Start Bit, 8 data bits, 1 Stop bit
 The bits of the byte come out low order bit
  first in time
 So we will have this string of 10 bits, with
  gray showing the state of the wire before and
  after the byte:
    …1 1 1 1 0 1 1 0 0 0 0 1 0 1 1 1 1 1…
                    Time
ANOTHER VIEW OF THE SAME THING

   Here we show both the bit stream and the
    Arduino voltage levels
NOW RS232

 On the Arduino, the serial line swings
  between 0 and 5 volts (some are 0 to 3.3V)
 RS-232 is an older protocol
    A  ‗1‘ is -12V
     A ‗0‘ is +12V

   Don‘t even think about connecting the
    Arduino directly to this…please
ANOTHER VIEW OF THE SAME THING

 This time RS232
 A ‗1‘ is -12V

 A ‗0‘ is +12V
SO HOW DO WE GET FROM LOW LEVEL TO
RS232?
 We need a hardware level translator
 This one is a Sparkfun PRT-00449
HOW TO HOOK TO ARDUINO

   Note the signal arrows between the adapter
    and the Arduino
TEST CODE INCLUDES AND DEFINES
#include <SoftwareSerial.h>

#define INSOFT1 7
#define OUTSOFT1 8

int incomingByte = 0;
SoftwareSerial SWSerial(INSOFT1, OUTSOFT1);
TEST CODE SETUP
void setup()
{
Serial.begin(9600);
SWSerial.begin(9600);
}
TEST CODE LOOP
void loop()
{
while (Serial.available() > 0)
    {
    incomingByte = Serial.read();
    SWSerial.print((char)incomingByte);
    }
while (SWSerial.available() > 0)
    {
    incomingByte = SWSerial.read();
    Serial.print((char)incomingByte);
    }
}
SCREEN CAPTURES
SCREEN CAPTURES
MORE STUFF…

 Q: How do I hook up right?
 A: Use an RS232 Analyzer and adapters
HOOK TO THE MAIN COMPUTER

 The TD light should light
 Note TD and DTR, may light for a more
  advanced connection
HOOK TO THE TARGET

 The RD light should light
 Sometimes Target powered from the host,
  and there will be no lights—or the target is
  off!
 Note possible:
     CD

     CTS

     DSR
HOOK TOGETHER

   The ideal outcome – all the lights!
FIXING IT

   Sometimes you need a NULL adapter on one
    side
IF YOU DO THIS A BIT…

 Invest in some adapters
 These are a long term investment

 I bought the first of mine 30 years ago…they
  wear well
SOURCE FOR RS232 GEAR

   These companies offer different adapters
    over time
     Radio Shack (www.radioshack.com)
     Frys Electronics (www.frys.com)

   This company is more expensive, but has a
    huge variety in stock at all times
     Black   Box (www.blackbox.com)
RS232 TO LOW LEVEL ADAPTER

   Sparkfun has two different ones
     PRT-00133 ($6.95) is a through hole kit
     PRT-00449 ($13.95) is surface mount and is pre-
      built
   www.sparkfun.com
QUESTIONS?

   Find more slides from Don at
    www.slideshare.net/dondoerres
   The Arduino code shown came be
    downloaded from
    https://github.com/dondoerres/drdCodeCamp2012.
    1

More Related Content

PPT
PPTX
Session3
PPTX
Lica 3rd chapter slides
PDF
Kramer PT-102SN
DOC
(Main)astable square wave generator
PPT
Lecture32
PDF
Kramer VS-401-XLM
PPT
Physical prototyping lab2-analog_digital
Session3
Lica 3rd chapter slides
Kramer PT-102SN
(Main)astable square wave generator
Lecture32
Kramer VS-401-XLM
Physical prototyping lab2-analog_digital

What's hot (17)

PDF
Kramer VS-611
PDF
Kramer VS-1001-XLM
PDF
Kramer 401Dxl
PDF
Kramer VS-601-XLM
PDF
Kramer VS-1201XL
DOCX
Not gate
PPTX
Building light automation (1)
PDF
Kramer VM-9T
PDF
Kramer VS-1011
PPTX
transistor transistor logic
PPTX
PDF
Vs 81 h-dxl
PDF
Kramer VS-81-HDXL
PDF
SFP(FT-901B-S-LC20)_DataSheet_ver_1.1
PDF
Franklin oscillator
PDF
PDF
Kramer VM-312
Kramer VS-611
Kramer VS-1001-XLM
Kramer 401Dxl
Kramer VS-601-XLM
Kramer VS-1201XL
Not gate
Building light automation (1)
Kramer VM-9T
Kramer VS-1011
transistor transistor logic
Vs 81 h-dxl
Kramer VS-81-HDXL
SFP(FT-901B-S-LC20)_DataSheet_ver_1.1
Franklin oscillator
Kramer VM-312
Ad

Similar to 2012 1 arduino_rs232 (20)

PDF
I2c interfacing raspberry pi to arduino
PDF
Embedded system course projects - Arduino Course
PPTX
Arduino Workshop (3).pptx
PPT
Physical prototyping lab3-serious_serial
PDF
publish manual
PPTX
arduino and its introduction deep dive ppt.pptx
PPTX
Arduino Workshop
PDF
Logic Gates & Family.pdf
PPTX
Intro_to_Arduino_-_v30.pptx
DOCX
Arduino windows remote control
PPTX
Fun with arduino
PDF
Arduino spooky projects_class3
PDF
ARDUINO (1).pdf
PPTX
Smart Blind stick by using arduino uno and sensor
DOCX
Measurements upload
PPTX
Arduino Slides With Neopixels
PPT
Introduction to Arduino 16822775 (2).ppt
PPT
Physical prototyping lab2-analog_digital
PDF
Arduino projects &amp; tutorials
PPTX
Basic arduino components and more things about arduino
I2c interfacing raspberry pi to arduino
Embedded system course projects - Arduino Course
Arduino Workshop (3).pptx
Physical prototyping lab3-serious_serial
publish manual
arduino and its introduction deep dive ppt.pptx
Arduino Workshop
Logic Gates & Family.pdf
Intro_to_Arduino_-_v30.pptx
Arduino windows remote control
Fun with arduino
Arduino spooky projects_class3
ARDUINO (1).pdf
Smart Blind stick by using arduino uno and sensor
Measurements upload
Arduino Slides With Neopixels
Introduction to Arduino 16822775 (2).ppt
Physical prototyping lab2-analog_digital
Arduino projects &amp; tutorials
Basic arduino components and more things about arduino
Ad

More from Don Doerres (10)

PPTX
2018 03 28_near_scifi
PPTX
2018LifeOnOtherWorldsl
PDF
2018 tamid sshw
PDF
2018_03_15_life_on_otherworlds
PDF
2017 aacr youth day
PDF
Presentation desert codecamp_2017_1_sonichandkerchief
PPTX
2013 1 arduino_datalogger
PPTX
Rasberry pi class
PPTX
Raspberry pi lnl
PDF
Single Boards Overview
2018 03 28_near_scifi
2018LifeOnOtherWorldsl
2018 tamid sshw
2018_03_15_life_on_otherworlds
2017 aacr youth day
Presentation desert codecamp_2017_1_sonichandkerchief
2013 1 arduino_datalogger
Rasberry pi class
Raspberry pi lnl
Single Boards Overview

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Big Data Technologies - Introduction.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation theory and applications.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
KodekX | Application Modernization Development
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
Teaching material agriculture food technology
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Spectral efficient network and resource selection model in 5G networks
The AUB Centre for AI in Media Proposal.docx
MYSQL Presentation for SQL database connectivity
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine learning based COVID-19 study performance prediction
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
Big Data Technologies - Introduction.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Unlocking AI with Model Context Protocol (MCP)
Encapsulation theory and applications.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
KodekX | Application Modernization Development
20250228 LYD VKU AI Blended-Learning.pptx
Teaching material agriculture food technology
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Chapter 3 Spatial Domain Image Processing.pdf
Electronic commerce courselecture one. Pdf
Review of recent advances in non-invasive hemoglobin estimation
Spectral efficient network and resource selection model in 5G networks

2012 1 arduino_rs232

  • 1. Implementing RS-232 Serial Ports On An Arduino DESERT CODE CAMP 2012.1 Presented by Don Doerres Embedded Pro Guy don@azlaborlaw.com
  • 2. TODAY’S TAKEAWAYS  The Arduino has a ―Low Level‖ serial connection; many electronic devices have higher voltage serial connections called RS- 232  This class will explain  The basics of the serial connection  What the low and high level signals look like  How to convert between the types of signals  Some generalized RS-232 interfacing suggestions
  • 3. LET’S PICK A CHARACTER FOR AN EXAMPLE  Let‘s use capital ‗C‘ for Code Camp  Look this up on an ANSI Chart  Dec: 67, Hex:43, Binary, 8 bits: 01000011
  • 4. THE BASIC SERIAL PROTOCOL 1  The bits of the characters come one at a time, through a single wire.  The wire ―idles‖ at a ‗1‘ level to show that it is alive  The bits come out low order bit first  We will program for bytes of 8 bits each
  • 5. THE BASIC SERIAL PROTOCOL 2  We know the wire is alive because it idles at ‗1‘, the higher voltage level  We know in advance how fast bits will be coming out of the wire; this is called the ―baud rate‖  So, our Arduino is sampling the incoming wire for a transition from ‗1‘ to a ‗0‘
  • 6. THE BASIC SERIAL PROTOCOL 3  So now we have one start bit  This will be followed by 8 bits of the byte  And, to keep this straight, we will have 1 extra bit of 1 at the end of the string of bits to guarantee that a ‗1‘ to ‗0‘ transition can take place to indicate the start of a next byte
  • 7. PUTTING IT ALL TOGETHER  1 Start Bit, 8 data bits, 1 Stop bit  The bits of the byte come out low order bit first in time  So we will have this string of 10 bits, with gray showing the state of the wire before and after the byte: …1 1 1 1 0 1 1 0 0 0 0 1 0 1 1 1 1 1… Time
  • 8. ANOTHER VIEW OF THE SAME THING  Here we show both the bit stream and the Arduino voltage levels
  • 9. NOW RS232  On the Arduino, the serial line swings between 0 and 5 volts (some are 0 to 3.3V)  RS-232 is an older protocol A ‗1‘ is -12V  A ‗0‘ is +12V  Don‘t even think about connecting the Arduino directly to this…please
  • 10. ANOTHER VIEW OF THE SAME THING  This time RS232  A ‗1‘ is -12V  A ‗0‘ is +12V
  • 11. SO HOW DO WE GET FROM LOW LEVEL TO RS232?  We need a hardware level translator  This one is a Sparkfun PRT-00449
  • 12. HOW TO HOOK TO ARDUINO  Note the signal arrows between the adapter and the Arduino
  • 13. TEST CODE INCLUDES AND DEFINES #include <SoftwareSerial.h> #define INSOFT1 7 #define OUTSOFT1 8 int incomingByte = 0; SoftwareSerial SWSerial(INSOFT1, OUTSOFT1);
  • 14. TEST CODE SETUP void setup() { Serial.begin(9600); SWSerial.begin(9600); }
  • 15. TEST CODE LOOP void loop() { while (Serial.available() > 0) { incomingByte = Serial.read(); SWSerial.print((char)incomingByte); } while (SWSerial.available() > 0) { incomingByte = SWSerial.read(); Serial.print((char)incomingByte); } }
  • 18. MORE STUFF…  Q: How do I hook up right?  A: Use an RS232 Analyzer and adapters
  • 19. HOOK TO THE MAIN COMPUTER  The TD light should light  Note TD and DTR, may light for a more advanced connection
  • 20. HOOK TO THE TARGET  The RD light should light  Sometimes Target powered from the host, and there will be no lights—or the target is off!  Note possible:  CD  CTS  DSR
  • 21. HOOK TOGETHER  The ideal outcome – all the lights!
  • 22. FIXING IT  Sometimes you need a NULL adapter on one side
  • 23. IF YOU DO THIS A BIT…  Invest in some adapters  These are a long term investment  I bought the first of mine 30 years ago…they wear well
  • 24. SOURCE FOR RS232 GEAR  These companies offer different adapters over time  Radio Shack (www.radioshack.com)  Frys Electronics (www.frys.com)  This company is more expensive, but has a huge variety in stock at all times  Black Box (www.blackbox.com)
  • 25. RS232 TO LOW LEVEL ADAPTER  Sparkfun has two different ones  PRT-00133 ($6.95) is a through hole kit  PRT-00449 ($13.95) is surface mount and is pre- built  www.sparkfun.com
  • 26. QUESTIONS?  Find more slides from Don at www.slideshare.net/dondoerres  The Arduino code shown came be downloaded from https://github.com/dondoerres/drdCodeCamp2012. 1