.. _radio: .. module:: radio :synopsis: Wireless broadcast related functions :mod:`radio` --- radio wireless broadcast functions --------------------------------------------------- The radio module implements wireless broadcast functionality based on the `ESP-NOW `_ connectionless Wi-Fi communication protocol. It supports 13 channels. Within the same channel, it can receive broadcast messages sent by members, making it suitable for multi-board networking communication within a range of 30 meters. Functions ---------- .. py:method:: radio.on() Turn on the wireless function .. py:method:: radio.off() Turn off the wireless function .. py:method:: radio.config(channel) Configure wireless parameters - ``channel`` (int): The wireless channel, range 1~13 .. py:method:: radio.receive() Receive wireless broadcast messages, returned as a string. It can receive up to 250 bytes of data. If no message is received, it returns ``None``. When the parameter of ``receive`` is ``True``, i.e. ``receive(True)``, it returns a (msg, mac) tuple. The default is ``receive(False)``, i.e. it returns only msg. .. py:method:: radio.receive_bytes() Receive wireless broadcast messages, returned as bytes. Everything else is the same as ``radio.receive()``. .. py:method:: radio.send() Send a wireless broadcast message; the data type sent is a string. It returns True after a successful send, otherwise False. .. py:method:: radio.send_bytes() Send a wireless broadcast message; the data type sent is bytes. It returns True after a successful send, otherwise False. .. literalinclude:: /_static/products/mpython-s3/_static/examples/radio/radio.py :caption: Wireless broadcast example :linenos: