Atomic RS485 Base

AtomRS485 Class provides a set of methods to control the RS485 module. Through the UART interface, the module can transmit and receive data, supporting various baud rates and flow control configurations.

Support the following products:

rs485 base

rs485

UiFlow2 Example

RS485 Example

Open the atoms3r_rs485_example.m5f2 project in UiFlow2.

This example demonstrates how to send and receive data using the RS485 module via the UART interface.

UiFlow2 Code Block:

example.png

Example output:

None

MicroPython Example

RS485 Example

This example demonstrates how to send and receive data using the RS485 module via the UART interface.

MicroPython Code Block:

 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")

Example output:

None

API

AtomRS485

base.rs232.AtomRS485

alias of AtomRS232