Sensors and I/O

UART Echo

Starting point for meters, PLCs and modules. RS485 is only a level shift.

Sensors and I/O UART to a meter ESP32 family

Official path: examples/peripherals/uart/uart_echo

01 Overview

Read a byte, write it back. Proves pins, baud and wiring.

  • Use when: second UART bring-up, meter link.
  • Skip when: the protocol is already stable (add Modbus on top).

02 Hardware

  • Cross TX/RX. TTL to TTL — never raw RS232 voltages.
  • RS485 needs a transceiver, A/B, 120Ω, DE/RE.
  • Common ground or you get noise, not data.

03 Software flow

1. Port, baud, buffers.

2. Read loop, echo write.

3. Products parse frames instead of echoing forever.

04 Core points

  • Garbage is usually ground or levels, then firmware.
  • Custom work: RS485 hardware, protocol, isolation.

中文

传感器与外设

UART Echo 串口

接电表、PLC、模组的起点。RS485 只是电平转换。

传感器与外设 串口接仪表 ESP32 family

官方路径: examples/peripherals/uart/uart_echo

01 项目概述

从 UART 读什么写回什么。证明口线、波特率、接线。

  • 适用: 调试第二串口、对接仪表。
  • 不适用: 已经稳定的协议栈(在 echo 之上加 Modbus)。

02 项目硬件描述

  • TX/RX 交叉。TTL 对 TTL,不要直接接 RS232 12V。
  • RS485 要加收发器、A/B、120Ω、DE/RE 脚。
  • 共地,否则乱码。

03 项目软件流程描述

1. 配端口、波特率、缓冲。

2. 读循环,echo 写出。

3. 产品改为帧解析,而不是永久 echo。

04 项目核心点

  • 乱码先查地和电平,再查固件。
  • 可定制: RS485 硬件、协议、隔离。