question

Timo Jurado avatar image
Timo Jurado asked

Ve.Direct to LoRaWAN change band US902-928 to AU915?

Hi is there any possibility today to change the working frequency band of a Ve.Direct to LoRaWAN from band US902-928 to AU915?

This can be done by local dealers?

Kind regards

Timo

VE.DirectLoRaWAN
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

15 Answers
Simon avatar image
Simon answered ·

@Timo Jurado have a look in the transmitter.py file stored on pycom

Transmitter class, handles LoRaWAN connectivity.


# LoRaWAN region, used for setting which freqencies we use
LORAWAN_REGION = 'au'

# LoRaWAN OTAA configuration
LORAWAN_APP_EUI = '70b88888888888'
LORAWAN_APP_KEY = '3f8888888888888888888888880'

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Timo Jurado avatar image
Timo Jurado answered ·

Hi Simon,

thank you very much for this comment. It makes me some hope. You have any other hint or tutorial how to access the transmitter.py file? I have already Studio VS Code and "Pymakr" Plugin installed but can't see or find the mentioned file.

Kind regards

Timo

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Simon avatar image
Simon answered ·

@Timo Jurado using a pycom expansion board and VS or Atom , what files do you have?, its possible we have different versions

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Timo Jurado avatar image
Timo Jurado answered ·

I could access in the developer mode the transmitter.py file and changed LORAWAN_REGION = 'us' to LORAWAN_REGION = 'au'. Is there something else to do because in the terminal get stuck when try to connect to US TTN, I have the same output.

