아두이노 우노 Q RS422

Arduino UNO Q와 TTL-to-RS422 모듈을 사용하여 RS422 직렬 통신을 수행합니다. RS422는 두 개의 비틀린 선 쌍에서 차동 신호를 사용합니다 — 하나의 선 쌍은 송신, 하나는 수신 용으로 사용됩니다 — 전이중 통신을 가능하게 하며, 최대 1200m의 거리에서 높은 노이즈 면역성으로 통신합니다. Bridge와 Telegram을 사용하면 Python이나 휴대폰에서 원격으로 RS422 데이터를 송수신할 수 있습니다.

이 튜토리얼에서 배우게 될 내용:

Arduino UNO Q rs422

필요한 하드웨어

1×Arduino UNO Q 아마존
1×USB Cable for Arduino Uno Q 아마존
1×TTL-RS422 변환 모듈 쿠팡 | 아마존
1×점퍼케이블 쿠팡 | 아마존
1×(옵션) RS422 to USB 변환 케이블 아마존
1×(추천) 아두이노 우노용 스크루 터미널 블록 쉴드 쿠팡 | 아마존
1×(추천) Sensors/Servo Expansion Shield for Arduino Uno 쿠팡 | 아마존
1×(추천) 아두이노 우노용 브레드보드 쉴드 쿠팡 | 아마존
1×(추천) 아두이노 우노용 케이스 쿠팡 | 아마존
1×(추천) 아두이노 우노용 프로토타이핑 베이스 플레이트 & 브레드보드 키트 아마존
공개: 이 포스팅 에 제공된 일부 링크는 아마존 제휴 링크입니다. 이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

TTL to RS422 모듈 정보

Arduino UNO Q MCU는 TTL 로직 레벨(3.3V)을 사용하여 UART를 통해 통신합니다. RS422 호환 산업용 장치, 카메라 또는 CNC 컨트롤러와 장거리에서 통신하려면, TTL을 RS422 차동 표준으로 변환해야 합니다. TTL-to-RS422 모듈은 양방향으로 이 변환을 수행합니다.

RS422의 주요 특징:

  • 전이중 통신(별도의 TX 및 RX 선 쌍)
  • 장거리: 최대 1200미터
  • 차동 신호로 인한 높은 노이즈 면역성
  • 포인트-투-포인트 또는 제한된 멀티드롭(드라이버당 최대 10개의 수신기)
rs422 module 사용법 핀아웃

핀아웃

  • TTL 인터페이스 (Arduino UNO Q MCU에 연결):
    • VCC: 전원 — 3.3V에 연결
    • GND: 접지
    • RXD: 데이터 입력 — MCU TX 핀(D6)에 연결
    • TXD: 데이터 출력 — MCU RX 핀(D7)에 연결
  • RS422 인터페이스:
    • A (R+): RX+ — 원격 TX+(T+/Y 핀)에 연결
    • B (R-): RX− — 원격 TX-(T-/Z 핀)에 연결
    • Y (T+): TX+ — 원격 RX+(R+/A 핀)에 연결
    • Z (T-): TX− — 원격 RX-(R-/B 핀)에 연결

배선 다이어그램

Arduino UNO Q ttl to rs422 module 연결 배선도

이 이미지는 Fritzing을 사용하여 만들어졌습니다. 이미지를 확대하려면 클릭하세요.

TTL-to-RS422 모듈 핀 Arduino UNO Q MCU 핀 비고
VCC 3.3V
GND GND
RXD D6 (MCU TX)
TXD D7 (MCU RX)

A/B(R+/R-) 및 Y/Z(T+/T-)를 RS422 장치 또는 PC 테스트용 USB-to-RS422 어댑터의 해당 핀에 연결합니다.

RS422 프로그래밍 방법

  • SoftwareSerial을 포함하고 RS422 직렬 객체를 만듭니다:
#include <SoftwareSerial.h> SoftwareSerial rs422(7, 6); // RX: D7, TX: D6
  • 들어오는 RS422 데이터를 읽습니다:
if (rs422.available()) { char data = rs422.read(); }
  • RS422를 통해 데이터를 전송합니다:
