RF433R Unit
This library is the driver for Unit RF433R.
Support the following products:
Note
ESP32-S3 related devices, such as CoreS2 and AtomS3, are not supported yet.
UiFlow2 Example:
Receive data
Open the basic_rf433r_recv_example.m5f2 project in UiFlow2.
The example program demonstrates communication using RF433TUnit and RF433RUnit. Please refer to the sending end. RF433TUnit
UiFlow2 Code Block:
Example output:
None
MicroPython Example:
Receive data
The example program demonstrates communication using RF433TUnit and RF433RUnit. Please refer to the sending end. RF433TUnit
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 unit import RF433RUnit 9 10 11title0 = None 12label_cnt = None 13rf433r_0 = None 14rf433r_data = None 15cnt = None 16 17 18def rf433r_0_receive_event(received_data): 19 global title0, label_cnt, rf433r_0, rf433r_data, cnt 20 rf433r_data = received_data 21 cnt = rf433r_data[-1] 22 label_cnt.setText(str((str("Count: ") + str(cnt)))) 23 print(rf433r_data) 24 25 26def setup(): 27 global title0, label_cnt, rf433r_0, rf433r_data, cnt 28 M5.begin() 29 title0 = Widgets.Title("RF433R Recv Data", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu24) 30 label_cnt = Widgets.Label("Count", 115, 118, 1.0, 0x00FF00, 0x000000, Widgets.FONTS.DejaVu18) 31 rf433r_0 = RF433RUnit((36, 26)) 32 rf433r_0.set_recv_callback(rf433r_0_receive_event) 33 rf433r_0.start_recv() 34 35 36def loop(): 37 global title0, label_cnt, rf433r_0, rf433r_data, cnt 38 M5.update() 39 40 41if __name__ == "__main__": 42 try: 43 setup() 44 while True: 45 loop() 46 except (Exception, KeyboardInterrupt) as e: 47 try: 48 from utility import print_error_msg 49 50 print_error_msg(e) 51 except ImportError: 52 print("please update to latest firmware")
Example output:
None
API
RF433RUnit
- class unit.rf433r.RF433RUnit(port=None)
Bases:
object
Create an RF433RUnit object.
UiFlow2 Code Block:
MicroPython Code Block:
from unit import RF433RUnit unit_rf433r = RF433RUnit(port=(36, 26))
- read()
Read data.
- Returns:
receive data.
- Return type:
bytes | None
If no data is received, return None.
UiFlow2 Code Block:
MicroPython Code Block:
unit_rf433r.read()
- set_recv_callback(callback)
Set receive data callback function.
- Parameters:
callback – A function that will be called when data is received.
UiFlow2 Code Block:
MicroPython Code Block:
def unit_rf433r_receive_event(received_data): rf433r_data = received_data unit_rf433r.set_recv_callback(unit_rf433r_receive_event)
- start_recv()
Start receive data.
UiFlow2 Code Block:
MicroPython Code Block:
unit_rf433r.start_recv()
- Return type:
None
- stop_recv()
Stop receive data.
UiFlow2 Code Block:
MicroPython Code Block:
unit_rf433r.stop_recv()
- Return type:
None