LoRa Communication between 2 lopys
-
Hi all,
i am trynig to have a comm between 2 lopys using the LoRa.LORA mode.
I used this code :server:
from network import LoRa import socket lora = LoRa(mode=LoRa.LORA) s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) mydata = s.recv(64) print(mydata)
client:
from network import LoRa import socket lora = LoRa(mode=LoRa.LORA) s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) s.send(b'0123456789')
nothing happens...
I dont see anything transiting.
What am i doing wrong ?Thx
François
-
Thanks to Roberto, problem is solved.
Seems to be a pbm my boot.pyBad one :
import os from machine import UART uart = UART(0, 115200) os.dupterm(uart)
Good one :
import machine import os import time uart = machine.UART(0, 115200) os.dupterm(uart)
-
Thanks !
I tried this but doesnt work for me !
Thats why i did something simpler.
-
Hello @fb
here is a nice example on how t ouse 2 LoPys to connect them using LoRa.
https://forum.pycom.io/topic/236/lopy-nano-gatewayHope this helps
Best,
Roberto
-
My configuration :
import os; [os.uname().sysname, os.uname().machine, os.uname().release] ['LoPy', 'LoPy with ESP32', '0.9.5.b1']
-
Thx for your answer.
So i did that :Client :
from network import LoRa import socket import time lora = LoRa(mode=LoRa.LORA) s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) s.setblocking(False) while(True): s.send(b'0123456789') time.sleep(2)
Server :
from network import LoRa import socket lora = LoRa(mode=LoRa.LORA) s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) s.setblocking(False) while(True): mydata = s.recv(64) if (len(mydata)>2): print(mydata)
Stil nothing is printed.
And my REPL is out because it seems overloaded. Is it normal ?François
-
Hi
I think its because you only listen once. you need to get the server constantly listening.
While (true):
mydata = s.recv(64)
print(mydata)Then send the packet again.
Also not all packets make it to the server so posibly loop the "send as" as well with a:
time.sleep(2)
at the end of the loop.
James