Arduino UNO R4 RS422

In this guide, we will explain how to establish RS422 communication using Arduino UNO R4. We will cover the following steps in detail:

The tutorial gives guidance on using both Hardware Serial and SoftwareSerial.

Arduino UNO R4 RS-422

Hardware Preparation

1×Arduino UNO R4 WiFi
1×Arduino UNO R4 Minima (Alternatively)
1×USB Cable Type-C
1×TTL to RS422 Module
1×Jumper Wires
1×(Optional) RS422 to USB Cable
1×(Recommended) Screw Terminal Block Shield for Arduino UNO R4
1×(Recommended) Breadboard Shield For Arduino UNO R4
1×(Recommended) Enclosure For Arduino UNO R4

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables.

Overview of TTL to RS422 Module

When using serial communication on Arduino UNO R4 with functions such as Serial.print(), Serial.read(), and Serial.write(), the Arduino UNO R4 sends data using the TX pin and gets data through the RX pin. These pins work at TTL level, which means the signals they use have a short range. So, for serial communication over long distances, you need to change the TTL signal to RS232, RS422, or RS485 signal standards.

In this tutorial, we will explore how to use RS422 with Arduino UNO R4 by using a TTL to RS422 module. This module helps convert TTL signals to RS422 signals and vice versa.

Pinout

The RS422 to TTL module comes with two interfaces:

  • The TTL interface, which you connect to an Arduino UNO R4, has 4 specific pins:
    • VCC pin: This is the power pin that you must connect to VCC (5V or 3.3V).
    • GND pin: Another power pin that you should connect to GND (0V).
    • RXD pin: This is a data pin that you should connect to the TX pin of the Arduino UNO R4.
    • TXD pin: This is a data pin that you should connect to the RX pin of the Arduino UNO R4.
  • The RS422 interface includes these pins:
    • A (R+) pin: This is the RX+ pin of the module. Connect it to the TX+ pin (T+ or Y pin) of another RS422 device.
    • B (R-) pin: This is the RX- pin of the module. Connect it to the TX- pin (T- or Z pin) of another RS422 device.
    • Y (T+) pin: This is the TX+ pin of the module. Connect it to the RX+ pin (R+ or A pin) of another RS422 device.
    • Z (T-) pin: This is the TX- pin of the module. Connect it to the RX- pin (R- or B pin) of another RS422 device.
    RS-422 module Pinout
    image source: diyables.io

Wiring Diagram

  • Wiring diagram for using hardware serial with RS422:
The wiring diagram between Arduino UNO R4 TTL to RS422

This image is created using Fritzing. Click to enlarge image

  • Wiring diagram for using software serial with RS422
The wiring diagram between Arduino UNO R4 RS-422 to TTL

This image is created using Fritzing. Click to enlarge image

How To Program Arduino UNO R4 to use the RS422 module

  • Sets up the Serial connection:
Serial.begin(9600);
  • To use Software Serial, include the library and create a SoftwareSerial object.
#include <SoftwareSerial.h> SoftwareSerial rs422(6, 7); // RX on Pin 6, TX on Pin 7

Arduino UNO R4 Code for Hardware Serial

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-rs422 */ void setup() { // start communication with baud rate 9600 Serial.begin(9600); // wait a moment to allow serial ports to initialize delay(100); } void loop() { // Check if there's data available on Serial if (Serial.available()) { char data = Serial.read(); // read the received character Serial.print(data); // echo back to data to the sender } }

Arduino UNO R4 Code for Software Serial

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-rs422 */ #include <SoftwareSerial.h> SoftwareSerial rs422(6, 7); // RX: 6, TX: 7 void setup() { // start communication with baud rate 9600 rs422.begin(9600); // wait a moment to allow serial ports to initialize delay(100); } void loop() { // Check if there's data available on rs422 if (rs422.available()) { char data = rs422.read(); // read the received character rs422.print(data); // echo back to data to the sender } }

Testing

Follow these instructions step by step:

  • If this is your first time using the Arduino Uno R4 WiFi/Minima, refer to the tutorial on setting up the environment for Arduino Uno R4 WiFi/Minima in the Arduino IDE.
  • Connect the Arduino Uno R4 to the TTL-to-RS422 module according to the provided diagram.
  • Connect the Arduino Uno R4 to board to your computer using a USB cable.
  • Launch the Arduino IDE on your computer.
  • Select the appropriate Arduino Uno R4 board (e.g., Arduino Uno R4 WiFi) and COM port.
  • Copy the provided code and paste it into the Arduino IDE.
  • Click the Upload button in the Arduino IDE to transfer the code to the Arduino UNO R4.

You can test by sending data from your PC to Arduino UNO R4 and back using RS-422. Here are the steps to follow:

  • Connect your Arduino UNO R4 to your computer using an RS422-to-USB cable as shown below:
Arduino UNO R4 RS422 to PC communication
  • Download and install a Serial Terminal Program such as Tera Term or PuTTY.
  • Launch the Serial Terminal Program and set up the Serial parameters (COM port, baud rate, etc.).
  • Enter some data in the Serial Terminal to send to the Arduino UNO R4.
  • If the setup is correct, you will see the data you typed echoed back on the Serial Terminal screen.

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!