LoRaE220-433 Unit
Support the following products:
Micropython TX Example:
import os, sys, io
import M5
from M5 import *
from unit import LoRaE220433Unit
import time
lorae220433_0 = LoRaE220433Unit(1, (18, 17))
while True:
lorae220433_0.send(0x9999, 0, 'Hello M5')
time.sleep(1)
Micropython RX Example:
import os, sys, io
import M5
from M5 import *
from unit import LoRaE220433Unit
def lorae220433_0_receive_event(received_data, rssi):
print(received_data.decode())
print(rssi)
lorae220433_0 = LoRaE220433Unit(1, (13, 14))
lorae220433_0.receive_none_block(lorae220433_0_receive_event)
UIFLOW2 TX Example:
UIFLOW2 RX Example:
Working Mode
Mode (0-3) |
M1 |
M0 |
Function description |
0:Transmission Mode |
0 |
0 |
SEND: Users can enter data through the serial port, and the module will start wireless transmission. RECEIVE: The wireless receiving function of the module is enabled, and the wireless data will be output through the TXD pin of the serial port after receiving it. |
1:WOR Sending Mode |
0 |
1 |
SEND: Wirelessly sending data on RECEIVE: Wireless receiving data on NOTE: Support Air Wake Up |
2:WOR Receiving Mode |
1 |
0 |
SEND: Wirelessly sending data off RECEIVE: Wireless receiving data on NOTE: Support Air Wake Up |
3:Configuration Mode |
1 |
1 |
SEND: Wirelessly sending data off RECEIVE: Wireless receiving data off CONFIGURATION: Users can access registers to configure module status |
class LoRaE220433Unit
Constructors
- class LoRaE220433Unit(id, port)
Create a LoRaE220433Unit object.
- The parameters is:
port_id
uart port ID.port
uart pin tuple, which contains:(tx_pin, rx_pin)
.
UIFLOW2:
Methods
- LoRaE220433Unit.setup(own_address=0, own_channel=0, encryption_key=0x0000, air_data_rate=LoRaE220433Unit.AIRRATE_2_4K, subpacket_size=LoRaE220433Unit.SUBPACKET_200_BYTE, rssi_ambient_noise_flag=LoRaE220433Unit.RSSI_AMBIENT_NOISE_DISABLE, transmitting_power=LoRaE220433Unit.TX_POWER_22dBm, rssi_byte_flag=LoRaE220433Unit.RSSI_BYTE_DISABLE, transmission_method_type=LoRaE220433Unit.UART_TT_MODE, wor_cycle=LoRaE220433Unit.WOR_2000MS) bool
Note
Available when LoRaE220433Unit working mode is 3. Please refer to working mode table for the working mode.
Set module parameters.
- The parameters is:
own_address
: Local address.own_channel
: Native channel.encryption_key
: Encryption key.air_data_rate
: Data transmission rate.subpacket_size
: Maximum packet length.rssi_ambient_noise_flag
: RSSI Ambient Noise.transmitting_power
: Transmit power.rssi_byte_flag
: Output RSSI strength bytes.transmission_method_type
: transmission mode.lbt_flag
: Parameter no longer used.wor_cycle
: Wireless wake-up time.
UIFLOW2:
- LoRaE220433Unit.available_data() int
Note
Available when the working mode of LoRaE220433Unit is 0 / 1 / 2. Please refer to working mode table for the working mode.
Returns an integer counting the number of bytes that can be read without blocking. It will return 0 if there are no bytes available and a positive number if there are bytes.
UIFLOW2:
- LoRaE220433Unit.receive(timeout=1000) tuple[bytes, int]
Note
Available when the working mode of LoRaE220433Unit is 0 / 1 / 2. Please refer to working mode table for the working mode.
Use blocking method to receive data.
timeout
is used to set the reception timeout, the unit is ms.UIFLOW2:
- LoRaE220433Unit.receive_none_block(receive_callback: function) None
Note
Available when the working mode of LoRaE220433Unit is 0 / 1 / 2. Please refer to working mode table for the working mode.
Use non-blocking mode to receive data.
receive_callback
The callback function passed in will be called when data is received.The format of receive_callback is:
def receive_callback(data: bytes, rssi: int)
UIFLOW2:
- LoRaE220433Unit.stop_receive() None
Note
Available when the working mode of LoRaE220433Unit is 0 / 1 / 2. Please refer to working mode table for the working mode.
Stop receiving data in non-blocking mode.
UIFLOW2:
- LoRaE220433Unit.send(target_address: int, target_channel: int, send_data: bytes | str) bool
Note
Available when the working mode of LoRaE220433Unit is 0 or 1. Please refer to working mode table for the working mode.
Send data to the specified destination address and channel.
The parameters is:
target_address
Target address, the address range is 0x0000 - 0xFFFF, where 0xFFFF is the broadcast address.target_channel
Target channel, valid channel range is 0 - 30.send_data
The data needs to be sent.
UIFLOW2:
Constants
- LoRaE220433Unit.AIRRATE_2_4K: int
- LoRaE220433Unit.AIRRATE_4_8K: int
- LoRaE220433Unit.AIRRATE_9_6K: int
- LoRaE220433Unit.AIRRATE_19_2K: int
- LoRaE220433Unit.AIRRATE_38_4K: int
- LoRaE220433Unit.AIRRATE_62_5K: int
rate.
- LoRaE220433Unit.SUBPACKET_200_BYTE: int
- LoRaE220433Unit.SUBPACKET_128_BYTE: int
- LoRaE220433Unit.SUBPACKET_64_BYTE: int
- LoRaE220433Unit.SUBPACKET_32_BYTE: int
Maximum packet length.
- LoRaE220433Unit.RSSI_AMBIENT_NOISE_ENABLE: int
- LoRaE220433Unit.RSSI_AMBIENT_NOISE_DISABLE: int
RSSI ambient noise.
- LoRaE220433Unit.TX_POWER_22dBm: int
- LoRaE220433Unit.TX_POWER_17dBm: int
- LoRaE220433Unit.TX_POWER_13dBm: int
- LoRaE220433Unit.TX_POWER_10dBm: int
Transmit power.