rs422.print("Hello from Arduino UNO Q"); rs422.println("With newline");

Arduino UNO Q 코드

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-rs422 */ #include <SoftwareSerial.h> SoftwareSerial rs422(7, 6); // RX: D7, TX: D6 void setup() { Monitor.begin(9600); // USB serial for debug output rs422.begin(9600); // RS422 module serial delay(100); } void loop() { // Forward data from RS422 to Monitor if (rs422.available()) { char data = rs422.read(); Monitor.print(data); rs422.print(data); // echo back to sender } // Forward data from Monitor to RS422 if (Monitor.available()) { char data = Monitor.read(); rs422.print(data); } }

빠른 단계

Arduino UNO Q를 처음 사용하나요? 진행하기 전에 아두이노 우노 Q 시작하기 튜토리얼을 따르세요.

  • 연결: 배선 다이어그램에 표시된 대로 TTL-to-RS422 모듈을 Arduino UNO Q MCU에 연결합니다.
  • Arduino App Lab 열기: Arduino App Lab을 시작하고 Arduino UNO Q를 감지할 때까지 기다립니다.
  • 새 앱 만들기: Create New App 버튼을 클릭합니다.
create new app in 아두이노 app lab on Arduino UNO Q
  • 앱에 이름을 지정합니다(예: RS422).
  • Create를 클릭하여 확인합니다.
아두이노 app lab app folders and files on Arduino UNO Q
  • 스케치 붙여넣기: 위의 MCU 코드를 복사하여 sketch/sketch.ino에 붙여넣습니다.
  • 업로드: Arduino App Lab에서 Run 버튼을 클릭합니다.
click run 버튼 in 아두이노 app lab on Arduino UNO Q

테스트

RS422 통신을 테스트하려면:

  • T+/T- 및 R+/R- 핀을 USB-to-RS422 어댑터에 연결합니다:
Arduino UNO Q rs422 to pc communication
  • PC에서 직렬 터미널(예: Tera Term 또는 PuTTY)을 엽니다.
  • 보드율을 9600으로 설정하고 올바른 COM 포트를 선택합니다.
  • 텍스트를 입력하고 전송합니다. Arduino UNO Q는 이를 에코백하며 — 터미널에 에코된 데이터가 표시됩니다.

Bridge: Linux + MCU

이 섹션은 Bridge를 통해 Linux 쪽(Python)에서 RS422 데이터를 송수신하는 방법을 보여줍니다:

  • TTL-to-RS422 모듈은 SoftwareSerial을 통해 MCU에 연결됩니다 — MCU가 모든 직렬 I/O를 처리합니다
  • MPU는 SoftwareSerial을 직접 사용할 수 없습니다 — Bridge 함수를 호출하여 RS422 데이터를 송수신합니다
  • MPU는 Wi-Fi를 가지고 있습니다 — 전체 Debian Linux를 실행하므로 RS422 데이터를 Telegram이나 웹 서비스로 중계할 수 있습니다
  • Arduino_RouterBridge는 두 프로세서 간의 RPC 통신을 활성화합니다
  • ⚠️ /dev/ttyHS1(Linux) 및 Serial1(MCU)는 라우터에 의해 예약됩니다 — 사용자 코드에서 절대 열면 안 됩니다

MCU 코드 (Bridge)

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-rs422 */ #include "Arduino_RouterBridge.h" #include <SoftwareSerial.h> SoftwareSerial rs422(7, 6); // RX: D7, TX: D6 String received_data = ""; String send_rs422(String arg) { rs422.println(arg); Monitor.print("Sent via RS422: "); Monitor.println(arg); return "ok:sent"; } String get_received(String arg) { String result = received_data; received_data = ""; return result; } void setup() { Bridge.begin(); Monitor.begin(); rs422.begin(9600); delay(100); Bridge.provide_safe("send_rs422", send_rs422); Bridge.provide("get_received", get_received); Monitor.println("Arduino UNO Q RS422 Bridge ready"); } void loop() { while (rs422.available()) { char c = rs422.read(); received_data += c; } }

Python 코드 (Bridge)

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-rs422 */ from arduino.app_utils import * import time def loop(): print("Sending message via RS422...") result = Bridge.call("send_rs422", "Hello from Arduino UNO Q!") print(f"Result: {result}") time.sleep(1) data = Bridge.call("get_received") if data: print(f"Received via RS422: {data}") else: print("No data received") time.sleep(2) App.run(user_loop=loop)

빠른 단계

  • 연결: 위에 표시된 대로 TTL-to-RS422 모듈을 Arduino UNO Q에 연결합니다.
  • Arduino App Lab 열기하고 RS422Bridge라는 새 앱을 만듭니다.
  • MCU 스케치를 붙여넣기: sketch/sketch.ino에 MCU 스케치를 붙여넣습니다.
  • Python 코드를 붙여넣기: Python 파일에 Python 코드를 붙여넣습니다.
  • Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.
add sketch 라이브러리 in 아두이노 app lab on Arduino UNO Q
  • Search for Arduino_RouterBridge created by Arduino and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
Arduino_RouterBridge Arduino

This library provides a simple RPC bridge for Arduino UNO Q boards, allowing communication between the board and other devices using MsgPack serialization.

0.4.1
Install
More Info
  • 업로드: Run 버튼을 클릭합니다. Python은 RS422를 통해 메시지를 보내고 에코된 모든 데이터를 읽습니다.
click run 버튼 in 아두이노 app lab on Arduino UNO Q

App Lab 콘솔 출력

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-04-29 09:00:01] Arduino UNO Q RS422 Bridge ready [2026-04-29 09:00:06] Sent via RS422: Hello from Arduino UNO Q!
DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:00:06] Sending message via RS422... [2026-04-29 09:00:06] Result: ok:sent [2026-04-29 09:00:07] Received via RS422: Hello from Arduino UNO Q!

Telegram

Telegram을 통해 RS422 데이터를 송수신합니다 — 정밀 산업 장비의 메시지를 휴대폰으로 전달하거나 Telegram에서 RS422 장치로 명령을 보냅니다.

MCU 스케치: 이전 Bridge 섹션의 MCU 스케치와 같게 유지합니다.

Python 코드 (Telegram)

/* * 이 Arduino UNO Q 코드는 newbiely.kr 에서 개발되었습니다 * 이 Arduino UNO Q 코드는 어떠한 제한 없이 공개 사용을 위해 제공됩니다. * 상세한 지침 및 연결도에 대해서는 다음을 방문하세요: * https://newbiely.kr/tutorials/arduino-uno-q/arduino-uno-q-rs422 */ from arduino.app_utils import * import requests import time TELEGRAM_BOT_TOKEN = "YOUR_TELEGRAM_BOT_TOKEN" CHAT_ID = "YOUR_CHAT_ID" last_update_id = 0 def get_updates(): global last_update_id url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/getUpdates" params = {"offset": last_update_id + 1, "timeout": 5} try: response = requests.get(url, params=params, timeout=10) data = response.json() if data["ok"]: return data["result"] except Exception as e: print(f"Error getting updates: {e}") return [] def send_message(chat_id, text): url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage" payload = {"chat_id": chat_id, "text": text} try: requests.post(url, data=payload, timeout=10) except Exception as e: print(f"Error sending message: {e}") def loop(): updates = get_updates() for update in updates: last_update_id = update["update_id"] if "message" not in update: continue message = update["message"] chat_id = message["chat"]["id"] text = message.get("text", "").strip() print(f"Received: {text}") if text == "/start": send_message(chat_id, "Arduino UNO Q RS422 Bot\n" "/send <message> - Send a message via RS422\n" "/read - Read data received from RS422") elif text.startswith("/send"): parts = text.split(" ", 1) if len(parts) < 2: send_message(chat_id, "Usage: /send <message>") else: result = Bridge.call("send_rs422", parts[1]) send_message(chat_id, f"Sent via RS422: {parts[1]}") elif text == "/read": data = Bridge.call("get_received") if data: send_message(chat_id, f"Received via RS422:\n{data}") else: send_message(chat_id, "No data received yet.") else: send_message(chat_id, "Unknown command. Send /start for help.") time.sleep(0.3) App.run(user_loop=loop)

빠른 단계

  • YOUR_TELEGRAM_BOT_TOKEN을 BotFather에서 얻은 실제 봇 토큰으로 바꿉니다.
  • YOUR_CHAT_ID를 Telegram 채팅 ID로 바꿉니다.
  • Python 코드를 앱의 Python 파일에 붙여넣습니다(같은 MCU 스케치 유지).
  • Run 버튼을 클릭합니다 — Telegram에서 /send Hello를 보내 RS422를 통해 데이터를 전송합니다.

App Lab 콘솔 출력

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:10:05] Received: /send Hello RS422 device! [2026-04-29 09:10:09] Received: /read
Telegram
Telegram 12:45
Welcome to Telegram!
ArduinoBot 10:19
Chatting with Arduino...
telegram-botfather
BotFather Yesterday
Your bot has been created.

ArduinoBot

bot
Today
/send Hello RS422 device!
10:15 AM ✓✓
Sent via RS422: Hello RS422 device!
10:16 AM
/read
10:17 AM ✓✓
Received via RS422: Hello RS422 device!
10:18 AM

OpenClaw

You can adapt the OpenClaw to this tutorial by refering the instruction on 아두이노 우노 Q - OpenClaw Tutorial

프로젝트 아이디어

Arduino UNO Q와 RS422 통신으로 많은 유용한 프로젝트를 만들 수 있습니다:

  • CNC 기계 모니터: Arduino UNO Q를 RS422를 통해 CNC 컨트롤러에 연결합니다; MCU는 위치 및 상태 메시지를 읽으며, Python은 가공이 시작, 일시 중지 또는 완료될 때 Telegram에 실시간 업데이트를 보냅니다
  • 고속 카메라 트리거: RS422를 사용하여 산업용 카메라에 정확한 트리거 신호를 보냅니다; Python은 Bridge를 통해 트리거 타이밍을 결정하고 MCU에 명령을 보내면, MCU는 RS422 차동 선 쌍을 통해 트리거 펄스를 전송합니다
  • 장거리 센서 배열: RS422를 500m에 걸쳐 원격 환경 센서 스테이션에 연결합니다; MCU는 RS422를 통해 센서 데이터를 읽고 Python은 판독값을 로깅하며 값이 임계값을 초과할 때 Telegram 경고를 보냅니다
  • PLC 상태 대시보드: PLC의 RS422 프로그래밍 포트에 연결하여 진단 데이터를 읽습니다; Python은 데이터를 상태 보고서로 포맷하고 예정된 간격으로 Telegram에 보냅니다
  • 정밀 모션 컨트롤러: Telegram에서 Bridge를 통해 MCU로 위치 명령을 보내면, MCU는 RS422를 통해 서보 드라이버로 이를 전달합니다 — 정밀 액추에이터의 원격 전이중 제어를 가능하게 합니다

자신에게 도전하세요

Arduino UNO Q의 RS422를 더 탐구할 준비가 되었나요? 이 도전과제를 시도하세요:

  • 쉬움: /ping Telegram 명령을 추가하여 고정 문자열 PING\n을 RS422를 통해 보내고 get_received로 즉시 응답을 읽습니다 — 연결된 RS422 장치가 반응하는지 테스트하는 데 유용합니다.
  • 중간: 메시지 로그 구현: Python은 마지막 10개의 수신 RS422 메시지를 Python 리스트에 저장합니다; /history Telegram 명령은 저장된 모든 메시지를 번호가 지정된 목록으로 반환합니다 — 휴대폰에서 최근 통신 기록을 제공합니다.
  • 고급: 전이중 RS422 릴레이 구축: Python은 send_rs422로 10초마다 하트비트 문자열을 보내는 루프를 유지하고, get_received로 수신 데이터를 읽고, 이를 Telegram으로 전달합니다 — 동시에 Telegram 명령을 청취하여 사용자 정의 메시지를 보내면, 완전한 양방향 RS422-to-Telegram 게이트웨이를 만듭니다.