[     1.375] Coupling LoPy, version LoPy4-92976c6-1.15.0.b1
[     1.408] Setting up LoRaWAN connection...
[     1.446] Setting up LoRaWAN frequencies for TTN US region...
[     1.675] Dev EUI: 70b3d5499d27144d
[     1.679] App EUI: 70b3d57ef0005f34
[     1.683] App Key: 4d79432c35ad44e34e592bbd2bcef70b
[     1.688] Waiting for module to join network...
Transmitter class file.
"""

import binascii
import errno
import math
import usocket
import utime
from encoder import binpack_mark_message
from reader import Reader
from network import LoRa
from micropython import const

class Transmitter:
    """
    Transmitter class, handles LoRaWAN connectivity.
    """

    # LoRaWAN region, used for setting which freqencies we use
    LORAWAN_REGION = 'au'

    # LoRaWAN OTAA configuration
    LORAWAN_APP_EUI = '70b3d57ef0005f34'
    LORAWAN_APP_KEY = '*******'
1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Simon avatar image Simon commented ·

@Timo Jurado this is the full au transmitter file, check and see if there are any other charges



transmitter.txt

0 Likes 0 ·
transmitter.txt (13.5 KiB)
Timo Jurado avatar image
Timo Jurado answered ·

Thank you very much @Simon ! The file looks nearly identical but in my version there were missing the self. definitions at the end of the file so I add these lines to my transmitter.py file.

Now the main problem is I can´t transfer write (sync project) to the PYCOM lopy4 memory. I get different kind of error message. Also with the help of ChatGPT no solution yet.


1) OSError: file exists: '.'

failed to upload c:\_iot\pycom_lopy4 to Reason: Error: Traceback (most recent call last): File "<stdin>", line 7, in <module> File "<stdin>", line 7, in <module> File "<stdin>", line 4, in <module> OSError: file exists: '.'


2) I am not 100% sure if the rootPath "flash/" is correct? I have the following file structure on the PYCOM

>>> import os
>>> os.listdir()  # List the contents of the root directory
['main.py', 'sys', 'lib', 'cert', 'boot.py', 'encoder.py', 'nanomsgpack.py', 'queue.py', 'reader.py', 'transmitter.py', 'vedirect.py', 'flash']
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Timo Jurado avatar image
Timo Jurado answered ·


Hi Simon,

I tried it with a simple serial UART connection on PIN0/RX and P1/TX and 3,3VDC supply like mentioned in the manual and layout pycom-lopy4-pinout.pdf

But it seems that it doesn´t establish correct a connection. I get a terminal output but the Pymakre project doesn´t load any files. The Pymakr indicates the following error "Could not safeboot device. Please hard reset the device and verify that a shield is installed".

1722136785405.png



The Terminal window gives me this message:

[   901.708] Timed out trying to connect to LoRaWAN network after 900000ms!
[   901.713] Exception caught in transmitter:
Traceback (most recent call last):
  File "main.py", line 131, in catch_reset
  File "transmitter.py", line 85, in run
  File "transmitter.py", line 186, in _connect
RuntimeError: LoRaWAN connect timeout
[   901.729] Resetting in 10000ms!
ets Jun  8 2016 00:22:57

rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff9028,len:8
load:0x3fff9030,len:1060
load:0x4009fa00,len:0
ho 12 tail 0 room 4
load:0x4009fa00,len:14084
entry 0x400a05d4
[   912.113] Coupling LoPy, version LoPy4-92976c6-1.15.0.b1
[   912.145] Setting up LoRaWAN connection...
[   912.184] Setting up LoRaWAN frequencies for TTN US region...
[   912.413] Dev EUI: 70b3d5499d27144d
[   912.416] App EUI: ***************
[   912.421] App Key: ***************
[   912.425] Waiting for module to join network...

1722133557779.png



https://alepycom.gitbooks.io/pycom-documentation/content/chapter/gettingstarted/connection/lopy4.html#diy

Apreceate any advice how to acces the transmitter.py" file to change the band form "us" to "au".

Kind regards

Timo


1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Simon avatar image Simon commented ·

see video

0 Likes 0 ·
Simon avatar image
Simon answered ·

Yes when using VS or alike you have to stop the scrip and boot into safe mode easy to do on the Pycom expiation board as it has a safe boot button, (Pin12 to +3.3V) have you taken a back up of your working config as you are now hacking LOL

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Simon avatar image
Simon answered ·

@Timo Jurado

also had problems with v1.9 of VS went back to v1.8 https://code.visualstudio.com/updates/v1_89

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Timo Jurado avatar image
Timo Jurado answered ·

@Simon thanks for the advices! Like you can imagine its the first time for me, but I will give a try.

1) We went back to VSCode 1.8

2) We started the device in safe boot mode (holding 1-3 sec, 3,3VDC to PIN12)

We have the following folder structure and recognized that the main.py and boot.py files are empty. Is this normal? Please can you confirm or share the right file structure as backup to flash files and folders to the root directory */* or */flash* directory of the PYCOM?

1722294022541.png

Unfortunatly still get always errors during the Pymakr-project upload.

failed to upload c:\_iot\pycom_lopy4 to / Reason: Error: Traceback (most recent call last): File "<stdin>", line 7, in <module> File "<stdin>", line 7, in <module> File "<stdin>", line 4, in <module> OSError: error creating directory '/'
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Simon avatar image
Simon answered ·

@Timo Jurado


also disable auto updates is VS once a fresh install of V 1.89.1 is done.

root dir, if you have to you can go back to fresh with Pymaker updater but keep your Lora EUI's and app key safe ,


Pycom MicroPython 1.20.2.r6 [v1.11-c5a0a97] on 2021-10-28; FiPy with ESP32
Pybytes Version: 1.7.1
Type "help()" for more information.
>>> [ 10.996] Setting up LoRaWAN connection...
[ 11.053] Setting up LoRaWAN frequencies for TTN AU915 region...
[ 11.229] LoRaWAN Dev EUI: 70888888888
[ 11.241] LoRaWAN App EUI: 7088888888888
[ 11.253] LoRaWAN App Key: 88888888888888888888888888888888888
[ 11.265] Waiting for module to join LoRaWAN network...
[ 16.275] LoRaWAN connected.


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Timo Jurado avatar image
Timo Jurado answered ·

Hi @Simon, we are back and we managed to compare and upload your transmitter.py file for the AU915 band. For documentation there was the following difference in channel range (8,15) in comparison to the original US915 band file.

        if self.LORAWAN_REGION == 'au':
            if self.lora.frequency() != 915000000:
                raise RuntimeError(
                    'Invalid firmware for AU region. Reported LoRaWAN frequency: {}'.format(self.lora.frequency())
                )
            self._log('Setting up LoRaWAN frequencies for TTN AU region...')
            for i in range(0, 72):
                self.lora.remove_channel(i)
            for i in range(8, 15):
                self.lora.add_channel(i, frequency=916800000+i*200000, dr_min=0, dr_max=3)
            self.lora.add_channel(8, frequency=917500000, dr_min=4, dr_max=4)

Now we have another challange to sucessfully conect the device to TTN Latam. We recieve some JOIN messages in our lora gateway but it doesn´t connect. When we try to manually add the device in the our aplication in the TTN console we get the following error "device is already registered as in application victronenergy-coupling-v1".

{
"code": 6,
"message": "error:pkg/identityserver:end_device_euis_taken (an end device with JoinEUI 70XXXXXXXXXXXF34 and DevEUI 70B3D5499D27144D is already registered as 70b3d5499d27144d in application victronenergy-coupling-v1)",
"details": [
{
"@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
"namespace": "pkg/identityserver",
"name": "end_device_euis_taken",
"message_format": "an end device with JoinEUI {join_eui} and DevEUI {dev_eui} is already registered as {device_id} in application {application_id}",
"attributes": {
"application_id": "victronenergy-coupling-v1",
"dev_eui": "70B3D5499D27144D",
"device_id": "70b3d5499d27144d",
"join_eui": "70XXXXXXXXXXXF34"
},
"correlation_id": "26fb8881b06e4577b34ea795ac97282e",
"code": 6
}
]
}

The upload JOIN message from TTN console looks like this:

Console:
{
"name": "gs.up.receive",
"time": "2024-08-07T01:51:25.694236433Z",
"identifiers": [
{
"gateway_ids": {
"gateway_id": "eui-343632381e006800",
"eui": "343632381E006800"
}
}
],
"data": {
"@type": "type.googleapis.com/ttn.lorawan.v3.GatewayUplinkMessage",
"message": {
"raw_payload": "ADRfAPB+1bNwTRQnnWlVsXBSY1ofQO4=",
"payload": {
"m_hdr": {},
"mic": "Wh9A7g==",
"join_request_payload": {
"join_eui": "70XXXXXXXXXXXF34",
"dev_eui": "70B155699D27144D",
"dev_nonce": "6352"
}
},
"settings": {
"data_rate": {
"lora": {
"bandwidth": 125000,
"spreading_factor": 10,
"coding_rate": "4/5"
}
},
"frequency": "917200000",
"timestamp": 654636276,
"time": "2024-08-07T01:51:22.490760Z"
},
"rx_metadata": [
{
"gateway_ids": {
"gateway_id": "eui-343632381e006800",
"eui": "343632381E006800"
},
"time": "2024-08-07T01:51:22.490760Z",
"timestamp": 654636276,
"rssi": -96,
"channel_rssi": -96,
"snr": -8,
"uplink_token": "CiIKIAoUZXVpLTM0MzYzMjM4MWUwMDY4MDASCDQ2MjgeAGgAEPTpk7gCGgwInabLtQYQ/se0yQIgoLLz2oaBBg==",
"channel_index": 2,
"received_at": "2024-08-07T01:51:25.569913250Z"
}
],
"received_at": "2024-08-07T01:51:25.690824190Z",
"correlation_ids": [
"gs:uplink:01J4N8HAZYWZGCGPCAXJ15Q8BD"
],
"crc_status": false
},
"band_id": "AU_915_928"
},
"correlation_ids": [
"gs:uplink:01J4N8HAZYWZGCGPCAXJ15Q8BD"
],
"origin": "ip-10-101-5-86.us-west-1.compute.internal",
"context": {
"tenant-id": "CgN0dG4="
},
"visibility": {
"rights": [
"RIGHT_GATEWAY_TRAFFIC_READ"
]
},
"unique_id": "01J4N8HAZYQDTWMMBKZV40EXWT"
}

We are lost again on this point ;-) Is there anything else what we can try to solve this?

Kind regards

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Simon avatar image
Simon answered ·

@Timo Jurado ,

 already registered as 70b3d5499d27144d in application victron - This is correct 


Getting closer good stuff, do you get a green LED on the Pycom? check VRM add to the device to the Victron portal if required

https://betavrm.victronenergy.com/add-installation

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Timo Jurado avatar image
Timo Jurado answered ·

Hi @Simon:

  1. The Pycom doesn´t connect correctly to Lorawan Network -> no green light !
  2. The Pycom does not connect to the VRM Portal! --> Error: Device ID in VRM cannot found


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Simon avatar image
Simon answered ·

@Timo Jurado uploads are not working her still, I have a back up of the pycom and some screen shots to send to you flick me your email address if your in au can give you a call


2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Timo Jurado avatar image
Timo Jurado answered ·

Hi @Simon at the end we used the MicroPython Tool (ampy) to upload the files over a serial connection because Pymakr/VSCode didn´t work correctly. Still we haven´t found a solution and happy to get your backup and screen shots. My mail timo.jurado@gmail.com

The following line in your transmitter.py file under the 'au' frequency band section is default or you added it to the file?

            self.lora.add_channel(8, frequency=917500000, dr_min=4, dr_max=4)
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources

Additional resources still need to be added for this topic

VE.Direct protocol FAQ