Lopy and Matchx usage
-
{ "SX1301_conf": { "lorawan_public": true, "clksrc": 1, /* radio_1 provides clock to concentrator */ "lbt_cfg": { "enable": true, "rssi_target": -81, /* dBm */ "chan_cfg":[ /* 8 channels maximum */ { "freq_hz": 915200000, "scan_time_us": 5000 }, { "freq_hz": 915400000, "scan_time_us": 5000 }, { "freq_hz": 915600000, "scan_time_us": 5000 }, { "freq_hz": 915800000, "scan_time_us": 5000 }, { "freq_hz": 916000000, "scan_time_us": 5000 }, { "freq_hz": 916200000, "scan_time_us": 5000 }, { "freq_hz": 916400000, "scan_time_us": 5000 }, { "freq_hz": 916600000, "scan_time_us": 5000 } ], "sx127x_rssi_offset": -7 /* dB */ }, "antenna_gain": 2, /* antenna gain, in dBi */ "radio_0": { "enable": true, "type": "SX1257", "freq": 915600000, "rssi_offset": -166.0, "tx_enable": true, "tx_freq_min": 915000000, "tx_freq_max": 928000000 }, "radio_1": { "enable": true, "type": "SX1257", "freq": 916300000, "rssi_offset": -166.0, "tx_enable": false }, "chan_multiSF_0": { "desc": "Lora MAC, 125kHz, all SF, 915.2 MHz", "enable": true, "radio": 0, "if": -400000 }, "chan_multiSF_1": { "desc": "Lora MAC, 125kHz, all SF, 915.4 MHz", "enable": true, "radio": 0, "if": -200000 }, "chan_multiSF_2": { "desc": "Lora MAC, 125kHz, all SF, 915.6 MHz", "enable": true, "radio": 0, "if": 0 }, "chan_multiSF_3": { "desc": "Lora MAC, 125kHz, all SF, 915.8 MHz", "enable": true, "radio": 0, "if": 200000 }, "chan_multiSF_4": { "desc": "Lora MAC, 125kHz, all SF, 916.0 MHz", "enable": true, "radio": 1, "if": -300000 }, "chan_multiSF_5": { "desc": "Lora MAC, 125kHz, all SF, 916.2 MHz", "enable": true, "radio": 1, "if": -100000 }, "chan_multiSF_6": { "desc": "Lora MAC, 125kHz, all SF, 916.4 MHz", "enable": true, "radio": 1, "if": 100000 }, "chan_multiSF_7": { "desc": "Lora MAC, 125kHz, all SF, 916.6 MHz", "enable": true, "radio": 1, "if": 300000 }, "chan_Lora_std": { "desc": "Lora MAC, 500kHz, SF8, 915.825 MHz", "enable": true, "radio": 0, "if": 250000, "bandwidth": 500000, "spread_factor": 8 }, "chan_FSK": { "desc": "FSK disabled", "enable": false }, "tx_lut_0": { /* TX gain table, index 0 */ "pa_gain": 0, "mix_gain": 8, "rf_power": -6, "dig_gain": 3 }, "tx_lut_1": { /* TX gain table, index 1 */ "pa_gain": 0, "mix_gain": 10, "rf_power": -3, "dig_gain": 3 }, "tx_lut_2": { /* TX gain table, index 2 */ "pa_gain": 0, "mix_gain": 9, "rf_power": 0, "dig_gain": 0 }, "tx_lut_3": { /* TX gain table, index 3 */ "pa_gain": 0, "mix_gain": 12, "rf_power": 3, "dig_gain": 0 }, "tx_lut_4": { /* TX gain table, index 4 */ "pa_gain": 1, "mix_gain": 8, "rf_power": 6, "dig_gain": 2 }, "tx_lut_5": { /* TX gain table, index 5 */ "pa_gain": 1, "mix_gain": 9, "rf_power": 10, "dig_gain": 0 }, "tx_lut_6": { /* TX gain table, index 6 */ "pa_gain": 1, "mix_gain": 11, "rf_power": 11, "dig_gain": 2 }, "tx_lut_7": { /* TX gain table, index 7 */ "pa_gain": 1, "mix_gain": 11, "rf_power": 12, "dig_gain": 1 }, "tx_lut_8": { /* TX gain table, index 8 */ "pa_gain": 1, "mix_gain": 11, "rf_power": 13, "dig_gain": 0 }, "tx_lut_9": { /* TX gain table, index 9 */ "pa_gain": 1, "mix_gain": 12, "rf_power": 14, "dig_gain": 1 }, "tx_lut_10": { /* TX gain table, index 10 */ "pa_gain": 2, "mix_gain": 8, "rf_power": 16, "dig_gain": 0 }, "tx_lut_11": { /* TX gain table, index 11 */ "pa_gain": 2, "mix_gain": 12, "rf_power": 20, "dig_gain": 2 }, "tx_lut_12": { /* TX gain table, index 12 */ "pa_gain": 2, "mix_gain": 14, "rf_power": 23, "dig_gain": 2 }, "tx_lut_13": { /* TX gain table, index 13 */ "pa_gain": 2, "mix_gain": 15, "rf_power": 25, "dig_gain": 0 }, "tx_lut_14": { /* TX gain table, index 14 */ "pa_gain": 3, "mix_gain": 11, "rf_power": 26, "dig_gain": 3 }, "tx_lut_15": { /* TX gain table, index 15 */ "pa_gain": 3, "mix_gain": 13, "rf_power": 28, "dig_gain": 0 } }, "gateway_conf": { /* change with default server address/ports, or overwrite in local_conf.json */ "server_address": "aux.matchx.io", "serv_port_up": 1700, "serv_port_down": 1700, /* adjust the following parameters for your network */ "keepalive_interval": 10, "stat_interval": 30, "push_timeout_ms": 100, /* forward only valid packets */ "forward_crc_valid": true, "forward_crc_error": false, "forward_crc_disabled": false, /* GPS configuration */ "gps_tty_path": "/dev/ttyS1", /* GPS reference coordinates */ "ref_latitude": 0.0, "ref_longitude": 0.0, "ref_altitude": 0 } } -
Thanks @misterlisty
Please remove your all add_channel and remove_channel code and replace it with the following (yes remove_channel should be first). It should then match your gateway configuration. Also change the SO_DR to 3 as mentioned in my previous post. Do try OTAA and ABP if you can.
for i in range(0, 72): lora.remove_channel(i) # set the 8 channels for MatchX configuration for channel in range(0,8): lora.add_channel(channel, frequency=915200000+channel*200000, dr_min=0, dr_max=3) -
@jmarcelino I get an error if i try to remove channels upto 72
-
@misterlisty
Is your LoPy configured configured for the EU868 region by any chance?It should have selected 915Mhz if you chose Australia during firmware upgrade.
Please check with
from network import LoRa lora = LoRa() lora.frequency()also are you running the latest firmware?
Thanks
-
from network import LoRa lora = LoRa() lora.frequency()doesn't return anything...
My firmware is MicroPython v1.8.6-834-g5677703c on 2017-11-13; FiPy with ESP32
-
@misterlisty
Did you try it on the REPL?Try
print(lora.frequency()) -
@jmarcelino The result is 868000000
Appears like it isn't Australia..i assume i have to reapply firmware?
-
Yes that’s set to EU868. We need to reset the device in Pycom’s database before you do a firmware upgrade to change the location. Please send me the MAC address of the WLAN via chat or email a request to support@pycom.io.
Thanks
import binascii binascii.hexlify(network.WLAN().mac(),':').decode() -
@jmarcelino Here is my Mac <removed>
How do you know what setting my fopy has? DO you sedn this during firmware update?
-
Hi,
We have no record of your board, so I guess you never updated it?
We really recommend always updating all our boards first. The factory firmware tends to be very old - or set to the wrong region as yours was.
In any case if you run the upgrade tool and choose Australia, then it should set to 915Mhz correctly and you can use the code I posted.
The firmware update instructions are at: https://docs.pycom.io/chapter/gettingstarted/installation/firmwaretool.html
Thanks!
-
@jmarcelino I have connected a wire from GND to G23 and the fopy will not go into upgrade mode. Its connected to a pysense board while i atempt this. It just running my normal code...can i upgrade while connected to the pysense board? Instructions suggest yes.
-
@misterlisty
Yes you can use the PySense and you don't need the wire anymore.Make sure you update the Pysense firs, follow the steps here:
https://docs.pycom.io/chapter/pytrackpysense/installation/firmware.htmlWhen you have the new firmware on the Pysense load the the Pycom Firmware Update tool and tick the box which says Pytrack/Pysense:

