From 23a63cac12d7a4809414d34a03804ea92eb3bb36 Mon Sep 17 00:00:00 2001 From: spirkelmann Date: Wed, 20 Nov 2019 18:37:43 +0100 Subject: [PATCH] extended main and changed default spreading factor --- micropython/lora_transceiver.py | 4 ++-- micropython/main.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/micropython/lora_transceiver.py b/micropython/lora_transceiver.py index e19243e..8fa3954 100644 --- a/micropython/lora_transceiver.py +++ b/micropython/lora_transceiver.py @@ -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) diff --git a/micropython/main.py b/micropython/main.py index fce9f58..cad2f2c 100644 --- a/micropython/main.py +++ b/micropython/main.py @@ -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()