MicroPython LoRa EBYTE E220 LLCC68 device library complete and tested with Arduino, esp8266, esp32, STM32 and Raspberry Pi Pico (rp2040 boards).
OTHER License
To install the library execute the following command:
pip install ebyte-lora-e220
Here an example of constructor, you must pass the UART interface and (if you want, but It's reccomended) the AUX pin, M0 and M1.
from lora_e220 import LoRaE220
from machine import UART
uart2 = UART(2)
lora = LoRaE220('400T22D', uart2, aux_pin=15, m0_pin=21, m1_pin=19)
code = lora.begin()
print("Initialization: {}", ResponseStatusCode.get_description(code))
from lora_e220 import LoRaE220, print_configuration
from lora_e220_operation_constant import ResponseStatusCode
code, configuration = lora.get_configuration()
print("Retrieve configuration: {}", ResponseStatusCode.get_description(code))
print_configuration(configuration)
The result
----------------------------------------
Initialization: {} Success
Retrieve configuration: {} Success
----------------------------------------
HEAD : 0xc1 0x0 0x8
AddH : 0x0
AddL : 0x0
Chan : 23 -> 433
SpeedParityBit : 0b0 -> 8N1 (Default)
SpeedUARTDatte : 0b11 -> 9600bps (default)
SpeedAirDataRate : 0b10 -> 2.4kbps (default)
OptionSubPacketSett: 0b0 -> 200bytes (default)
OptionTranPower : 0b0 -> 22dBm (Default)
OptionRSSIAmbientNo: 0b0 -> Disabled (default)
TransModeWORPeriod : 0b11 -> 2000ms (default)
TransModeEnableLBT : 0b0 -> Disabled (default)
TransModeEnableRSSI: 0b0 -> Disabled (default)
TransModeFixedTrans: 0b0 -> Transparent transmission (default)
----------------------------------------
You can set only the desidered parameter, the other will be set to default value.
configuration_to_set = Configuration('400T22D')
configuration_to_set.ADDL = 0x02
configuration_to_set.ADDH = 0x01
configuration_to_set.CHAN = 23
configuration_to_set.SPED.airDataRate = AirDataRate.AIR_DATA_RATE_100_96
configuration_to_set.SPED.uartParity = UARTParity.MODE_00_8N1
configuration_to_set.SPED.uartBaudRate = UARTBaudRate.BPS_9600
configuration_to_set.OPTION.transmissionPower = TransmissionPower('400T22D').\
get_transmission_power().POWER_10
# or
# configuration_to_set.OPTION.transmissionPower = TransmissionPower22.POWER_10
configuration_to_set.OPTION.RSSIAmbientNoise = RssiAmbientNoiseEnable.RSSI_AMBIENT_NOISE_ENABLED
configuration_to_set.OPTION.subPacketSetting = SubPacketSetting.SPS_064_10
configuration_to_set.TRANSMISSION_MODE.fixedTransmission = FixedTransmission.FIXED_TRANSMISSION
configuration_to_set.TRANSMISSION_MODE.WORPeriod = WorPeriod.WOR_1500_010
configuration_to_set.TRANSMISSION_MODE.enableLBT = LbtEnableByte.LBT_DISABLED
configuration_to_set.TRANSMISSION_MODE.enableRSSI = RssiEnableByte.RSSI_ENABLED
configuration_to_set.CRYPT.CRYPT_H = 1
configuration_to_set.CRYPT.CRYPT_L = 1
# Set the new configuration on the LoRa module and print the updated configuration to the console
code, confSetted = lora.set_configuration(configuration_to_set)
I create a CONSTANTS class for each parameter, here a list: AirDataRate, UARTBaudRate, UARTParity, TransmissionPower, ForwardErrorCorrectionSwitch, WirelessWakeUpTime, IODriveMode, FixedTransmission
Here an example of send data, you can pass a string
lora.send_transparent_message('pippo')
lora.send_fixed_message(0, 2, 23, 'pippo')
Here the receiver code
while True:
if lora.available() > 0:
code, value = lora.receive_message()
print(ResponseStatusCode.get_description(code))
print(value)
utime.sleep_ms(2000)
If you want receive RSSI also you must enable it in the configuration
configuration_to_set.TRANSMISSION_MODE.enableRSSI = RssiEnableByte.RSSI_ENABLED
and set the flag to True in the receive_message method
code, value, rssi = lora.receive_message(True)
Result
Success!
pippo
Here an example of send data, you can pass a dictionary
lora.send_transparent_dict({'pippo': 'fixed', 'pippo2': 'fixed2'})
lora.send_fixed_dict(0, 0x01, 23, {'pippo': 'fixed', 'pippo2': 'fixed2'})
Here the receiver code
while True:
if lora.available() > 0:
code, value = lora.receive_dict()
print(ResponseStatusCode.get_description(code))
print(value)
print(value['pippo'])
utime.sleep_ms(2000)
if you want receive RSSI also you must enable it in the configuration
configuration_to_set.TRANSMISSION_MODE.enableRSSI = RssiEnableByte.RSSI_ENABLED
and set the flag to True in the receive_dict method
code, value, rssi = lora.receive_dict(True)
Result
Success!
{'pippo': 'fixed', 'pippo2': 'fixed2'}
fixed
You can order the PCB here
Instruction and assembly video on 6 part of the guide
You can order the PCB here
Instruction and assembly video on 6 part of the guide