Pycom LoPy4 Gateway ID - script not working

I’m using a LoPy4

(sysname=‘LoPy4’, nodename=‘LoPy4’, release=‘1.20.3.b4’, version=‘v1.11-95ab8f63 on 2021-09-10’, machine=‘LoPy4 with ESP32’, lorawan=‘1.0.2’, sigfox=‘1.0.1’, pybytes=‘1.6.1’)

I went to this page of your tutorial - Building a LoRaWAN Nano Gateway to The Things Network :

to produce this Gateway ID from the board by expanding the WiFi MAC address.

I copied this code :

import ubinascii
wl = WLAN()
print("Gateway EUI: {}".format(binascii.hexlify(wl.mac())[:6] + 'fffe' + binascii.hexlify(wl.mac())[6:]))```
and pasted it into the IDE.

I expected to get the Gateway ID, but I got this response:

```Traceback (most recent call last):
File "", line 1, in
TypeError: object with buffer protocol required```

Can you see if anything is not correctly configured, or is there a simple answer to this question?

Hi Malcom,

Glad to see you back on the forum!!

From a quick glance, it looks like you have accidentally popped a ‘u’ at the start of the import statement, which should read - ‘import binascii’.

Unfortuntately TTNv2 is being shutdown late this year, and low channel(less that 8) gateways are being depricated from the list, you can read more about the shutdown here.

I’m not certain that these are definitely TTNv3 compatible but definitely worth checking out:

PS: you can checkout gateways near you on TTN Mapper

I’ve been opting to go down the route of using Peer-Peer or LoRa MAC to get long-range comms at the moment so that might also be worth checking out :smiley:



Thanks Liam,
I double checked it and tried pasting it into the Atom console with or without the “u”
and I get the same error.
I also checked the same code on the Pycom page: LoRaWAN Nano-gateway
and they use the ubinascii version, whereas the Core tutorial uses binascii.
Both give the same error message.
It is puzzling because the board is functioning in other modes.
I’m really stumped. I tried posting the error on the Pycom Github page, but no response
from any user.

Thanks for the other links.

1 Like

Hi Malcom,

Lets try breaking down the print statement to see where the error might be coming from.
Try running the follwing in the REPL:

print( binascii.hexlify(wl.mac())[6:])

From there you can construct the EUI yourself but it would be good to see what the cause is. If I remember I’ll have a look around when I bust out my LoPy again.

1 Like

Liam, I tried both versions, but same result.
I’m interested to hear if you can replicate the problem on your device.
Let me know the results.



Hi Malcom,

I got the same error orignally but this code now works:

import ubinascii
from network import WLAN

wl = WLAN()

print("Gateway EUI: {}".format(binascii.hexlify(wl.mac()[0])[:6] + 'fffe' + binascii.hexlify(wl.mac()[1])[6:]))

It looks like somewhere down the line they might have changed the output from the WLAN.mac() function.
What was happening, was the WLAN.mac() function would output a tuple, one for each STA and AP modes, inside the tuple was a bytes array which is now being selected.

I along with the guys at Core would love to see what you come up with, Lovin LoRa atm!!


Thanks Liam! You’re a champ!
Everyone I’ve asked, including guys at our TechSpace couldn’t figure it out.

At least now I can try and stand up a gateway and do some testing.

I’ve watched Core Electronics grow and become a great resource with very helpful staff and nice tutorials, so thanks to you guys !! And convey that to Graham too.




Hey Malcom,

Cheers! No worries at all!!
If you dont have any luck and will just be doing some local stuff lemme know and we can discuss a P2P setup :smiley:
PS; Here is another one of my fav’s for the RPi: Adafruit LoRa Radio Bonnet with OLED - RFM95W @ 915MHz - RadioFruit Australia

The stuff they do is sooo good ayye! Definitely check out their YouTube and the stuff they make in-house