# MicroPython OTAA Node

**URL:** <https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375>\
**Category:** Hardware\
**Created:** [January 10, 2022, 10:18am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375 "2022-01-10T10:18:02Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [January 10, 2022, 10:18am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/1 "2022-01-10T10:18:02Z")

</div>

I would like to use MicroPython to make an OTAA join request Node. My node is an ESP32 + SX1276 node. The LoRaWAN lib that I have seen so far is uLoRaWAN ([GitHub - mallagant/uLoRaWAN: LoRaWAN implementation in MicroPython](https://github.com/mallagant/uLoRaWAN)). Is there anyone success using this lib with MicroPython on ESP32.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [January 10, 2022, 10:41am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/2 "2022-01-10T10:41:37Z")

</div>

As there does not seem to be any handling of MAC commands, whilst you may be able to get a join, you’ll find all the settings that are sent by the Network Server can’t be processed unless you write the code for that.

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [January 11, 2022, 12:42am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/3 "2022-01-11T00:42:19Z")

</div>

Thank you Nick. It seems that it is uncomplete lib. Hope someday, there will be an usable one.

---

<div class="post-metadata">

**Author:** ![cslorabox](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/cslorabox/32/35697_2.png) [@cslorabox](https://www.thethingsnetwork.org/forum/u/cslorabox)\
**Post date:** [January 11, 2022, 3:31am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/4 "2022-01-11T03:31:05Z")

</div>

> [@Somsak](#):
>
> Hope someday, there will be an usable one.

If you look there are already plenty of threads here on how to correctly use the mostly working LoRaWAN library that is available for ESP32 hardware.

It just won’t be micropython.

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [August 18, 2024, 4:20am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/5 "2024-08-18T04:20:23Z")

</div>

> **[GitHub - BNNorman/CircuitPython-LoRaWAN: CircuitPython LoRaWAN code to work...](https://github.com/BNNorman/CircuitPython-LoRaWAN)**
>
> CircuitPython LoRaWAN code to work with the HopeRF RFM95 - GitHub - BNNorman/CircuitPython-LoRaWAN: CircuitPython LoRaWAN code to work with the HopeRF RFM95

This library work with CircuitPython and Pi Pico, hope someone can port it to run on ESP32 and MicroPython.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [August 18, 2024, 9:49am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/6 "2024-08-18T09:49:56Z")

</div>

> [@Somsak](#):
>
> hope someone can port it to run on ESP32 and MicroPython.

What is stopping **YOU** from doing it?

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [August 18, 2024, 10:20am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/7 "2024-08-18T10:20:57Z")

</div>

I tried for a few weeks without success. I have only basic skill of MicroPython.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [August 18, 2024, 10:22am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/8 "2024-08-18T10:22:58Z")

</div>

So tell us where you got stuck and perhaps you can finish it off which will be so much better for you and will get the job done.

Or if anyone does want to do the port, they get a head start based on your experiences.

Whereas hoping someone will start from scratch may result in a very long wait.

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [October 3, 2024, 11:40am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/9 "2024-10-03T11:40:35Z")

</div>

I decided to try this lib [GitHub - GereZoltan/LoRaWAN: Possibly complete LoRaWAN implementation in micropython with SX1262](https://github.com/GereZoltan/LoRaWAN) with my Heltec LoRa V.3  
Then I found that this library is only LoRaWAN 1.0 which TTS is not supported. Then, I try with Chirpstack .

Mac command processing part is not correct. So, it stops working after receiving Mac Command.

> Blockquote\>\>\> %run -c $EDITOR\_CONTENT  
> This is the LoRa temperature and humidity measurement application.  
> Unique board ID:  
> f412fa81648c  
> Initializing SX1262 radio module  
> LoRa module has been initialized.  
> Sending Join request:Done  
> Message received in RX1:Join-AcceptMIC: Valid  
> OTAA activation successful!  
> Queue length: 1  
> [(2, 0, [1, 103, 0, 255])]  
> FCntUp: 0 FCntDown: -1  
> Highest priority is: 2 at index: 0  
> Sending unconfirmed data  
> Current FCntUp: 0  
> FrameCount: 0 NbTrans: 1  
> TxDone on 923.2 Hz, DR: 0  
> Message received in RX1 window: DR: 0 at 147997 Valid  
> Processing frame: Unconfirmed Data down

```
Processing MAC Commands
	NEWCHANNEL DEVSTATUSSNR: 5.5

```

Traceback (most recent call last):  
File “”, line 31, in   
File “LoRaWANHandler.py”, line 938, in send  
File “LoRaWANHandler.py”, line 772, in ProcessFrame  
File “LoRaWANHandler.py”, line 695, in ProcessMACCommands  
TypeError: unsupported types for **rshift** : ‘float’, ‘int’

> > >

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [October 3, 2024, 11:43am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/10 "2024-10-03T11:43:53Z")

</div>

If I skip Mac Command part, it seems working find so far.  
 ![Clipboard01](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/c/7/c7a021c6848de6cb7654d83af7cb07aafee17ed9.jpeg)

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [October 3, 2024, 5:50pm UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/11 "2024-10-03T17:50:43Z")

</div>

Using a v1.0.0 stack that was last updated 3 years ago to add fport from a repro that was last updated 7 years ago is like buying an old rusty car that does to run well with flat tyres and hoping it will keep you safe on the motorway.

This and you using Chirpstack (this forum is TTN/TTI only as it’s funded by TTI) and turning off MAC commands I think brings this attempt to find a MP LW offering to a close.

It would be far far simpler for you to port the CircuitPython offering to MicroPython OR you could use CircuitPython.

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [October 5, 2024, 4:16am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/12 "2024-10-05T04:16:05Z")

</div>

Yes, you are right. Unfortunately, it is an old Lib. Hope someone can improve it to work with TTN in the future. There are many works that need to be done, such as Mac Command Processing and change to new LoRaWAN version.

I put all modified files that I have done so far in [GitHub - m2mlorawan/heltecV.3LoRaWAN](https://github.com/m2mlorawan/heltecV.3LoRaWAN)  
(Modify for Heltec V.3, AS923)

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [October 5, 2024, 9:12am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/13 "2024-10-05T09:12:38Z")

</div>

The LW spec is complex, why try and update software so old when you could just copy the CircuitPython over to MicroPython.

Or just use MicroPython.

Buy you never seem to comment on any of these observations so probably time to stop.

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [October 5, 2024, 11:03am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/14 "2024-10-05T11:03:30Z")

</div>

If you mean using CircuitPython lib from [GitHub - BNNorman/CircuitPython-LoRaWAN: CircuitPython LoRaWAN code to work with the HopeRF RFM95](https://github.com/BNNorman/CircuitPython-LoRaWAN),  
I have two problems with it. The first one is that it works with SX1276 which is older than SX1262. The Second is the author said he found some problem with ESP32 doit board. I do not have a PI to test and I also not familiar with NVM both in MicroPython and CircuitPython but I will try ithis lib on Heltec LoRa V.2 soon.

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [October 12, 2024, 8:23pm UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/15 "2024-10-12T20:23:53Z")

</div>

Problem solved.  
Pycom MicroPython works perfectly both OTAA and ABP on ESP32. Downlink also works fine.

> **[GitHub - pycom/pycom-micropython-sigfox: A fork of MicroPython with the ESP32...](https://github.com/pycom/pycom-micropython-sigfox)**
>
> A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules. - pycom/pycom-micropython-sigfox

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [October 12, 2024, 9:28pm UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/16 "2024-10-12T21:28:20Z")

</div>

This is a repro that hasn’t had an update in 3 years from a company that has ceased trading with a copy of LoRaMac-node with a copyright notice from 2013 that supports LW v1.0.X.

Leaving aside 9 years of bug fixes, I wonder if you know what that X is and what material differences are between that X and the more recent versions and what impact that may have on the shared community network that you get for free.

So whilst you may now have what you want, you are driving an old rust bucket that is making a squealing noise and belching smoke from the exhaust on a communal highway.

---

<div class="post-metadata">

**Author:** ![stevencellist](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/stevencellist/32/46434_2.png) [@stevencellist](https://www.thethingsnetwork.org/forum/u/stevencellist)\
**Post date:** [October 12, 2024, 10:08pm UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/17 "2024-10-12T22:08:49Z")

</div>

First-hand experience here with 60 now-retired Pycom nodes: their LoRaWAN stack will and would never ever ever pass certification, to put it positively. I’ve had to apply some quite extreme hacks to get them to behave somewhat nicely.

---

<div class="post-metadata">

**Author:** ![Somsak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/somsak/32/45700_2.png) [@Somsak](https://www.thethingsnetwork.org/forum/u/Somsak)\
**Post date:** [October 13, 2024, 12:00am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/18 "2024-10-13T00:00:08Z")

</div>

I saw there is still some movement on their firmware release page.

> **[Release Firmware Release v1.20.2.r6 · pycom/pycom-micropython-sigfox](https://github.com/pycom/pycom-micropython-sigfox/releases/tag/v1.20.2.r6)**
>
> pybytes version 1.7.1 - fix initialization

This was released on Oct 28, 2021

I know that it is old LoRaWAN 1.0.2, but better than nothing working. I mean for MicroPython.

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [October 13, 2024, 9:20am UTC](https://www.thethingsnetwork.org/forum/t/micropython-otaa-node/54375/19 "2024-10-13T09:20:14Z")

</div>

> [@Somsak](#):
>
> but better than nothing working

Maybe for you, but how about all the other users of the airwaves your are sharing with?

There are plenty of other poor / old implementations around, it’s just not progress if we start resurrecting them.
