Serial (RS232) Interfacing Between Arduino With Computer Using SoftwareSerial Library



robotics-university.com | Hello friends, today I invite you to learn about serial interfacing between Arduino board with computer using “SoftwareSerial” library. With that library, I will guide you to make a simple Arduino project, i.e. interface a Arduino board to computer via USB port helped by a USB To TTL bridge (CP2102) module. Are you interest? If yes, let’s continue read this article and practice by follow the guidance on this project. 

1. Project Materials 
To make this project, we have to has the project materials. Below I write the hardware and software needs in order we can make this project realized. 

A. Hardware needs 
(1) Arduino Uno board. 
(2) USB To TTL (CP2102) bridge module. 
(3) USB cable. 
(4) Connector cable/jumper (male-female). 
(5) Computer/Laptop. 

B. Software needs 
(1) Arduino IDE. Download here! 
(2) SoftwareSerial library. Download here and here! 
(3) USB To TTL bridge driver. Download here! 

Prepare all of the project materials first and then we can continue our job! Don’t forget to install the needed software to your computer. For SoftwareSerial library, if you install the latest version of Arduino IDE, usually this library has installed on it. 

2. Project Schematic 
To start the project, at the first, we have to assemble the hardware material with follow the schematic below. See figure 1. 

Figure 1. Serial (RS232) Interfacing Arduino Uno with Computer 

From the schematic, we know that we will use PIN3 of Arduino Uno board as RXD (Data Receive) pin and PIN 7 as TXD (Data Transmit) pin. See Table 1 for detail hardware connection between Arduino Uno board with USB To TTL module. 

Table 1. Arduino Uno - USB To TTL module connection 

Then table 2 give us information about the interfacing of Arduino Uno and USB To TTL module with the computer. 

Table 2. The interfacing of Arduino Uno and USB To TTL module with the computer 

Figure 2. Device Manager - COM3 for Arduino Uno & COM4 for USB To TTL module 

Arduino Uno board connect to the computer via COM3, while USB To TTL module connect to the computer via COM4. See figure 2. 

3. Arduino Sketch (Program) 
The next step, type this Arduino Sketch (program) below on Arduino IDE text editor. 

The program above will make we can send a text (“Hallo mas Taufiq, piye kabare?”) to the computer serially and display it on the Arduino IDE “Serial Monitor” when the RESET button on Arduino Uno board pressed.

4. Compile (Verify) & Upload the Arduino Sketch 
To compile and upload the Arduino sketch (program) to your Arduino board, you can follow my guidance on my previous article “How to Use IDE Arduino Software.

Figure 3. Step to Compile/Verify of Arduino sketch

Figure 4. Step to Uploading of Arduino sketch 

5. Run The Project Application 
To run the application that we has created on this project, please follow the steps below: 

Step 1: Change the COM Port 
The communication between Arduino Uno board with the computer build serially via COM4 of the computer.

Figure 5. Step to Change the serial COM port 

To make the two device communicated, we have to select the proper COM port on the Arduino IDE COM port selector, because we will use the "Serial Monitor" that available on Arduino IDE. So select COM4. See figure 5! 

Step 2: Open “Serial Monitor” on Arduino IDE 
After we select the proper COM port, next we can open the “Serial Monitor” of Arduino IDE. Select “Tools” menu on Arduino IDE menu-bar, then select “Serial Monitor” or you can use shortcut-key Ctrl + Shift + M. See figure 6!

Figure 6. Step to open Arduino IDE Serial monitor 

If the “Serial Monitor” option has been selected, Arduino IDE Serial Monitor will appear as shown on figure 7.

Figure 7. Arduino IDE Serial monitor 

Step 3: Project Test - Send A Message From Arduino To Computer (Serial Monitor) 
The last step, to know the project result, we must test the performance. To start testing this project result, make sure the USB To TTL module has been connected to the computer via USB (COM4) port (See figure 8), then press the RESET button on the Arduino Uno board once.

Figure 8. The message on Arduino IDE Serial Monitor when RESET button pressed 

If the project has no errors, every once you press RESET button on Arduino Uno board , on the Arduino IDE “Serial Monitor” will show a text that we has been determined on the Arduino program (Sketch), i.e. “Hallo mas Taufiq, piye kabare?” See figure 9.

Figure 9. The received message from Arduino Uno board on Arduino IDE Serial Monitor 


Share on Google Plus

About Taufiq D.S. Suyadhi

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment