forked from Telos4/LoRa-Workshop
extended main and changed default spreading factor
This commit is contained in:
parent
04caff9623
commit
23a63cac12
|
@ -3,7 +3,7 @@ from uPyLora.sx127x import SX127x
|
||||||
from uPyLora.controller_esp32 import ESP32Controller
|
from uPyLora.controller_esp32 import ESP32Controller
|
||||||
|
|
||||||
class LoRaTransceiver:
|
class LoRaTransceiver:
|
||||||
def __init__(self, spreadingfactor=9, bandwidth=125E3, frequency=868E6, syncword=0x12, display=None):
|
def __init__(self, spreadingfactor=7, bandwidth=125E3, frequency=868E6, syncword=0x12, display=None):
|
||||||
# set up radio module
|
# set up radio module
|
||||||
# SX127x LoRa module configured for LoRaWAN Channel 0
|
# SX127x LoRa module configured for LoRaWAN Channel 0
|
||||||
self.controller = ESP32Controller()
|
self.controller = ESP32Controller()
|
||||||
|
@ -30,7 +30,7 @@ class LoRaTransceiver:
|
||||||
|
|
||||||
def setSignalBandwidth(self, bandwidth):
|
def setSignalBandwidth(self, bandwidth):
|
||||||
""" set the bandwidth
|
""" set the bandwidth
|
||||||
possible values should be 125 or 250 kHz according to EU 868 frequency plan
|
possible values should be 125 kHz or 250 kHz according to EU 868 frequency plan
|
||||||
"""
|
"""
|
||||||
self.lora.setSignalBandwidth(bandwidth)
|
self.lora.setSignalBandwidth(bandwidth)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,16 @@
|
||||||
from lora_transceiver import LoRaTransceiver
|
from lora_transceiver import LoRaTransceiver
|
||||||
|
|
||||||
|
# create transceiver for LoRaWAN frequency (channel 0 = 868.1 Mhz)
|
||||||
lora = LoRaTransceiver(frequency=868.1E6, syncword=0x34)
|
lora = LoRaTransceiver(frequency=868.1E6, syncword=0x34)
|
||||||
|
|
||||||
|
# change the spreading factor
|
||||||
|
lora.setSpreadingFactor(7)
|
||||||
|
|
||||||
|
# sending string data
|
||||||
|
lora.send_string('imaginaerraum')
|
||||||
|
|
||||||
|
# sending raw data
|
||||||
|
lora.send([0x61, 0x62, 0x63])
|
||||||
|
|
||||||
|
# receiving data
|
||||||
|
lora.recv()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user