Help on TTN LoRaWAN MicroPython on Heltec LoRa 32 V3.2

Hi! Beginner willing to learn here.

As part of a project, I try to figure out how to connect to TTN my LoRa 32 V3 flashed with MicroPython.
I already connected in LoRaWANN to TTN in Arduino IDE with the examples provided in the lib, but I am having a hard time doing the same in MicroPython.
I was wondering if any of you succeeded in doing so?

As far as I can understand, Adafruit’s lib for that isn’t compatible anymore with TTN since 2021, since they forced migration to Stack V3.
I did find other implementations on GitHub, but I am struggling to figure all this out on my own without much documentation since I have little experience with microcontrollers and such specific libraries, especially if it needs heavy porting.

The repo GereZoltan/LoRaWAN mentioned on the TTN forum looks very promising, it mentions Chipstark, but I don’t see why it wouldn’t work with TTN as well. The issue is that the TTN post ends there, and I am having a hard time understanding how to try the provided code. I took a look at the paper published by its author, but it doesn’t go too much in depth in the code.
Of course, I edited the pins accordingly with the V3.2’s pin map: CS = const(8) / DIO1 = const(14) / BUSY = const(13) / RESET = const(12) / and LED_PIN = const(35)
I edited the rest to match European settings, it looks ok, I may be missing something.

How should I go from there?
Am I missing something important? Maybe my file tree isn’t right?

Do you have LoRaWAN projects that you wouldn’t mind to share so I can take a look at your implementation and the library you are using and try to learn something from there?

Thank you.

Sooooo many thoughts.

Why do you need to run Python based LW firmware?

To learn to drive, would you start by building a car or would you learn about cars first?

They are so bad, making everyone use the new improved FREE service that does the same thing that they support for FREE but can’t run servers for v2 & for v3 at the same time for FREE.

The red warning box that Adafruit spread all over their sites regarding Single Channel Packet Forwarders is misleading, has some technically inaccuracies and is quite often unrelated to the subject matter. Their TinyLoRa repro has only had superficial updates to the badges, CI & whatnot since about 2020. However the LW specs haven’t been retroactively changed and TTS v3 supports pretty much every version of LW so I’m not sure what the issues might be (because no one appears to have listed them in an easy to find way) or why they may be thinking like that.

And yes, I’ve told them.

Many people struggle to implement a LW device using a library even when @CaptainAwesome has written the blow-by-blow instructions. Why are you starting out building something complicated when you don’t understand the engine it runs on?

It is imprudent and regarded as unacceptable to learn LoRaWAN by implementing a stack whilst using TTN which is used by many communities around the world for their environmental sensing systems. If you want an experimental platform, use a self-hosted version of TTS or a (free) Discovery instance or Chirpstack.

Heltec is a hardware company that provides firmware for a range of things. If you wanted to write a BlueTooth stack, you could ask here. But maybe there are subject matter experts else where?

A search on the TTN forum yields this: https://github.com/BNNorman/CircuitPython-LoRaWAN and some hopeful comments from another user who would like someone else to port it to MicroPython.

In time, I’m sure you can achieve this end goal, but by trying to route directly to it without many of the foundations in place, you will initially be building on quicksand with errors coming up that seem incomprehensible because they refer to elements that are not at all obvious but are fundamental to the way it all works.

Thank you for your detailed answer!
Based on the tone, I apologize if my message is confusing or misinformed, I’m still finding my way around all this, and I appreciate you taking the time to share your views on it.

I’m working with MicroPython simply because it’s the environment I’m most comfortable with, and my project has some guidelines that make Python the most practical choice in theory for me. Not everyone loves Python, but I do. I may try to explore the use of something as a middleman for LoRa communication with my gateway, but for now, I’m trying to make it work with what I know without additional devices.

I may have had a poor choice of words regarding TTN, translation issue. I didn’t mean to imply anything negative about their migration to Stack V3. I was pointing out that Adafruit’s library isn’t compatible anymore since the switch. I genuinely appreciate TTN as a free and valuable tool. Also, I get what you say about Adafruit’s library and the surrounding context.

I also see your point about using TTN for experimentation. My goal is more to ensure that what I’m building locally will work with TTN. That’s why I mentioned trying out GereZoltan’s LoRaWAN library and said that I didn’t see why it wouldn’t work on TTN after exploring the code.

I posted here because there are many other hardware-related coding questions on the forum, so I thought my question might fit. I’m sorry if it wasn’t the case.

Thanks the link to the CircuitPython-LoRaWAN repo, I did see it but didn’t go much further with it.
I’ll keep experimenting on my own and see if I can make progress.
I’d still love to see examples of an implementation with the LoRa 32 V3 if someone did something :slight_smile:

And I said that is unlikely to be true.

The LoRaWAN specifications are fully documented and globally ratified - if it works with a locally hosted TTS or Chirpstack (big hint, please do this), then it will work with commercial or community deployments.

Have you got copies of the spec and which version are you working to? The wrong answer is v1.1 BTW!

This is not hardware related, Micro/Circuit Pythons are standards as well. If code works on one device with an appropriate radio, it will work on another. The microcontroller is largely irrelevant, a particular implementation of any one MCU like the LoRa v3 more so. Taking a generic ESP32 dev board with a generic SX1262 radio & wiring them up can still be programmed in a wide range of languages.

I am fully aware that my first & this reply is a bit pointy. Every couple of months across the LoRaWAN eco-system someone wants to write their own implementation without having tried a few different devices with the existing stacks on different microcontrollers with different sensors & power & duty cycle & antennas etc. You are going further by not being overly familiar with microcontrollers as well although it’s hard to know at what level you may actually be at, you may be underestimating your abilities.

This is like planning to do a wreck dive in shark infested waters using Nitrox when you haven’t tried a 3m dive with air in your local swimming pool. You are being encouraged to take lots of baby steps so that we can avoid impact on community systems. You will make faster progress if you lay solid foundations for yourself. The questions you bring up will be answerable because you will have enough prior knowledge to frame them properly. But probably best not here as this is Heltec land first & foremost. TTN is where the LoRaWAN experts hang out.

As so much of the LW eco-system is based on C/C++ and is so modular with Arduino libraries to assist, getting your bits (sensor readings & payload construction) working in Python and then translating that in to C would be highly productive. You are using Python in a procedural way so it’s almost find & replace to change the words used. There are probably even programs that can do that. In that respect, all these languages are the same, some use tabs/spaces (insanity) instead of brackets, but someone that can program should be able to see past the syntax.

I’ve nothing against Python on the desktop, I use it for adhoc data processing & simple utilities, but for resource constrained devices like an MCU, coding close to the metal with C results in a more efficient solution - particular for LW where power is everything.

The TTN forum has supported BNNorman with his work & he is proactive in supporting his library. So if you do anything with Python, I’d use that, even if you have to port it to MicroPython or move your code to CircuitPython.

I understand the whole thing, no worries.
Didn’t do much since, I’ll try to get my hands on BNNorman’s code when I have the time, or I may just go for the middle-man with C solution, as explained earlier, as it looks like the easiest way to solve this for the time being.
Anyway, thank you for your time :slight_smile:

1 Like