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

    lopy4 connecting to a relay (class c)

    Scheduled Pinned Locked Moved LoPy
    lopy
    5 Posts 4 Posters 739 Views 4 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.
    • A Offline
      abhishek2101
      last edited by

      Hi

      is lopy4 a class C device ?

      I am looking to connect a relay and send commands to start AC loads. Can somebody guide me how to do this ?

      A J 2 Replies Last reply Reply Quote 0
      • A Offline
        abhishek2101 @abhishek2101
        last edited by

        @abhishek2101 any help would be much appreciated.

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

          @abhishek2101 There is the parameter device_class in the lora.init() call or the constructor, where you can set the device class. The default is class A, but you can also set device class C.
          See https://docs.pycom.io/firmwareapi/pycom/network/lora

          1 Reply Last reply Reply Quote 0
          • J Offline
            jcaron @abhishek2101
            last edited by

            @abhishek2101 The LoPy4 is supposed to support Class C, though I have never tested this.

            Note that

            • you need the network (LNS and gateways) to support class C devices, which is quite uncommon I believe
            • a class C device needs to be always listening, so no deep sleep or anything like that, it most probably can't run on batteries and needs to be powered all the time.
            1 Reply Last reply Reply Quote 1
            • Charly86C Offline
              Charly86 @abhishek2101
              last edited by Charly86

              @abhishek2101 I've got some Lopy4 acting as a class C, and it works fine (mine are always powered)

              but you need a server capable of sending downlink of course.

              I'm sorry I can't share any code but looks like something

              LoRa(mode=LoRa.LORAWAN, public=True, tx_retries=3, device_class=LoRa.CLASS_C)
              
              while (not lora.has_joined()):
                  time.sleep(0.1)
              
              lsock = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
              lsock.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)
              lsock.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, False)
              lsock.setblocking(False)
                              
              while true:
                    data, port = self.lsock.recvfrom(32)
                    lg = len (data)
                    if lg > 0:
                        print("Downlink Port={:d} Size={:d} Payload={}".format(port, lg, hexlify(data).upper()) )
                    time.sleep(0.1)
              
              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 / 1
              • First post
                Last post

              Pycom on Twitter

              Pycom