Logo
v2.2.1
  • mPython Board Contents

mPython Board Tutorial

  • Basic Tutorials
  • Advance Tutorials
  • Get Started - Coding Example

MicroPython Library

  • Python Standard library
  • MicroPython Class Library

mPython Library

  • mPython Library
    • mpython — mPython Board related built-in functions
    • music — Music related functions
    • urequests — Related functions of HTTP client
    • umqtt.simple — MQTT client function
    • gui — Provide related functions of GUI class drawing
    • audio — Provide audio playback related functions
    • radio — Radio-related functions
    • sdcard — SD Card
    • bluebit — blue:bit driver
    • parrot — mPython Expansion Board driver
    • ds18x20 — ds18b20 Temperature sensor driver
    • servo — Servo driver function
  • mPython extend library

MicroPython Syntax

  • MicroPython syntax
  • Copyright
  • release

mPython Series

  • mPython Expansion Board
mPython board
  • Docs »
  • mPython Library »
  • radio — Radio-related functions
  • Edit on GitHub

radio — Radio-related functions¶

The radio module is based on ESP-NOW Wireless broadcasting without connection provides wireless broadcast function, supports 13 Channel, and can receive broadcast messages sent by members in the same Channel, suitable for multi-board network communication within 30 meters. Parameter ———-

radio.on()¶

Turn ON wireless function

radio.off()¶

Turn OFF wireless function

radio.config(channel)¶

Configure wireless parameters

  • channel (int): Wireless channel, range 1~13
radio.receive()¶

Receive a wireless broadcast message, the message is returned as a string. Can receive up to 250 bytes of data. If no message is received, it returns None . When the internal parameter of receive is True , that is receive(True) , the (msg,mac) binary is returned. The default is receive(False) , which only returns msg.

radio.receive_bytes()¶

Receive wireless broadcast message, the message is returned in bytes. Others are the same as radio.receive() .

radio.send()¶

Send wireless broadcast message, data type as string. Return True after successful transmission, otherwise return False.

radio.send_bytes()¶

Send wireless broadcast message, byte data type. Return True after successful transmission, otherwise return False.

Radio broadcasting example¶
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import radio
import _thread

channel=2

radio.on()
radio.config(channel=channel)               # radio通道设置

def rec_loop():                             # radio接收循环
    while True:
        temp=radio.receive(True)           # radio 接收数据,返回(msg,mac)
        # temp=radio.receive()             # radio 接收数据,返回msg
        if temp:                           # 当接收到数据时打印
            print(temp)

_thread.start_new_thread(rec_loop, ())      # radio接收线程

radio.send("hello mPython!")
Next Previous

© Copyright 2018-2021 labplus.All Rights Reserved Revision b1acb551.

Built with Sphinx using a theme provided by Read the Docs.