Skip to main content

Semtech SX126X LoRa driver for Jetson TX2

Project description

jetson-SX126X

Semtech SX126X LoRa driver for Jetson TX2.
This library is ported and modified from micropySX126X by ehong-tl.

Constructors (Similar for SX1261 and SX1268)

class sx1262.SX1262(cs, irq, rst, gpio, device='/dev/spidev3.0', baudrate=2000000)
Create and initialize SX1262 object.

The parameters are:

  • cs : NSS pin
  • irq : DIO1 pin
  • rst : RESET pin
  • gpio : BUSY pin
  • device : spidev device path
  • baudrate : SPI bus baud rate

Methods (Similar for SX1261 and SX1268)

General

SX1262.setFrequency(freq)
Set frequency in MHz.
Return: Status (Refer to Constants Status dictionary)

SX1262.setOutputPower(power)
Set TX power in dBm.
Return: Status

SX1262.setBlockingCallback(blocking, callback=None)
Set TX/RX blocking mode and interrupt callback.
If blocking = True, TX/RX is set to blocking mode and callback function will be ignored.
If blocking = False, TX/RX is set to non blocking mode and callback function will be triggered with events argument upon TX/RX events.
If callback = None, events callback function will be disabled.

SX1262.getRSSI()
Get RX RSSI in dBm.
Return: RSSI value

SX1262.getTimeOnAir(len)
Get RX time on air according to message length, len = message length.
Return: Time on air value

SX1262.send(data)
Send message, data type must be bytes or bytearray.
Return: Payload length, status

SX1262.recv(len=0, timeout_en=False, timeout_ms=0)
Read RX message.
len = Message length, if 0, default to SX126X_MAX_PACKET_LENGTH
timeout_en = Enable RX timeout, if False, function blocking indefinitely until message received (Only in blocking mode)
timeout_ms = RX timeout in ms, 0 means timeout = 100 LoRa symbols length for LoRa or timeout = 500% expected time-on-air for FSK (Only in blocking mode)
Return: Payload, status

LoRa

SX1262.begin(freq=434.0, bw=125.0, sf=9, cr=7, syncWord=0x12, power=14, currentLimit=60.0
preambleLength=8, implicit=False, implicitLen=0xFF, crcOn=True, txIq=False, rxIq=False,
tcxoVoltage=1.6, useRegulatorLDO=False, blocking=True)

This method is used to set LoRa configuration.

The parameters are:

  • freq : Frequency in MHz
  • bw : Bandwidth in kHz
  • sf : Spreading factor, 5 to 12
  • cr : Coding rate, 5 to 8
  • syncWord : Sync word, private = 0x12, public = 0x34
  • power : TX power in dBm
  • currentLimit : Current limit in mA
  • preambleLength : Preamble length
  • implicit : Implicit or explicit header, implicit = True
  • implicitLen : Implicit header payload length
  • crcOn : CRC on or off
  • txIq : TX invert IQ
  • rxIq : RX invert IQ
  • tcxoVoltage : TCXO input voltage in V
  • useRegulatorLDO : Use LDO regulator = True, use DC-DC regulator = False
  • blocking : Blocking TX/RX = True, non blocking TX/RX = False

Return: Status

SX1262.setBandwidth(bw)
Set LoRa bandwidth in kHz.
Return: Status

SX1262.setCodingRate(cr)
Set LoRa coding rate, 5 to 8.
Return: Status

SX1262.setPreambleLength(preambleLength)
Set LoRa preamble length.
Return: Status

SX1262.setSpreadingFactor(sf)
Set LoRa spreading factor, 5 to 12.
Return: Status

SX1262.setSyncWord(syncWord, [controlBits])
Set LoRa sync word, private = 0x12, public = 0x34.
Optional parameter controlBits, default value is 0x44.
e.g. syncWord = 0xAB, controlBits = 0xCD -> SX126x 2 bytes sync word = 0xACBD
e.g. syncWord = 0x12, controlBits = 0x44 -> SX126x 2 bytes sync word = 0x1424
Return: Status

SX1262.explicitHeader()
Enable LoRa explicit header mode.
Return: Status

SX1262.implicitHeader(implicitLen)
Enable LoRa implicit header mode with implicit length parameter.
Return: Status

SX1262.forceLDRO(enable)
Force enable Low Data Rate Optimization.
Return: Status

SX1262.autoLDRO()
Enable auto Low Data Rate Optimization.
Return: Status

SX1262.setCRC(crcOn)
Set LoRa CRC mode.
Return: Status

SX1262.setTxIq(txIq)
Set LoRa TX invert IQ mode.

SX1262.setRxIq(rxIq)
Set LoRa RX invert IQ mode.

SX1262.getSNR()
Get LoRa RX SNR in dB.
Return: SNR value

FSK

