RN2483库
lora-rn2483的Python项目详细描述
用于使用RN2483 Lorawan收发器的Python库和工具
Compatible devices | Build Status |
---|---|
Raspberry Pi 3B+ |
RN2483到Raspberry PI GPIO连接
Pin | RN2483 | to | Pin | Raspberry Pi 3B+ |
---|---|---|---|---|
[7] | UART_RX | -> | [14] | UART_TX0 |
[6] | UART_TX | -> | [15] | UART_RX0 |
如何使用
将库作为模块导入时,导入pyserial并使用指定的串行接口(例如ubuntu中的/dev/ttyusb0)初始化连接。
安装pyserial
:
pip3 install pyserial
安装rn2483
:
git clone https://github.com/alexantoniades/python-RN2483.git
cd python-RN2483
python3 setup.py install
导入并初始化模块
importserialimportrn2483#define serial port and baudrate for rn2583 transceiverPORT="/dev/ttyUSB0"BAUDRATE=57600# Initialize serial connectionuart=serial.Serial(PORT,BAUDRATE)# Initialize transceiverdevice=rn2483(connection=uart,debug=True)# Check if device is initializedprint(device.connection.is_open)# Check hardware euiprint(device.hardware_eui())
配置Lorawan-通过个性化进行身份验证
device.config_abp(nwskey=NetworkSessionKey,appskey=ApplicationSessionKey,devaddr=DeviceAddress)
配置Lorawan-空中身份验证
device.config_otaa(appkey=ApplicationKey,appeui=ApplicationEUI)
发送数据
device.send("Hello World")
关闭连接
device.close_connection()