Arduino Nano 33 IoT - RS422

This guide shows you how to use RS422 communication with your Arduino Nano 33 IoT. We will learn by following these steps:

Arduino Nano 33 IoT TTL to RS422

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×TTL to RS422 Module
1×Jumper Wires
1×Optionally, RS422 to USB Cable
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

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 you use serial communication on the Arduino Nano 33 IoT with commands like Serial.print(), Serial.read(), and Serial.write(), data is sent from the TX pin and received by the RX pin. These pins work at TTL level, which means they handle signals that only travel a short distance. So, if you want to send data over longer distances, you need to change the TTL signal to RS232, RS422, or RS485 standards.

This guide shows how to work with RS422 on the Arduino Nano 33 IoT. We use a TTL to RS422 module that changes TTL signals into RS422 signals and back.

Pinout

The RS422 to TTL module comes with two ports:

  • TTL Interface (connected to Arduino Nano 33 IoT):
  • VCC Pin: Connect this power pin to VCC (5V or 3.3V).
  • GND Pin: Connect this power pin to GND (0V).
  • RXD Pin: Connect this data pin to a TX pin on the Arduino Nano 33 IoT.
  • TXD Pin: Connect this data pin to an RX pin on the Arduino Nano 33 IoT.
  • RS422 Interface:
  • A (R+) Pin: This is the RX+ pin on the module. Connect it to the TX+ pin (or T+ / Y pin) on the other RS422 device.
  • B (R-) Pin: This is the RX- pin on the module. Connect it to the TX- pin (or T- / Z pin) on the other RS422 device.
  • Y (T+) Pin: This is the TX+ pin on the module. Connect it to the RX+ pin (or R+ / A pin) on the other RS422 device.
  • Z (T-) Pin: This is the TX- pin on the module. Connect it to the RX- pin (or R- / B pin) on the other RS422 device.
RS-422 module Pinout
image source: diyables.io

Wiring Diagram

The wiring diagram between Arduino Nano and 33 IoT TTL to RS422

This image is created using Fritzing. Click to enlarge image

How To Program Arduino Nano 33 IoT to use the RS422 module

  • Set the pins for serial communication.
#define RX1PIN D3 #define TX1PIN D2
  • Starts the serial connection:
Serial1.begin(9600, SERIAL_8N1, RX1PIN, TX1PIN); // Initialize RS232 serial communication using a 9600 baud rate
  • To read data from RS422, you can use these functions:
    • Serial.read() – reads one character.
    • Serial.readBytes() – reads multiple characters.
    • Serial.readBytesUntil() – reads multiple characters until a specific character is found.
    • Serial.readString() – reads data as a text string.
    • Serial.readStringUntil() – reads a text string until a specific character is found.
  • To write data to RS422, you can use these functions:
    • Serial.print() – sends data to the output.
    • Serial.println() – sends data and moves to a new line.
    • Serial.write() – sends raw binary data.
  • You can find more RS422 functions in the Serial reference.

Arduino Nano 33 IoT Code

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-rs422 */ #define RX1PIN 3 #define TX1PIN 2 void setup() { // start communication with baud rate 9600 Serial.begin(9600); // Serial Monitor Serial1.begin(9600, SERIAL_8N1, RX1PIN, TX1PIN); // RS422 // wait a moment to allow serial ports to initialize delay(100); } void loop() { // Check if there's data available on Serial if (Serial1.available()) { char data = Serial1.read(); // read the received character Serial1.print(data); // echo back to data to the sender Serial.print(data); // print the recived data to Serial Monitor } }

Testing

You can try a test by sending data from your computer to the Arduino Nano 33 IoT using RS-422 and then sending it back. To do this, follow these steps:

  • Connect the Arduino Nano 33 IoT to your computer using an RS422-to-USB cable like the one shown below.
Arduino Nano 33 IoT RS422 to PC communication
  • Install a serial terminal program like Tera Term or PuTTY.
  • Open the program and set up the serial settings (like COM port and baud rate).
  • Type some text in the terminal to send it to the Arduino Nano 33 IoT.
  • If it works, you'll see the text appear back in the terminal.

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!