Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    LoPy Nano-Gateway

    Scheduled Pinned Locked Moved Guides
    62 Posts 27 Posters 50.6k Views 31 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • X Offline
      Xykon administrators
      last edited by

      After quite a bit of trial and error I have managed to get the LoPy to "talk" in P2P mode to a Dragino LoRa/GPS hat (which uses the same SX1272 chip that's in the LoPy.

      For anyone interested I have posted some more details here and have made the source code for the LoPy and Raspberry Pi available on github.

      Christian Ehlers

      A 1 Reply Last reply Reply Quote 4
      • A Offline
        arista @Xykon
        last edited by

        This is extremely exiting, since I have exactly the same hardware! I hope I'll have some time this month to test your code, @Xykon, and make the bits fly.

        1 Reply Last reply Reply Quote 1
        • A Offline
          angel.imaz
          last edited by

          Hello.

          It would be great to get a proper tutorial on how to do a http request from a lora through a nano gateway.

          I backed you in KS because you made a big point of making this possible. It is great to have the device. But really not very user friendly at all. And you are already launching a new one with more radios. Yet you still have not make LoPy work as promised.

          Please help!

          Thank you!

          Angel

          B 1 Reply Last reply Reply Quote 1
          • B Offline
            bioagbob @angel.imaz
            last edited by

            Ditto. What's LoRa without a gateway!? Time for proper documentation on this product feature.

            1 Reply Last reply Reply Quote 0
            • D Offline
              daniel
              last edited by

              @angel-imaz please see my post here:

              https://forum.pycom.io/topic/98/lopy-as-lorawan-basestation/20

              Our team is working on examples and there will be in the docs soon. If you need a HTTP client library, please try this one out: https://github.com/micropython/micropython-lib/tree/master/http.client

              1 Reply Last reply Reply Quote 0
              • O Offline
                Oneillsite
                last edited by

                A good way to test it:
                2 Lopy's with PymakrBoard connected on 2 usb ports
                2 instances of Pymakr

                1 Reply Last reply Reply Quote 0
                • M Offline
                  microman7k
                  last edited by

                  Hi,

                  I test this sample but after about one hour of working i get "ValueError: buffer too small" on nano gateway. Any clues why?

                  Firmware: (sysname='LoPy', nodename='LoPy', release='0.9.7.b1', version='v1.8.6-234-g765f2bc on 2016-12-02', machine='LoPy with ESP32')

                  Best Regards

                  O 1 Reply Last reply Reply Quote 0
                  • O Offline
                    Oneillsite @microman7k
                    last edited by

                    @microman7k Hi, first of all you should update the firmware of your Lopy.

                    M 1 Reply Last reply Reply Quote 0
                    • M Offline
                      microman7k @Oneillsite
                      last edited by

                      @Oneillsite On the latest firmware (1.0.1.b1), results are even worse. After one event i get:

                      execfile('nanogw.py')
                      D: 1 P: b'22.5'
                      E (200196) wifi: error malloc bcn_param

                      Traceback (most recent call last):
                      File "<stdin>", line 1, in <module>
                      File "nanogw.py", line 20, in <module>
                      ValueError: buffer too small

                      O 1 Reply Last reply Reply Quote 0
                      • O Offline
                        Oneillsite @microman7k
                        last edited by

                        @microman7k i can't figure out why the message mention "wifi"...

                        M 1 Reply Last reply Reply Quote 0
                        • B Offline
                          borjam @Roberto
                          last edited by

                          I have been playing with it, actually receiving the packets on a Raspberry Pi with a Dragino Lora+GPS Hat and it works. (The "hat" is based on the SX1276).

                          There is a possibility of making an ugly hack in order to support multiple channels for a gateway. It wouldn´t be a multi channel gateway, but a channel hop capable gateway :)

                          The trick (I'll try next week) is to use the CAD functionality. Given the length of the prefix it may be possible to do something like this:

                          • Set frequency

                          • repeat
                            CAD
                            if CAD_DONE // this means timeout
                            next frequency in list
                            until CAD_DETECTED

                          . receive packet

                          It may be a bit tight, but it should be possible to monitor three frequencies. I'll get back with the results.

                          1 Reply Last reply Reply Quote 0
                          • M Offline
                            microman7k @Oneillsite
                            last edited by

                            @Oneillsite

                            Hi, on latest firmware version (1.2.0.b1) you get "MemoryError: parser could not allocate enough memory"

                            execfile('nanogw.py')
                            Traceback (most recent call last):
                            File "<stdin>", line 1, in <module>
                            File "nanogw.py", line 23
                            MemoryError: parser could not allocate enough memory

                            Pycom, can you please provide working sample with the latest firmware version or is this another bug?

                            L 1 Reply Last reply Reply Quote 0
                            • L Offline
                              lmetcalfe @microman7k
                              last edited by

                              @microman7k
                              I am getting same error.

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                daniel
                                last edited by

                                Hello,

                                We are checking what's happening with this nano-gateway example and we'll get back to you shortly. The memory error can be explained due to the newly added interrupt handler task which is using some of the GC memory and the Bluetooth system also consuming a big chunk. Espressif is due to provide some good memory optimizations to sort this out and give us back several tens of KBs of precious RAM.

                                L 1 Reply Last reply Reply Quote 0
                                • L Offline
                                  lmetcalfe @daniel
                                  last edited by

                                  @daniel
                                  It would be great if the RAM is not consumed if we do not use some modules like BT or Wifi or Lora as many applications may only use one of these radios. In my case I only use Lora.

                                  1 Reply Last reply Reply Quote 0
                                  • I Offline
                                    iber
                                    last edited by

                                    Would it be possible to use SSL on the LoRa with f.e: ssl.wrap_socket to secure it with a self signed certificate?

                                    J 1 Reply Last reply Reply Quote 0
                                    • J Offline
                                      jmarcelino @iber
                                      last edited by

                                      @iber The overhead of SSL (handshake alone can be a few kb) probably makes it a bad candidate considering the duty cycle/time-on-air restrictions of LoRa.

                                      I'd suggest using just an symmetric crypto like AES128 much as LoRaWAN uses.

                                      1 Reply Last reply Reply Quote 2
                                      • T Offline
                                        this.wiederkehr
                                        last edited by

                                        I see, this uses some default settings for lora (frequency, tx_power, bandwidth, sf, preamble, coding_rate). But what are the default values? Is there a way to get the default values programatically?

                                        1 Reply Last reply Reply Quote 0
                                        • D Offline
                                          daniel
                                          last edited by

                                          @this-wiederkehr if you go to the docs: https://docs.pycom.io/pycom_esp32/library/network.LORA.html?highlight=lora#network.lora.init

                                          You can see the default values:

                                          lora.init(mode, *, frequency=868000000, tx_power=14, bandwidth=LoRa.868000000, sf=7, preamble=8, coding_rate=LoRa.CODING_4_5, power_mode=LoRa.ALWAYS_ON, tx_iq=false, rx_iq=false, adr=false, public=true, tx_retries=1)
                                          

                                          Cheers,
                                          Daniel

                                          1 Reply Last reply Reply Quote 0
                                          • R Offline
                                            Roberto
                                            last edited by

                                            Hello @Feiko,
                                            This is an answer to your post here New release New firmware release 1.2.2.b1:
                                            I'm answering in the blog since this will allow us to keep a more organised discussion

                                            Regarding your problem with the NanoGateway code, here are a few remarks from your post:

                                            1. In your code you are sending a message and changing the ID every time you do it, the original code had this Device ID as an ID of the device not as a message Id witch is the way you are using it here. It was meant as a way of identifying 2 or mode LoPys connected to the same gateway. I actually tested this same code with 10 devices some days after the original post.

                                            2. Even with 1 in mind you are just giving the device time.time() + 20 (that is 20ms) to
                                              a. Pack the message
                                              b. Send the message using LoRa
                                              c. 2nd LoPy receive the message using LoRa
                                              d. Message unpack and processing
                                              e. Sending ACK over LoRa

                                              The problem with this approach is that in LoRa packages (specially several byte long ones) can take hundreds of milliseconds to transmit.
                                              Since you are checking almost immediately after you send the message and in a while loop with no delays you get that no ACK received output.
                                              My recommendation would be to
                                              a. Extend the amount of time you are going to way for a message (this might change depending on your application). Lets say 20 seconds for testing
                                              b. make the while(waiting_ack and timeout > time.time()) delay at least 100 ms before checking for messages again

                                            3. Regarding the Ack with wrong device_id: 1 message. A little more of the same as point 2. To illustrate here is a little time span of your problem
                                              a. Message ID 1 is created and send
                                              b. Node waits 20 ms for ack
                                              c. Message arrives at gateway in ms: 25
                                              d. Node already ditched the package as non responding and sends Message ID: 2
                                              e. Node wauts 20 ms for ack on pkg 2
                                              f. Gateway responds to ack pkg 1 in ms 26
                                              g. Node gets to ms 40 and trashes the pack 2 as non responding to ack and sends message ID: 3
                                              g. Message with ack of message 1 arrives at node in ms 48.
                                              h. At this point if (device_id == DEVICE_ID) will check if the ack that jsut arrived (1) matches the current pkg (3). NO. node prints to screen
                                              Ack with wrong device_id

                                              Adding extra time (like in point 2) would fix this issue but it will give you a temporal solution only, since the error will present itself if the message takes more than 20 secs (unprovable). The full solution would require an implementation of a retry message sending process with a message queue of messages that where sent and are waiting for an ACK.
                                              There is a lot of documentation regarding this kind of algorithms out there and it was not implemented in the original NanoGateway post since it escapes the scope of the demonstration code.

                                            4. Regarding the OSError: [Errno 11] EAGAIN i'll check into this but i tried the original code posted in the blog with the new firmware and was not able to reproduce it.

                                            F 1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 1 / 4
                                            • First post
                                              Last post

                                            Pycom on Twitter

                                            Pycom