lopy4 connecting to a relay (class c)
-
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 ?
-
@abhishek2101 any help would be much appreciated.
-
@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 -
@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.
-
@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)
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