extended main and changed default spreading factor

This commit is contained in:
Simon Pirkelmann 2019-11-20 18:37:43 +01:00
parent 04caff9623
commit 23a63cac12
2 changed files with 15 additions and 2 deletions

View File

@ -3,7 +3,7 @@ from uPyLora.sx127x import SX127x
from uPyLora.controller_esp32 import ESP32Controller
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
# SX127x LoRa module configured for LoRaWAN Channel 0
self.controller = ESP32Controller()
@ -30,7 +30,7 @@ class LoRaTransceiver:
def setSignalBandwidth(self, 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)

View File

@ -1,3 +1,16 @@
from lora_transceiver import LoRaTransceiver
# create transceiver for LoRaWAN frequency (channel 0 = 868.1 Mhz)
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()