Alex's Corner - Week 3 - LoPy LoRaWAN Nano-Gateway & TTN

  • @jmarcelino i had missed that change.

    I have now changed the freq: and added the remove channel loop.

    But still getting Not joined yet.

    I tried changing s.setsockopt(socket.SOL_LORA, socket.SO_DR, 4) value, without any luck.

    Here are my files...
    Node - main py
    NanoGateway nanogateway py
    NanoGateway config py

  • @palmy-nz
    Did you change your line 41 as in that thread I linked?

    Where it says "freq": 868.1 should be "freq": 915.1

    Then in your remove all 3 lora.add_channel() lines and replace with

    for channel in range(0, 72):
    lora.add_channel(0, frequency=915100000, dr_min=0, dr_max=4)

    This is necessary for 915Mhz regions

  • @bucknall I do, but device status still 'never seen'.

    My device eui, app eui, and app key all match node (from

    Not sure about the application handler, currently set to ttn-handler-us-west? no au (aussie) option

    Where could I be looking?

  • @palmy-nz looks fine :) - have you set up an application on the TTN yet?

  • Thanks @jmarcelino @bucknall

    Changing the dr_max from 5 to 4 (for 915mhz) did fix this ValueError.

    Now I am just getting Not joined yet

    My gateway looks like this

    GATEWAY_ID = '70b3d54990c648be'
    SERVER = ''
    PORT = 1700
    NTP = ""
    NTP_PERIOD_S = 3600
    WIFI_SSID = '***'
    WIFI_PASS = '***'
    LORA_FREQUENCY = 915100000
    LORA_DR = "SF7BW125"   # DR_5

    Anything glaringly obvious?

  • Hi @palmy-nz please try the settings that @jmarcelino suggested and let me know how you get on. If this fails, I have another idea of what might have been the issue!

    Data acquisition is definitely an interesting topic! I'll make sure it's on the list for Alex's Corner!



  • @palmy-nz
    For the 915Mhz region the dr_max parameter (LoRa datarate setting) has to be 4 and not 5.

    You'll also need to change the nano gateway script to match the frequencies and channel, please see this thread

  • Hi Alex, thanks for these videos.

    I managed to get the nano-gateway working, using the Packet Forwarder protocol and finding out my Device EUI with these commands

    import network
    import binascii

    However, I could not get the node working with the example. I am getting this error:

    ValueError: invalid argument(s) value

    On this line

    lora.add_channel(0, frequency=915100000, dr_min=0, dr_max=5)

    Note I am on the 915 frequency (New Zealand). Has to be something to do with that aye?

    Any advice appreciated.

    Ps. I would love to see in an upcoming video how to pull data from sensors, and also push to nodes e.g. trigger led/servo.

  • I've gotten around to pushing up the LoPy LoRaWAN Nano-Gateway Tutorial!

    Check it out here -

  • @Peter-Lans
    TTN is saying the gateway "not connected" and other issues should be fixed early next week.

  • Thank you Alex and all the people here on the forum.
    Thanks to all the information provided here I managed to connect my Lopy as nano gateway to TTN. The frontpage detected it although my console tells me it is not connected. I guess that will be fixed at some point in time too.
    But the data is coming through from de OTAA node, so I guess it works. It has to, because my Lopy is the only gateway around.

    As I am completely new to lora, micropython and microprocessor programming, it is an exiting journey for me. But from here, I do have a great starting point to move on.

    Kind regards,
    Peter Lans

  • @daniel said in New firmware release 1.6.7.b1 (LoRaWAN Nano Gateway with TTN example!!):

    @rskoniec I'm also seeing those and I'm investigating the cause together with Espressif.

    @rskoniec said in New firmware release 1.6.7.b1 (LoRaWAN Nano Gateway with TTN example!!):

    Sometimes I see series of W (xxxxxxxxx) wifi: post pm rx bcn failed messages on my LoRaWAN Nano Gateway:

    Push ack
    Push ack
    Push ack
    W (147750288) wifi: post pm rx bcn failed
    W (147750288) wifi: post pm rx bcn failed
    Pull ack
    Pull ack
    Pull ack

    With the newest f/w 1.6.10.b1 I'm still seeing these messages. @daniel Any news from Espressif?

  • I combined a couple of my tests / results of this weekend in another blog post titled "LoRaWAN + The Things Network = Still some love left". Which shows that this weekend was better than last week when I wrote "LoRaWAN + The Things Network = Tough Love or No Love ?" ;-)

  • @PiAir
    Hi Pierre,
    Thanks for your replies. I appreciate it a lot.
    Who could have guessed that the ttn network / router was down?
    Waited until today, have the same config as you described and guess what?
    Today everything works. I'm happy, because now I have a gateway I can connect to without having to leave my house :-)
    Thanks again.

  • BTW, I just noticed that the LoPy Nano Gateway and node support downlink information....nice. :)
    (now I just have to add some code on the client to actually do something with it and a payload function to do the encoding on the TTN side, see if only the TTN backbone works then testing is much more interesting).

    pfff....until I get another upvote I am only allowed one post per 600 seconds...

    While I was waiting to post, I had another look at the code in the examples folder:

    for i in range (200):
    s.send(b'PKT #' + bytes([i]))
    rx = s.recv(256)
    if rx:

    It might be worthwhile to explain somewhere that this node example script sends 200 packages and then stops.
    Now, resetting will restart the node, but because the devices on TTN by default do "Frame Counter Checks", the backend will ignore the packages after the reset because the node will start at 1 again and the backend will see them as duplicates.
    You can reset the frames counter for the device to fix this.

  • @gerkez It looks like the TTN backend is up again, so you should be able to get the LoPy Nano Gateway + the LoPy node working at the moment.


  • @gerkez Currently my LoPy shows the same error without changing anything since this morning.
    There are reports on the TTN network about the EU-router currently being down:
    (or at least reports of people not being able to connect), so better wait until tomorrow.

    You should go for
    Protocol: packet forwarder
    Gateway EUI: should be the same as in the
    Description: think of something
    Frequency Plan: Europe (if you are in Europe)
    Location: pick your own house on the map
    Antenna placement: indoors

    After you create the gateway, in Settings there is also the option "Router" where at first nothing is selected, you can specifically set that to ttn-router-eu but AFAIK that doesn't matter.

    For now, nothing to play / experiment with as long as the gateways are (apparently) down.

  • @PiAir


    I'm in exactly the same situation, latest firmware and so on.
    After watching the video, I set up my lopy to act as a nano gateway and thanks to your post, I created a packet forwarder gateway at TTN in stead of the gateway connector. I actually tried both of them.
    No success.
    At this moment I have a packet forwarder gateway, but I'm wondering whether I should choose a router.
    In the video, Alex doesn't choose a router when he adds the gateway, but later on you see the "" on the pre configured gateway. I wonder where that one comes from.
    I know it's the same one as in the file, but should I enter this one while adding the gateway at TTN or not?
    It looks like the script is running; I get the push ack's and pull ack's, but no connection with TTN
    At the TTN console, I get messages like: "could not subscribe to gateway status. NOC connection timed out" and "Status not connected".

    Is this going to work?
    I really need a gateway, because there isn't one in my vicinity.

  • @bucknall Hi Alex,

    Thanks, that would be much appreciated. I understand that stuff related to the TTN backend is out of your control but anything that can make it more clear were the problem lies would be great!



  • Hi @PiAir, I completely understand your frustration.

    I was actually having concerns about calling off the demo as TTN was throwing some strange errors relating to viewing the gateway traffic. I believe they're making some changes as to how packet forwarding is working and that the gateway traffic feature is still under heavy development.

    Looking back over the video, I see where the error was coming from; I'd accidentally selected Gateway Connector, under the protocol -

    0_1490948082059_Screen Shot 2017-03-31 at 09.14.07.png

    It should be Packet Forwarder and this was producing errors with the manner in which the nano-gateway connected to TTN.


    What I will aim to do is to tidy up the example we have on the documentation and produce a step by step (with screenshots) as to how you can set up your nano-gateway.

    I'll also modify Daniel's code to add a debug output that will hopefully make it easier to troubleshoot on the nano-gateway's side.

    Apologies for the issues you've been running into, hopefully we can get them fixed shortly!




Pycom on Twitter