Тестирование радиомодемов LoRa/LoRaWAN RN2483. Часть 1, LoRa

“ ” — LoRa/LoRaWAN, . , “”, .



LoRa?


(Long Range) , Semtech, SX1272 and SX1276. LoRa , , LoRaWAN.

LoRa — . , 10, . , 433 868 (EU-) 915 (USA-).

? .

RN2483. , . RN2483 SX1276 , UART, (, Arduino, , etc). , , , eBay .

USB, .


Python:
import serial
from time import sleep

def deviceSend(device, cmd):
        try:
	  print cmd
          device.write(cmd + "\r\n")
          line = device.readline()
          if line is not None and len(line) > 0: 
            r = line.decode('utf-8').strip()
            print "> " +r        
            return
        except Exception as e:
	  pass

if __name__ == "__main__":
  port = serial.Serial(port="COM20", baudrate=57600, timeout=5)
  deviceSend(port, "sys reset")
  sleep(2)
  deviceSend(port, "mac pause")
  deviceSend(port, "radio set freq 868000000")
  # Output power, -3..15
  deviceSend(port, "radio set pwr -3")
  deviceSend(port, "radio set mod lora")
  # sf12, sf7  
  deviceSend(port, "radio set sf sf7")
  # Bandwidth: with 125KHz the sensitivity is better but time on air is longer. Chip is capable from 125KHz to 500KHz.
  deviceSend(port, "radio set bw 125")
  deviceSend(port, "radio tx 0123456789")
  sleep(0.5)                             
  line = port.readline()
  print line.strip()
  deviceSend(port, "mac resume")


.
pwr — , -3..15dB
frequency
mac pause — lorawan, (p2p)
tx
mod — . 2 , lora fsk.
bw — , 125, 250, 500.
sf — spread factor, .
sf7 sf12 .


, . 255 , .


对于接收,必须设置与传输相同的参数,否则调制解调器将不会彼此“听到”声音。下面给出了代码,该程序在一个无限循环中“侦听”串行端口上的数据。

源代码
import serial
from time import sleep

def deviceSend(device, cmd):
        try:
	  print cmd
          device.write(cmd + "\r\n")
          line = device.readline()
          if line is not None and len(line) > 0: 
            r = line.decode('utf-8').strip()
            print "> " +r        
            return r
        except Exception as e:
	  pass
        return ""

if __name__ == "__main__":
  port = serial.Serial(port="COM20", baudrate=57600, timeout=5)
  deviceSend(port, "sys reset")
  sleep(2)
  deviceSend(port, "mac pause")
  deviceSend(port, "radio set freq 868000000")
  # Output power, -3..15dB
  deviceSend(port, "radio set pwr -3")
  deviceSend(port, "radio set mod lora")
  # sf12, sf7  
  deviceSend(port, "radio set sf sf7")
  # Bandwidth: with 125KHz the sensitivity is better but time on air is longer. Chip is capable from 125KHz to 500KHz.
  deviceSend(port, "radio set bw 125")
  # WDT: 5s wait for each data
  deviceSend(port, "radio set wdt 5000")

  print "Start listening"
  try:
     while True:
       ans = deviceSend(port, "radio rx 0")
       if ans == "ok":
         r = port.readline().strip()
         if r != "err" and len(r) > 0:
           print "> " + r
	 # We need time to prepare RN2483 for the next receiving
         sleep(0.1)

  except KeyboardInterrupt:
     pass

  deviceSend(port, "mac resume")


, , - serial port. ( ) Raspberry Pi, .


RN2483 , PDF «RN2903 LoRa Technology Module Command Reference User’s Guide». Semtech Lora Calculator, ( , ) — , , .

, SX1276 1000 30 8 100 10dBm.

, Raspberry Pi . 3. , : , 868, 3 . , « », . , 3 , 300. , .


LoRa . 2 rn2483 eBay 80EUR. SX1276 12$ . SX1276 - 9$ ( RN2483, SX1276, ).


LoRa ( -) . LoRa , ( ). , , LoRa — , . — , , , . , «» . , , . «» LoraWAN, . , , .

RN2483 LoRaWAN.

:
— RN2483 datasheet
ww1.microchip.com/downloads/en/DeviceDoc/40001784B.pdf
— LoRa FAQ
www.link-labs.com/lora-faqs
— Semtech SX1272
www.semtech.com/wireless-rf/rf-transceivers/sx1272
— Semtech LoRa Calculator
www.semtech.com/apps/filedown/down.php?file=SX1272LoRaCalculatorSetup1%271.zip

RN2483 Raspberry Pi Arduino github.

Source: https://habr.com/ru/post/zh-CN398229/


All Articles