Atomic RS485 Base

AtomRS232 类提供了一套控制 RS232 模块的方法。通过 UART 接口,模块可以发送和接收数据,支持各种波特率和流量控制配置。

支持以下产品:

rs485 base

rs485

UiFlow2 Example

RS485 Example

在 UiFlow2 中打开 atoms3r_rs485_example.m5f2 项目。

本示例演示如何使用 RS485 模块通过 UART 接口发送/接收数据。

UiFlow2 代码块:

example.png

示例输出:

None

MicroPython 发送应用示例:

RS485 Example

本示例演示如何使用 RS485 模块通过 UART 接口发送/接收数据。

MicroPython 代码块:

 1# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from base import AtomRS485
 9
10
11base_rs485 = None
12
13
14def setup():
15    global base_rs485
16
17    M5.begin()
18    base_rs485 = AtomRS485(
19        2,
20        baudrate=115200,
21        bits=8,
22        parity=None,
23        stop=1,
24        tx=6,
25        rx=5,
26        txbuf=256,
27        rxbuf=256,
28        timeout=0,
29        timeout_char=0,
30        invert=0,
31        flow=0,
32    )
33
34
35def loop():
36    global base_rs485
37    M5.update()
38    if BtnA.wasPressed():
39        base_rs485.write("hello M5")
40        print("hello M5")
41    if base_rs485.any():
42        print(base_rs485.read())
43
44
45if __name__ == "__main__":
46    try:
47        setup()
48        while True:
49            loop()
50    except (Exception, KeyboardInterrupt) as e:
51        try:
52            from utility import print_error_msg
53
54            print_error_msg(e)
55        except ImportError:
56            print("please update to latest firmware")

示例输出:

None

API

AtomRS485

base.rs232.AtomRS485

AtomRS232 的别名