SX1262.beginFSK(freq=434.0, br=48.0, freqDev=50.0, rxBw=156.2, power=14, currentLimit=60.0,
preambleLength=16, dataShaping=0.5, syncWord=[0x2D, 0x01], syncBitsLength=16,
addrFilter=SX1262.ADDR_FILT_OFF, addr=0x00, crcLength=2, crcInitial=0x1D0F, crcPolynomial=0x1021,
crcInverted=True, whiteningOn=True, whiteningInitial=0x0100,
fixedPacketLength=False, packetLength=0xFF, preambleDetectorLength=SX1262.PREAMBLE_DETECT_16,
tcxoVoltage=1.6, useRegulatorLDO=False,
blocking=True)

This method is used to set FSK configuration.

The parameters are:

  • freq : Frequency in MHz
  • br : Bit rate in kbps
  • freqDev : Frequency deviation in kHz
  • rxBW : RX bandwidth in kHz
  • power : TX power in dBm
  • currentLimit : Current limit in mA
  • preambleLength : Preamble length
  • dataShaping : Time-bandwidth product of the Gaussian filter to be used for shaping
  • syncWord : Sync word
  • syncBitsLength : Sync word length in bit
  • addrFilter : Address filtering, refer to Constants FSK address filtering
  • addr : Address for address filtering
  • crcLength : CRC length, 0, 1 or 2
  • crcInitial: CRC initial value
  • crcPolynomial : Polynomial for CRC calculation
  • crcInverted : Invert CRC bytes
  • whiteningOn : Enable whitening
  • whiteningInitial : Initial value used for whitening LFSR
  • fixedPacketLength : Enable fixed packet length mode
  • packetLength : Packet length in bytes (fixed packet length mode) or maximum packet length in bytes (variable packet length mode)
  • preambleDetectorLength : Minimum preamble detection length, refer to Constants FSK preamble detector length
  • tcxoVoltage : TCXO input voltage in V
  • useRegulatorLDO : Use LDO regulator = True, use DC-DC regulator = False
  • blocking : Blocking TX/RX = True, non blocking TX/RX = False

Return: Status

SX1262.setBitRate(br)
Set FSK bit rate in kbps.
Return: Status

SX1262.setFrequencyDeviation(freqDev)
Set FSK frequency deviation in kHz.
Return: Status

SX1262.setRxBandwidth(rxBw)
Set FSK RX bandwidth in kHz.
Return: Status

SX1262.setDataShaping(dataShaping)
Set FSK time-bandwidth product of the Gaussian filter to be used for shaping.
Return: Status

SX1262.setSyncBits(syncWord, bitsLen)
Set FSK sync word and sync bits length.
syncWord = Sync word in list
bitsLen = Sync word bit length
Return: Status

SX1262.setPreambleLength(preambleLength)
Set FSK preamble length.
Return: Status

SX1262.setPreambleDetectorLength(preambleDetectorLength)
Set minimum preamble detection length, refer to Constants FSK preamble detector length.

SX1262.setNodeAddress(addr)
Activate address filtering on node address addr.
Return: Status

SX1262.setBroadcastAddress(addr)
Activate address filtering on node and broadcast address addr.
Return: Status

SX1262.disableAddressFiltering()
Disable address filtering.
Return: Status

SX1262.setCRC(len, initial=0x1D0F, polynomial=0x1021, inverted=True)
Set FSK CRC.
len = CRC length, 0, 1 or 2
initial = CRC initial
polynomial = Polynomial used for CRC calculation
inverted = Enable CRC bytes inversion
Return: Status

SX1262.setWhitening(enabled, initial=0x0100)
Set FSK whitening.
initial = Initial value for whitening LFSR
Return: Status

SX1262.fixedPacketLengthMode(len)
Set FSK fixed packet length mode.
len = Packet length in bytes
Return: Status

SX1262.variablePacketLengthMode(maxLen)
Set FSK variable packet length mode.
maxLen = Max packet length in bytes
Return: Status

Constants (Similar for SX1261 and SX1268)

Events: SX1262.TX_DONE, SX1262.RX_DONE
FSK address filter: SX1262.ADDR_FILT_OFF, SX1262.ADDR_FILT_NODE, SX1262.ADDR_FILT_NODE_BROAD
FSK preamble detector length: SX1262.PREAMBLE_DETECT_OFF, SX1262.PREAMBLE_DETECT_X -> X = 8, 16, 24, 32
Status dictionary: SX1262.STATUS

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jetson-SX126X-1.0.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

jetson_SX126X-1.0.0-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file jetson-SX126X-1.0.0.tar.gz.

File metadata

  • Download URL: jetson-SX126X-1.0.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for jetson-SX126X-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1b5835e6f256b239c12445fdf3760e99367513b7f27135a09b24ce9ec4f390aa
MD5 b8b68f96f76dbbda1347c0e14b85704b
BLAKE2b-256 3244430b085535e0f986a7aa9976918adb3400da874fdcc645d82c37eda0bfb2

See more details on using hashes here.

File details

Details for the file jetson_SX126X-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for jetson_SX126X-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 512599b5a78e369ecffa9ab4bf6f3f3b6f409cae079b32dbe6df47d3758dbbba
MD5 776f0e05416f6b8566c62e7fd22aeb42
BLAKE2b-256 07d5beff9bc604eff76163c6f8480e27b65ac073f4f481411432d6d5c1cda6d1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page