Lorawan TTGO board - 'no module named ttn'

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
matt42
Posts: 4
Joined: Sat Apr 25, 2020 4:10 am

Lorawan TTGO board - 'no module named ttn'

Post by matt42 » Fri May 08, 2020 3:02 pm

Hi all,
I am trying to connect a TTGO board to the Lorawan network, using this code - https://github.com/lemariva/uPyLoRaWAN/tree/LoRaWAN

I keep getting this error when running main.py:

Code: Select all

SX version: 18
Traceback (most recent call last):
  File "<stdin>", line 59, in <module>
  File "sx127x.py", line 207, in __init__
ImportError: no module named 'ttn'

Line 59 in main.py:

Code: Select all

lora = SX127x(device_spi, pins=device_pins, ttn_config=ttn_config)
Line 207 in sx127x.py:

Code: Select all

from ttn.ttn_au import TTN_FREQS
ttn_config.py and ttn_au.py are both there

I seem to be missing the ttn module but cannot find it for MP, the only reference I can find is for standard Python. Does anyone have any pointers?

Hardware:
https://www.banggood.com/LILYGO-TTGO-T- ... rehouse=CN

thanks in advance,

Matt

User avatar
T-Wilko
Posts: 22
Joined: Thu Sep 19, 2019 8:08 am

Re: Lorawan TTGO board - 'no module named ttn'

Post by T-Wilko » Fri May 15, 2020 9:57 am

matt42 wrote:
Fri May 08, 2020 3:02 pm

Code: Select all

from ttn.ttn_au import TTN_FREQS
ttn_config.py and ttn_au.py are both there
I don't know exactly how you've stored your on-board files, but shouldn't the code be this?

Code: Select all

from ttn_au import TTN_FREQS

User avatar
T-Wilko
Posts: 22
Joined: Thu Sep 19, 2019 8:08 am

Re: Lorawan TTGO board - 'no module named ttn'

Post by T-Wilko » Tue May 19, 2020 3:15 am

No worries! Just out of curiosity, did you manage to get the TTGO board's LoRa functionality working?
I've been looking at getting my TTGO T-Beam's LoRa module functional sometime soon, and I also was eyeing off that repo that you first linked to.

User avatar
lemariva
Posts: 4
Joined: Sun Oct 21, 2018 9:33 am
Location: Hannover, Germany
Contact:

Re: Lorawan TTGO board - 'no module named ttn'

Post by lemariva » Wed May 20, 2020 7:45 am

The main.py expects that you upload the folder structure to the board too. If you use VSCode and the PyMakr plugin (https://lemariva.com/blog/2018/12/micro ... ode-as-ide), this is done by default. If you uploaded every file on the root / folder, you need to remove the ttn. prefix from the imports. Last Sunday, I upgraded the repository and added a configuration for the M5Stack with the LoRa868 Module. Now, it should be easier to configure new boards. :)

Post Reply