{"id":13801909,"url":"https://github.com/ehong-tl/micropySX126X","last_synced_at":"2025-05-13T12:32:06.725Z","repository":{"id":37432909,"uuid":"247648577","full_name":"ehong-tl/micropySX126X","owner":"ehong-tl","description":"Semtech SX126X LoRa driver for Micropython and CircuitPython.","archived":false,"fork":false,"pushed_at":"2024-10-01T07:23:51.000Z","size":104,"stargazers_count":103,"open_issues_count":16,"forks_count":22,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-12T13:38:32.907Z","etag":null,"topics":["circuitpython","lora","micropython","radio","sx1261","sx1262","sx1268","sx126x"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehong-tl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-03-16T08:28:20.000Z","updated_at":"2024-11-03T20:20:12.000Z","dependencies_parsed_at":"2024-01-29T19:30:20.615Z","dependency_job_id":"0b650b71-07f3-45bc-9aa8-ef4a271c467a","html_url":"https://github.com/ehong-tl/micropySX126X","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehong-tl%2FmicropySX126X","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehong-tl%2FmicropySX126X/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehong-tl%2FmicropySX126X/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehong-tl%2FmicropySX126X/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehong-tl","download_url":"https://codeload.github.com/ehong-tl/micropySX126X/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225217889,"owners_count":17439712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["circuitpython","lora","micropython","radio","sx1261","sx1262","sx1268","sx126x"],"created_at":"2024-08-04T00:01:29.987Z","updated_at":"2024-11-18T17:30:31.684Z","avatar_url":"https://github.com/ehong-tl.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"readme":"# micropySX126X\nSemtech SX126X LoRa driver for Micropython and CircuitPython.  \nThis library is ported and modified from [RadioLib](https://github.com/jgromes/RadioLib) by jgromes.  \nThis library supports generic and Pycom variant micropython as well as CircuitPython.  \nTested with:\n1. WiPy3.0 + Semtech SX1262MB1PAS shield (LoRa)\n2. WiPy3.0 + Ebyte E22-400M22S (LoRa)\n3. WiPy3.0 + Ebyte E22-400M30S (LoRa) - Built-in 10dB amplifier, eg. SX1268.setOutputPower(20) = 30dBm output, SX1268.setOutputPower(0) = 10 dBm output\n4. [LilyGO\u0026#174; T-Echo](https://github.com/lyusupov/POST_TEcho)\n5. Raspberry Pi Pico + [Waveshare SX126x Pico LoRa HAT](https://www.waveshare.com/pico-lora-sx1262-868m.htm)\n6. [HelTec Lora 32 v3](https://heltec.org/project/wifi-lora-32-v3/)\n\n***\\* Compile to .mpy or compile into micropython image to prevent memory issue error***\n\n## Constructors (Similar for SX1261 and SX1268)  \n***class*** **sx1262.SX1262(spi_bus, clk, mosi, miso, cs, irq, rst, gpio)**  \nCreate and initialize SX1262 object.\n\nThe parameters are:  \n- spi_bus : SPI bus ID\n- clk : SPI CLK pin\n- mosi : SPI MOSI pin\n- miso : SPI MISO pin\n- cs : NSS pin\n- irq : DIO1 pin\n- rst : RESET pin\n- gpio : BUSY pin\n\n## Methods (Similar for SX1261 and SX1268)  \n\n### General  \n**SX1262.setFrequency(freq)**  \nSet frequency in MHz.  \nReturn: Status (Refer to **Constants** Status dictionary)\n\n**SX1262.setOutputPower(power)**  \nSet TX power in dBm.  \nReturn: Status\n\n**SX1262.setBlockingCallback(blocking, callback=None)**  \nSet TX/RX blocking mode and interrupt callback.  \nIf blocking = True, TX/RX is set to blocking mode and callback function will be ignored.  \nIf blocking = False, TX/RX is set to non blocking mode and callback function will be triggered with events argument upon TX/RX events.  \nIf callback = None, events callback function will be disabled.\n\n**SX1262.getRSSI()**  \nGet RX RSSI in dBm.  \nReturn: RSSI value\n\n**SX1262.getTimeOnAir(len)**  \nGet RX time on air according to message length, len = message length.  \nReturn: Time on air value\n\n**SX1262.send(data)**  \nSend message, data type must be bytes or bytearray.  \nReturn: Payload length, status\n\n**SX1262.recv(len=0, timeout_en=False, timeout_ms=0)**  \nRead RX message.  \nlen = Message length, if 0, default to SX126X_MAX_PACKET_LENGTH  \ntimeout_en = Enable RX timeout, if False, function blocking indefinitely until message received (Only in blocking mode)  \ntimeout_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)  \nReturn: Payload, status\n\n### LoRa  \n**SX1262.begin(freq=434.0, bw=125.0, sf=9, cr=7, syncWord=0x12, power=14, currentLimit=60.0  \npreambleLength=8, implicit=False, implicitLen=0xFF, crcOn=True, txIq=False, rxIq=False,  \ntcxoVoltage=1.6, useRegulatorLDO=False, blocking=True)**  \nThis method is used to set LoRa configuration.\n\nThe parameters are:  \n- freq : Frequency in MHz\n- bw : Bandwidth in kHz\n- sf : Spreading factor, 5 to 12\n- cr : Coding rate, 5 to 8\n- syncWord : Sync word, private = 0x12, public = 0x34\n- power : TX power in dBm\n- currentLimit : Current limit in mA\n- preambleLength : Preamble length\n- implicit : Implicit or explicit header, implicit = True\n- implicitLen : Implicit header payload length\n- crcOn : CRC on or off\n- txIq : TX invert IQ\n- rxIq : RX invert IQ\n- tcxoVoltage : TCXO input voltage in V\n- useRegulatorLDO : Use LDO regulator = True, use DC-DC regulator = False\n- blocking : Blocking TX/RX = True, non blocking TX/RX = False\n\nReturn: Status\n\n**SX1262.setBandwidth(bw)**  \nSet LoRa bandwidth in kHz.  \nReturn: Status\n\n**SX1262.setCodingRate(cr)**  \nSet LoRa coding rate, 5 to 8.  \nReturn: Status\n\n**SX1262.setPreambleLength(preambleLength)**  \nSet LoRa preamble length.  \nReturn: Status\n\n**SX1262.setSpreadingFactor(sf)**  \nSet LoRa spreading factor, 5 to 12.  \nReturn: Status\n\n**SX1262.setSyncWord(syncWord, [controlBits])**  \nSet LoRa sync word, private = 0x12, public = 0x34.  \nOptional parameter controlBits, default value is 0x44.  \ne.g. syncWord = 0xAB, controlBits = 0xCD -\u003e SX126x 2 bytes sync word = 0xACBD  \ne.g. syncWord = 0x12, controlBits = 0x44 -\u003e SX126x 2 bytes sync word = 0x1424  \nReturn: Status\n\n**SX1262.explicitHeader()**  \nEnable LoRa explicit header mode.  \nReturn: Status\n\n**SX1262.implicitHeader(implicitLen)**  \nEnable LoRa implicit header mode with implicit length parameter.  \nReturn: Status\n\n**SX1262.forceLDRO(enable)**  \nForce enable Low Data Rate Optimization.  \nReturn: Status\n\n**SX1262.autoLDRO()**  \nEnable auto Low Data Rate Optimization.  \nReturn: Status\n\n**SX1262.setCRC(crcOn)**  \nSet LoRa CRC mode.  \nReturn: Status\n\n**SX1262.setTxIq(txIq)**  \nSet LoRa TX invert IQ mode.\n\n**SX1262.setRxIq(rxIq)**  \nSet LoRa RX invert IQ mode.\n\n**SX1262.getSNR()**  \nGet LoRa RX SNR in dB.  \nReturn: SNR value\n\n### FSK  \n**SX1262.beginFSK(freq=434.0, br=48.0, freqDev=50.0, rxBw=156.2, power=14, currentLimit=60.0,  \npreambleLength=16, dataShaping=0.5, syncWord=[0x2D, 0x01], syncBitsLength=16,  \naddrFilter=SX1262.ADDR_FILT_OFF, addr=0x00, crcLength=2, crcInitial=0x1D0F, crcPolynomial=0x1021,  \ncrcInverted=True, whiteningOn=True, whiteningInitial=0x0100,  \nfixedPacketLength=False, packetLength=0xFF, preambleDetectorLength=SX1262.PREAMBLE_DETECT_16,  \ntcxoVoltage=1.6, useRegulatorLDO=False,  \nblocking=True)**  \nThis method is used to set FSK configuration.\n\nThe parameters are:  \n- freq : Frequency in MHz\n- br : Bit rate in kbps\n- freqDev : Frequency deviation in kHz\n- rxBW : RX bandwidth in kHz\n- power : TX power in dBm\n- currentLimit : Current limit in mA\n- preambleLength : Preamble length\n- dataShaping : Time-bandwidth product of the Gaussian filter to be used for shaping\n- syncWord : Sync word\n- syncBitsLength : Sync word length in bit\n- addrFilter : Address filtering, refer to **Constants** FSK address filtering\n- addr : Address for address filtering\n- crcLength : CRC length, 0, 1 or 2\n- crcInitial: CRC initial value\n- crcPolynomial : Polynomial for CRC calculation\n- crcInverted : Invert CRC bytes\n- whiteningOn : Enable whitening\n- whiteningInitial : Initial value used for whitening LFSR\n- fixedPacketLength : Enable fixed packet length mode\n- packetLength : Packet length in bytes (fixed packet length mode) or maximum packet length in bytes (variable packet length mode)\n- preambleDetectorLength : Minimum preamble detection length, refer to **Constants** FSK preamble detector length\n- tcxoVoltage : TCXO input voltage in V\n- useRegulatorLDO : Use LDO regulator = True, use DC-DC regulator = False\n- blocking : Blocking TX/RX = True, non blocking TX/RX = False\n\nReturn: Status\n\n**SX1262.setBitRate(br)**  \nSet FSK bit rate in kbps.  \nReturn: Status\n\n**SX1262.setFrequencyDeviation(freqDev)**  \nSet FSK frequency deviation in kHz.  \nReturn: Status\n\n**SX1262.setRxBandwidth(rxBw)**  \nSet FSK RX bandwidth in kHz.  \nReturn: Status\n\n**SX1262.setDataShaping(dataShaping)**  \nSet FSK time-bandwidth product of the Gaussian filter to be used for shaping.  \nReturn: Status\n\n**SX1262.setSyncBits(syncWord, bitsLen)**  \nSet FSK sync word and sync bits length.  \nsyncWord = Sync word in list  \nbitsLen = Sync word bit length  \nReturn: Status\n\n**SX1262.setPreambleLength(preambleLength)**  \nSet FSK preamble length.  \nReturn: Status\n\n**SX1262.setPreambleDetectorLength(preambleDetectorLength)**  \nSet minimum preamble detection length, refer to **Constants** FSK preamble detector length.  \n\n**SX1262.setNodeAddress(addr)**  \nActivate address filtering on node address addr.  \nReturn: Status\n\n**SX1262.setBroadcastAddress(addr)**  \nActivate address filtering on node and broadcast address addr.  \nReturn: Status\n\n**SX1262.disableAddressFiltering()**  \nDisable address filtering.  \nReturn: Status\n\n**SX1262.setCRC(len, initial=0x1D0F, polynomial=0x1021, inverted=True)**  \nSet FSK CRC.  \nlen = CRC length, 0, 1 or 2  \ninitial = CRC initial  \npolynomial = Polynomial used for CRC calculation  \ninverted = Enable CRC bytes inversion  \nReturn: Status\n\n**SX1262.setWhitening(enabled, initial=0x0100)**  \nSet FSK whitening.  \ninitial = Initial value for whitening LFSR  \nReturn: Status\n\n**SX1262.fixedPacketLengthMode(len)**  \nSet FSK fixed packet length mode.  \nlen = Packet length in bytes  \nReturn: Status\n\n**SX1262.variablePacketLengthMode(maxLen)**  \nSet FSK variable packet length mode.  \nmaxLen = Max packet length in bytes  \nReturn: Status\n\n## Constants (Similar for SX1261 and SX1268)  \nEvents: SX1262.TX_DONE, SX1262.RX_DONE  \nFSK address filter: SX1262.ADDR_FILT_OFF, SX1262.ADDR_FILT_NODE, SX1262.ADDR_FILT_NODE_BROAD  \nFSK preamble detector length: SX1262.PREAMBLE_DETECT_OFF, SX1262.PREAMBLE_DETECT_X -\u003e X = 8, 16, 24, 32  \nStatus dictionary: SX1262.STATUS\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehong-tl%2FmicropySX126X","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehong-tl%2FmicropySX126X","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehong-tl%2FmicropySX126X/lists"}