sx126x
A Python library for interfacing with SX126X LoRa modules. This library provides a simple API for configuring and using SX126X devices for wireless communication.
Hardware Requirements
This library is designed to work with SX126X LoRa modules connected to a Raspberry Pi. The default configuration assumes the module is connected to GPIO pins 5 and 6 for mode control, but this can be customized.
Installation
Using pip:
pip install sx126x
Using uv:
uv pip install sx126x
For more information about uv, see https://docs.astral.sh/uv/
Default Configuration
| Parameter | Default Value | Description |
|---|---|---|
address |
Address.parse("242.242") |
Device address |
net_id |
1 |
Network ID |
channel |
1 |
Channel |
port |
None |
Serial port path |
pin_m0 |
6 |
GPIO 6 — Mode select pin M0 |
pin_m1 |
5 |
GPIO 5 — Mode select pin M1 |
baud_rate |
BaudRate.B9600 |
UART baud rate |
byte_size |
8 |
Number of data bits |
parity |
Parity.NONE |
Parity bit setting |
stop_bits |
1 |
Number of stop bits |
write_persist |
False |
Write registers persistently |
mode |
Mode.CONFIGURATION |
Set M0 and M1 according to mode |
timeout |
2 |
Read/write timeout in seconds |
debug |
False |
Enable debug logging |
air_speed |
AirSpeed.K2_4 |
Air data rate |
packet_size |
PacketSize.SIZE_128 |
Packet size |
ambient_noise |
AmbientNoise.DISABLED |
Ambient noise detection mode |
transmit_power |
TransmitPower.DBM_22 |
RF transmit power |
rssi |
RSSI.DISABLED |
Add RSSI to RX data |
transfer_method |
TransferMethod.FIXED |
Transmission addressing mode |
relay |
Relay.DISABLED |
Enable or disable relay functionality |
lbt |
LBT.DISABLED |
Listen Before Talk mode |
wor_control |
WORControl.TRANSMIT |
WOR (Wake On Radio) mode control |
wor_period |
WORPeriod.MS_500 |
WOR cycle period |
crypt_key |
CryptKey(0, 0) |
16-bit encryption key |
overwrite_defaults |
True |
Whether to override internal default parameters |
Usage Examples
The following examples demonstrate how to use the SX126X library for basic sending and receiving operations.
Sender
from sx126x import SX126X, Address
lora = SX126X(Address(3, 4))
lora.tx(Address(6, 9), b"Hello from device 3.4")
Receiver
from sx126x import SX126X, Address
lora = SX126X(Address(6, 9))
address, data = lora.rx()
# or
def lora_cb(address: Address, data: bytes) -> bool:
if address.__str__() == "3.4" and data == b"Hello from device 3.4":
print(f"Received message: {data.decode()}")
return False # stop receiving
return True # continue receiving
lora.rx_loop(lora_cb)
Metadata
Release files for sx126x 2.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sx126x-2.2.4.tar.gz | 29.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sx126x-2.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.5 kB
Release files / sx126x-2.2.4.tar.gz
| Download URL | sx126x-2.2.4.tar.gz |
|---|---|
| Size | 29.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
abd38f0147475f37f178a5f34f57484517c0229913e319f3fc23a7d82c6f80d6
|
|
BLAKE2b-256 checksum How to use checksums |
a2405cc09c8d0a0d6f2cd14dd8c429a2d1ab1c1fea563f435cce6a18511956ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2025.
Transparency logRelease files / sx126x-2.2.4-py3-none-any.whl
| Download URL | sx126x-2.2.4-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f722d7f4076bcb606a116053666e7a9f996360f5fffb8aca72e71e37aadb87a1
|
|
BLAKE2b-256 checksum How to use checksums |
a62e0105c8cc671cc183838455f8efab284b3335f840c28a408886de4cb10c0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2025.
Transparency log