EBYTE LoRa E220 devices circuitpython library (LLCC68)
Changelog
- 2023-07-16 0.0.2 Fix retrieve transmisison power Issue
- 2024-02-06 0.0.1 Fully functional library
Installation
To install the library execute the following command:
pip install ebyte-lora-e220-circuitpython
Library usage
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.
Initialization
from lora_e220 import LoRaE220
import busio
import board
uart2 = busio.UART(board.TX2, board.RX2, baudrate=9600)
lora = LoRaE220('400T22D', uart2, aux_pin=board.D15, m0_pin=board.D21, m1_pin=board.D19)
Start the module transmission
code = lora.begin()
print("Initialization: {}", ResponseStatusCode.get_description(code))
Get Configuration
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)
----------------------------------------
Set Configuration
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
Send string message
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)
time.sleep(2)
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
Send dictionary message
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'])
time.sleep(2)
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
This is a porting of the Arduino library for EBYTE LoRa E220 devices to circuitpython
Tutorial of the original library
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: settings and basic usage
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: library
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: configuration
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: fixed transmission, broadcast, monitor, and RSSI
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: power saving and sending structured data
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: WOR microcontroller and Arduino shield
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: WOR microcontroller and WeMos D1 shield
- Ebyte LoRa E220 device for Arduino, esp32 or esp8266: WOR microcontroller and esp32 dev v1 shield
LLCC68
LoRa Smart Home (LLCC68) is a sub-GHz LoRa® RF Transceiver for medium-range indoor and indoor to outdoor wireless applications. SPI interface. Pin-to-pin is compatible with SX1262. SX1261, SX1262, SX1268, and LLCC68 are designed for long battery life with just 4.2 mA of active receive current consumption. The SX1261 can transmit up to +15 dBm, and the SX1262, SX1268, and LLCC68 can transmit up to +22 dBm with highly efficient integrated power amplifiers.
These devices support LoRa modulation for LPWAN use cases and (G)FSK modulation for legacy use cases. The devices are highly configurable to meet different application requirements for consumer use. The device provides LoRa modulation compatible with Semtech transceivers used by the LoRaWAN® specification released by the LoRa Alliance®. The radio is suitable for systems targeting compliance with radio regulations, including but not limited to ETSI EN 300 220, FCC CFR 47 Part 15, China regulatory requirements, and the Japanese ARIB T-108. Continuous frequency coverage from 150MHz to 960MHz allows the support of all major sub-GHz ISM bands around the world.
Features
- The new LoRa spread spectrum modulation technology developed based on LLCC68, it brings a more extended communication distance and stronger anti-interference ability;
- Support users to set the communication key by themselves, and it cannot be read, which significantly improves the confidentiality of user data;
- Support LBT function, monitor the channel environment noise before sending, which significantly improves the communication success rate of the module in harsh environments;
- Support RSSI signal strength indicator function for evaluating signal quality, improving communication network, and ranging;
- Support air wakeup, that is ultra-low power consumption, suitable for battery-powered applications;
- Support point to point transmission, broadcast transmission, channel sense;
- Support deep sleep, the power consumption of the whole machine is about 5uA in this mode;
- The module has built-in PA+LNA, and the communication distance can reach 5km under ideal conditions;
- The parameters are saved after power-off, and the module will work according to the set parameters after power-on;
- Efficient watchdog design, once an exception occurs, the module will automatically restart and continue to work according to the previous parameter settings;
- Support the bit rate of2.4k~62.5kbps;
- Support 3.0~5.5V power supply, power supply greater than 5V can guarantee the best performance;
- Industrial standard design, supporting long-term use at -40~+85℃;
Comparison
| LLCC68 | SX1278-SX1276 |
|---|
| Distance | > 11Km | 8Km |
| Rate (LoRa) | 1.76Kbps – 62.5Kbps | 0.3Kbps – 19.2Kbps |
| Sleep power consumption | 2µA | 5µA |
Library
Library for Ebyte LoRa E220 LLCC68 device for Arduino, esp32 or esp8266.
Pinout
| Pin No. | Pin item | Pin direction | Pin application |
|---|
| 1 | M0 | Input(weak pull-up) | Work with M1 & decide the four operating modes. Floating is not allowed; it can be ground. |
| 2 | M1 | Input(weak pull-up) | Work with M0 & decide the four operating modes. Floating is not allowed; it can be ground. |
| 3 | RXD | Input | TTL UART inputs connect to external (MCU, PC) TXD output pin. It can be configured as open-drain or pull-up input. |
| 4 | TXD | Output | TTL UART outputs connect to external RXD (MCU, PC) input pin. Can be configured as open-drain or push-pull output |
5 | AUX | Output | To indicate the module’s working status & wake up the external MCU. During the procedure of self-check initialization, the pin outputs a low level. It can be configured as open-drain or push-pull output (floating is allowed). |
| 6 | VCC | | Power supply 3V~5.5V DC |
| 7 | GND | | Ground |
As you can see, you can set various modes via M0 and M1 pins.
| Mode | M1 | M0 | Explanation |
|---|
| Normal | 0 | 0 | UART and wireless channels are open, and transparent transmission is on |
| WOR Transmitter | 0 | 1 | WOR Transmitter |
| WOR Receiver | 1 | 0 | WOR Receiver (Supports wake up over air) |
| Deep sleep mode | 1 | 1 | The module goes to sleep (automatically wake up when configuring parameters) |
Some pins can be used statically, but If you connect them to the microcontroller and configure them in the library, you gain in performance and can control all modes via software. Still, we are going to explain better next.
Fully connected schema
As I already said, It’s not essential to connect all pins to the microcontroller’s output; you can put M0 and M1 pins to HIGH or LOW to get the desired configuration. If you don’t connect AUX, the library set a reasonable delay to ensure that the operation is complete (If you have trouble with the device freezing, you must put a pull-up 4.7k resistor or better connect to the device. ).
AUX pin
When transmitting data can be used to wake up external MCU and return HIGH on data transfer finish.
When receiving, AUX goes LOW and returns HIGH when the buffer is empty.
It’s also used for self-checking to restore regular operation (on power-on and sleep/program mode).
esp8266
esp8266 connection schema is more straightforward because it works at the same voltage of logical communications (3.3v).