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

    Set spreading factor

    Scheduled Pinned Locked Moved FiPy
    23 Posts 5 Posters 192 Views 6 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.
    • L Offline
      lloureiro @robert-hh
      last edited by

      @robert-hh Thanks Robert. But i need set it before join :(
      this is only possible after join, right?

      while not lora.has_joined():
          print('No OTAA join yet...sf_11_2.258')
          print(machine.temperature())
          pycom.rgbled(0x110000)
          time.sleep(0.1)
          pycom.rgbled(0x000000)
          time.sleep(2.4)
      
      
      # create a LoRa socket
      pycom.rgbled(0x00FF00)  # Green
      s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
      print('Vamos')
      # set the LoRaWAN data rate
      s.setsockopt(socket.SOL_LORA, socket.SO_DR, 0)
      
      robert-hhR 1 Reply Last reply Reply Quote 0
      • rcolisteteR Offline
        rcolistete @robert-hh
        last edited by

        @robert-hh said in Set spreading factor:

        @lloureiro You can set it via the socket data rate:
        s.setsockopt(socket.SOL_LORA, socket.SO_DR, data_rate)
        data_rate = 5 -> SF7BW125
        data_rate = 0 _> SF12BW125

        Remember :

        • to not enable ADR, so the initial 'data_rate' will be maintained in LoRaWan;
        • data rate codes depend on the LoRaWan region (US915, EU868, etc).

        My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

        1 Reply Last reply Reply Quote 0
        • robert-hhR Offline
          robert-hh @lloureiro
          last edited by

          @lloureiro Reading the spec and forum notes, the data rates for join should be handled automatic. It starts with the highest data rate (lowest sf), and if that fails, the data rate is lowered until eventually a join happens.
          Join always succeeds here, so it is hard test it.

          J B 2 Replies Last reply Reply Quote 0
          • J Offline
            jcaron @robert-hh
            last edited by

            @robert-hh you could probably just set a different address in your join so it won’t be accepted?

            robert-hhR 2 Replies Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @jcaron
              last edited by

              @jcaron obviously yes.

              1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @jcaron
                last edited by robert-hh

                @jcaron The told tale: "If anything else fails, read the instructions" applies here too. I had not respected the optional argument 'dr' argument of the join method. That allows setting the inital data rate for join. If set to 5 (EU868), the device will always use that and repeat the join request every 10 seconds. If set for instance to 1, the device will start with SF11 and repeat that every 100 seconds, but adds a join request at SF7 in between. But the SF11 request will not change.
                I do not know if that is the intended behavior, but at least the initial question is answered.

                Part of the log data below.

                08:35:05 868.14/5 SF11BW125 823.3 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:34:57 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:33:35 868.14/5 SF11BW125 823.3 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:33:27 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:32:06 868.14/5 SF11BW125 823.3 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:30:41 868.14/5 SF12BW125 1482.8 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:29:37 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:29:27 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:29:17 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:29:07 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:28:57 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:28:47 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:28:37 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:28:27 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:28:17 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:28:07 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:27:57 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:27:47 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:27:37 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:26:04 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:25:54 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:25:44 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:25:34 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:25:24 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:25:14 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:25:04 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:24:54 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:24:44 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:24:34 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:22:03 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:21:53 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:21:43 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:21:33 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:21:23 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:21:13 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:21:03 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:20:53 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:20:43 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:20:33 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:20:23 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:20:13 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:20:03 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:19:53 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:19:43 868.14/5 SF7BW125  61.7 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                08:17:26 868.14/5 SF12BW125 1482.8 app eui:70B3D57ED000A30C dev eui:70B3D5499B070000 payload size:23 bytes
                
                L 1 Reply Last reply Reply Quote 0
                • L Offline
                  lloureiro @robert-hh
                  last edited by lloureiro

                  @robert-hh Thank you so much Robert.
                  I still have another question. How can i control the frequency of join request when do lora.join()?
                  Because it seems to much join messages sent :(

                  I only did:

                  lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)
                  

                  1b31cb69-c40d-47d7-92f4-938db2c5ad41-image.png

                  robert-hhR 1 Reply Last reply Reply Quote 0
                  • robert-hhR Offline
                    robert-hh @lloureiro
                    last edited by

                    @lloureiro All the device in the list have different addresses. Do you use so many different devices for testing?
                    Please be aware that you have to register a device at TTN before a join request can succeed.

                    L 1 Reply Last reply Reply Quote 0
                    • L Offline
                      lloureiro @robert-hh
                      last edited by

                      @robert-hh No, it changed when received response from TTN.

                      robert-hhR 1 Reply Last reply Reply Quote 0
                      • robert-hhR Offline
                        robert-hh @lloureiro
                        last edited by

                        @lloureiro So you register with the MAC address of the device. If the server assigns a device address which is used the next time, then the first join should have succeeded. But why do you repeat the join then? Usually a join is needed not very often.

                        L 2 Replies Last reply Reply Quote 0
                        • L Offline
                          lloureiro @robert-hh
                          last edited by

                          @robert-hh Its is done automatically :( lora.has_joined() always returns false. There is a way to see logs messages in FiPy?

                          050020c2-5776-4aae-b4d6-9699378f7726-image.png

                          1 Reply Last reply Reply Quote 0
                          • L Offline
                            lloureiro @robert-hh
                            last edited by

                            @robert-hh It works! I increased SF on join. Thanks a lot for your help

                            f4036faa-78ba-4dc5-ae42-469830f4c16e-image.png

                            1 Reply Last reply Reply Quote 0
                            • B Offline
                              bitvijays @robert-hh
                              last edited by

                              @robert-hh Hope you are doing well and had a good weekend. Thank you for your support.

                              In one of the reply, you mentioned that "the data rates for join should be handled automatic. It starts with the highest data rate (lowest sf), and if that fails, the data rate is lowered until eventually a join happens. Join always succeeds here, so it is hard test it."

                              Is there a way to test this? like debug messages?

                              The scenario being near my house, there are no TTN Gateway, so, i bought a Indoor gateway (which works fine).

                              So, I tested sending data using different spreading factor using s.setsockopt(socket.SOL_LORA, socket.SO_DR, data_rate). When I set it to SF12BW125, the gateway far away was also able to receive the message. I was wondering if there's a way to set SF12 for the join request, so that the far gateway gets my Join request. (avoiding buying of a Indoor gateway) and increasing the reach-ability.

                              Kind regards,
                              bitvijays

                              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
                              • 1 / 2
                              • First post
                                Last post

                              Pycom on Twitter

                              Pycom