With this setup you don't need the jumper wire as the tool will use the Pysense to put the FiPy into programming mode.
-
@jmarcelino Will atempt update through pysense board shortly but it not upgrading the firmware if i use an USB adapter, connect G23 & GND...its running the normal code instead of going in upgrade mode..any suggestion here?
-
@misterlisty
It has to go into flash programming mode, it's a very low level hardware feature.Are you sure you are connecting GND and G23 (also called P2 on the pin map https://docs.pycom.io/chapter/datasheets/downloads/fipy-pinout.pdf )
Also when you use an USB adapter what exactly is your setup?
In any case I think it will be easier to use the Pysense.
-
OK..here is my status..have updated Fopy to latest firmware ie 1.1.12b
Here is my OTTA code..it appears to work if you look at the logs of MatchX but code says not yet joined still.
from network import LoRa import socket import time import binascii import struct lora = LoRa(mode=LoRa.LORAWAN) print("Lora send::-3") print("DevEUI[",binascii.hexlify(lora.mac()).upper().decode('utf-8'),"]") # create an OTAA authentication parameters dev_eui = binascii.unhexlify('70 B3 D5 49 97 E4 4C 6E'.replace(' ','')) app_eui = binascii.unhexlify('70 B3 D5 7E D0 00 81 BD'.replace(' ','')) app_key = binascii.unhexlify('77 E7 AE FA 56 67 78 3D 5C 2F 4A E0 B9 F2 E3 FC'.replace(' ','')) print("Lora send::-1") for i in range(0, 72): lora.remove_channel(i) # set the 8 channels for MatchX configuration for channel in range(0,8): lora.add_channel(channel, frequency=915200000+channel*200000, dr_min=0, dr_max=3) lora.join(activation=LoRa.OTAA, auth=(dev_eui,app_eui, app_key), timeout=0) print("Lora send::0") while not lora.has_joined(): time.sleep(5) print('Not yet joined...') print('Finally joined...') # remove all the non-default channels for i in range(3, 16): lora.remove_channel(i) # create a LoRa socket s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) print("Lora send::1") i = 0 while True: print("Lora send::1") # set the LoRaWAN data rate s.setsockopt(socket.SOL_LORA, socket.SO_DR, 3) print("Lora send::2") # make the socket blocking # (waits for the data to be sent and for the 2 receive windows to expire) s.setblocking(True) print("Lora send::3") # send some data count = s.send(bytes([i % 256])) print('Sent %s bytes' % count) print("Lora send::4") # make the socket non-blocking # (because if there's no data received it will block forever...) s.setblocking(False) print("Lora send::5") # get any data received (if any...) data = s.recv(64) print("Lora send::",data) i += 1
-
You're removing channels twice unnecessarily, remove your second part:
> # remove all the non-default channels > for i in range(3, 16): > lora.remove_channel(i)Also you're sill using RX2, there are two places for this configuration, I think you missed under Application Configuration -> Network Settings. Please set it to RX1 there.
-
@jmarcelino its set to to RX1 as suggested. I now have ABP working :), OTTA is yet to work...its definitely getting a lora_accept signal but the code doesn't acknowledge this.
-
@misterlisty
OK glad ABP is working, for OTAA you need to get the downlinks working.If you see the JoinResponse on frequency 923.3Mhz that means it's still RX2. Make sure it's set to RX1 in both places, there's a configuration for the Application and another for the device.--If it's correctly set to RX1 you'll see that the frequency of the JoinResponse matches the JoinRequest. -
@jmarcelino Thanks, what will the frequency be for RX1? I will try your suggestion.
-
@jmarcelino Its definitely set to RX1 in application settings and node settings..i suspect they have a bug and not replying to my support requests.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login