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

What's hot (17)

PDF
Kramer VS-611
AV ProfShop
 
PDF
Kramer VS-1001-XLM
AV ProfShop
 
PDF
Kramer 401Dxl
AV ProfShop
 
PDF
Kramer VS-601-XLM
AV ProfShop
 
PDF
Kramer VS-1201XL
AV ProfShop
 
DOCX
Not gate
Anupam Narang
 
PPTX
Building light automation (1)
Jeyalakshmi Jei
 
PDF
Kramer VM-9T
AV ProfShop
 
PDF
Kramer VS-1011
AV ProfShop
 
PPTX
transistor transistor logic
mansi acharya
 
PPTX
jiby
JIBY KRISHNA
 
PDF
Vs 81 h-dxl
AV ProfShop
 
PDF
Kramer VS-81-HDXL
AV ProfShop
 
PDF
SFP(FT-901B-S-LC20)_DataSheet_ver_1.1
Feliz Technology Co., Ltd.
 
PDF
Franklin oscillator
muhtadin akbar
 
PDF
Hw4
jamsponder
 
PDF
Kramer VM-312
AV ProfShop
 
Kramer VS-611
AV ProfShop
 
Kramer VS-1001-XLM
AV ProfShop
 
Kramer 401Dxl
AV ProfShop
 
Kramer VS-601-XLM
AV ProfShop
 
Kramer VS-1201XL
AV ProfShop
 
Not gate
Anupam Narang
 
Building light automation (1)
Jeyalakshmi Jei
 
Kramer VM-9T
AV ProfShop
 
Kramer VS-1011
AV ProfShop
 
transistor transistor logic
mansi acharya
 
Vs 81 h-dxl
AV ProfShop
 
Kramer VS-81-HDXL
AV ProfShop
 
SFP(FT-901B-S-LC20)_DataSheet_ver_1.1
Feliz Technology Co., Ltd.
 
Franklin oscillator
muhtadin akbar
 
Kramer VM-312
AV ProfShop
 

Similar to 2012 1 arduino_rs232 (20)

PPTX
Interfacing with Arduino
Omer Kilic
 
PPTX
Micro c lab8(serial communication)
Mashood
 
PDF
Serial Port Device Driver
Emblogic
 
PPT
ARDUINO AND ITS PIN CONFIGURATION
soma saikiran
 
PDF
Device Operation using PC by Arduino (1).pdf
sampathiraopujitha
 
PPT
AN INTRODUCTION TO SERIAL PORT INTERFACING
Total Project Solutions
 
PPTX
Arduino slides
sdcharle
 
PPTX
Arduino Workshop Slides
mkarlin14
 
PDF
Arduino Workshop @ MSA University
Ahmed Magdy Farid
 
PDF
RS 232 Notes for Embedded systems and IOT
ERPraven
 
PPTX
Audible Objects
Leif Bloomquist
 
PPT
Introduction to Arduino 16822775 (2).ppt
ansariparveen06
 
PPTX
02 General Purpose Input - Output on the Arduino
Wingston
 
PDF
Arduino- Serial communication
Jawaher Abdulwahab Fadhil
 
PPTX
Serial Communication & Embedded System Interface
KUET
 
PDF
Arduino spooky projects_class3
Anil Yadav
 
PDF
CC2500 Wireless Trans-receiver Module
Aarya Technologies
 
PDF
Product catlog
Aarya Technologies
 
PPTX
Arduino Slides With Neopixels
sdcharle
 
PDF
Arduino guide
Rajan Gautam
 
Interfacing with Arduino
Omer Kilic
 
Micro c lab8(serial communication)
Mashood
 
Serial Port Device Driver
Emblogic
 
ARDUINO AND ITS PIN CONFIGURATION
soma saikiran
 
Device Operation using PC by Arduino (1).pdf
sampathiraopujitha
 
AN INTRODUCTION TO SERIAL PORT INTERFACING
Total Project Solutions
 
Arduino slides
sdcharle
 
Arduino Workshop Slides
mkarlin14
 
Arduino Workshop @ MSA University
Ahmed Magdy Farid
 
RS 232 Notes for Embedded systems and IOT
ERPraven
 
Audible Objects
Leif Bloomquist
 
Introduction to Arduino 16822775 (2).ppt
ansariparveen06
 
02 General Purpose Input - Output on the Arduino
Wingston
 
Arduino- Serial communication
Jawaher Abdulwahab Fadhil
 
Serial Communication & Embedded System Interface
KUET
 
Arduino spooky projects_class3
Anil Yadav
 
CC2500 Wireless Trans-receiver Module
Aarya Technologies
 
Product catlog
Aarya Technologies
 
Arduino Slides With Neopixels
sdcharle
 
Arduino guide
Rajan Gautam
 
Ad

More from Don Doerres (10)

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

Recently uploaded (20)

PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
July Patch Tuesday
Ivanti
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Python basic programing language for automation
DanialHabibi2
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
July Patch Tuesday
Ivanti
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 

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 [email protected]
  • 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