Hi All,
I received the two LoRa modules yesterday and have played around with them a little bit. I may try and do some range tests this afternoon sometime.
Both Modules:
https://ibb.co/ncD4cBv
Module on a Pi3 (sending a .pkt):
https://ibb.co/NYRCyxH
Module on a Pi2 (receiving that .pkt):
https://ibb.co/r3gxFwx
I've played around with the example code which was kind of fun, the modules have three buttons on them, with that example code you can press a button to send a message to all nearby LoRa radios.
I modified (bastardized?) that code with code I found elsewhere to take a .pkt file from my board and break it up into chunks and send it over LoRa.
pi@pi3:~ $ ls -l *.pkt
-rw-r--r-- 1 pi pi 4164 Dec 31 08:14 12a64038.pkt
pi@pi3:~ $ ls -lh *.pkt
-rw-r--r-- 1 pi pi 4.1K Dec 31 08:14 12a64038.pkt
pi@pi3:~ $ python3 test_radio.py
Start: Fri 31 Dec 2021 11:25:08 AM EST
Finish: Fri 31 Dec 2021 11:26:34 AM EST
It takes about 86 seconds to send 4.1k to the module right next to it.
With these modules you can have up to 252 bytes in a single transmission (including control data). I tried breaking the .pkt file up into 200 character chunks, but wasn't able to receive the whole file on the other side. Breaking it up into 128 character chunks worked better, but not every time. I seem to have the best luck with 55 character chunks. This is all at close range with the antennas next to each other.
The python code I'm using doesn't have any error correction or even knows if the receiving end is actually listening, but does work to show it can be done:
Sending Side:
[ - cut - ]
CHUNK_SIZE = 55
pkt_file = '12a64038.pkt'
display.text('Sending PKT', 35, 0, 1)
display.show()
os.system('date')
with open(pkt_file, 'rb') as infile:
while True:
chunk = infile.read(CHUNK_SIZE)
if not chunk:
display.fill(0)
display.show()
os.system('date')
break
rfm9x.send(chunk)
time.sleep(1)
Receiving Side:
[ - cut - ]
file = open('trans.pkt', 'wb')
while True:
packet = None
packet = rfm9x.receive()
if packet is None:
display.text('- Waiting for PKT -', 15, 20, 1)
display.show()
else:
file.write(packet)
display.text('Receiving PKT', 15, 20, 1)
display.show()
time.sleep(0.1)
display.fill(0)
display.show()
file.close
Source:
https://lowpowerlab.com/forum/general-topics/transmitting-images-with-raspberry -pi/
If anyone knows of another way of sending files through LoRa please let me know. There's a way of setting up a remote serial port over LoRa that I'm looking into. It'd be neat to try using zmodem or something similar.
Jay
... Dachshunds are really small crocodiles with fur.
--- Mystic BBS v1.12 A47 2021/12/24 (Raspberry Pi/32)
* Origin: Northern Realms (21:3/110)