有谁读取过sx1278中文资料的RSSI信号强度值

LoRa物联网技术实战
在众多软件高手云集的2017年开源人年会(COSCUP)上,有一群年轻人看起来格外不同,晒得通红的健康黝黑肤色,在软件工程师中格外亮眼,他们不只是软件工程师,更是一群善用开源科技的「作田人」。就连在开源人年会开场,前行政院院长张善政都分享了自己靠开源技术管农田的经验。张善政每逢周末都会到花莲自家农地从事农作,最近找来一位朋友,利用开源软件,用空拍机从高处拍摄农地後,运用影像辨识技术来计算农地上的西...
LoRa技术备受热捧,给低功耗物联网应用带来了很大的发展和创新的空间。ST也与公司合作推出了LoRa解决方案。在现阶段,为使开发者快速地体验和开发基于LoRa的技术,ST公司在其现有产品的基础上,搭建起了一套LoRa网络系统。这些硬件和软件有:P-NUCLEO-LRWAN1开发板、I-CUBE-LRWAN中间件和X-NUCLEO-IKS01A1扩展板。使用这些板子和软件就可以非常容易地创建和配置一个LoRaWAN(TM)的节点。另外,ST还提供了各种产品的NUCLEO开发板和扩展板,可以方便定制各种节点的扩展功能,创建各种可能的产品原型组合。在本文所附的视频中,生动地展示了如何使用这些工具快速搭建一个基于STM32的LoRaWAN(TM)节点。下面将视频中的部分内容,摘录文字如下:LoRa要点LoRa是一种无线技术,用于创建M2M和物联网应用所需要的低功耗广域网(LPWAN)。低功耗(10-20年电池寿命)、低成本(非常低的基础设施投资)、安全性(AES128加密)长距离(1-10公里)标准化(由主要的行业执行者联盟推动)跟踪( 免费跟踪)STM32和LoRa 10分钟1. 准备– P-NUCLEO-LRWAN1NUCLEO-L073RZ开发板SX1272MB2DAS扩展板天线USB连接线P-NUCLEO-LRWAN1 官方主页:/content/st_com/en/products/wireless-connectivity/lorawan/p-nucleo-lrwan1.html– 计算机KEIL IDEI-CUBE-LRWAN LoRaWAN软件扩展包串口客户端(TeraTerm 或 PuTTY)浏览器– 网关选择基于LoRaWAN的网关,频率可根据地区选择,不同厂家的网关配置不同。本文选择了MULTITECH的“MultiConnect Conduit”网关2. STM32和LoRa板子安装– 确认JP1、JP6跳线短接,JP5设置为EV5– 将SX1271MB2DAS LoRa扩展板插到STM32 Nucleo板子上– 将天线接到LoRa扩展板上3. 安装LoRaWAN软件包– 下载并安装LoRaWAN软件包(可到搜索LoRaWAN)– 下载 I-CUBE-LRWANI-CUBE-LRWAN官方主页地址:/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-expansion-software/i-cube-lrwan.html默认可保持到 “C:\Users\yournam\STM32Cube\Repository\”4. 软件开发– 找到I-CUBE-LRWAN安装包,在下面的应用工程:..\STM32CubeExpansion_LRWAN_V1.0.1\Project\Multi\Applications\LoRa\classA\MDK-ARM\STM32L073RZ-Nucleo\Lora.uvprojx– 打开KEIL工程文件,选择sx1272mb2das目标模块– 在”hw_conf.h”文件中,去掉注释“DEBUG”和”TRACE”.– 在”comissoning.h”文件中,更改EUI设备,在96行。{0x0BE,0x7A,0x00,0x00,0x00,0x00,0x00,0xC8}– 在“main.c”文件中,在249行,设置产生一个测试消息。AppData-&BuffSize=sprintf((char*)AppData-&Buff,”-Hello world. STM32 is LoRaWAN connected”);– 编译并下载工程到目标设备。– 使用TeraTerm从Nucleo板子上获取UART数据。* 选择串口”Serial”,Port: COM8:STMicroelectronics STLink Virtual COM Port (COM8)* Setup& Terminal…& “New line-&Receive: “AUTO”* Setup& Serial port..&Baud rate: 921****00;Data: 7bit5. 网关设置和连接给网关上电,确认用以太网线连接到电脑。打开浏览器,连接网关的默认地址是:192.168.2.1Username: adminPassword: admin选择 Setup&LoRa Network Server, 设置:–Mode:Network Server– Network ID: EUI– EUI: 01-01-01-01-01-01-01-01– Network Key: Key– Key: 0x2B,0X7E, 0x15,0x16,0x28,0xAE,0xD2,0xA6,0xAB,0xF7,0x15,0x88,0x09,0xCF,0x4F,0x3C选择Status & Logs &Statistics&LoRa,检查节点是否连接到网关。如果Nucleo+LoRa设备都打开了,”Refresh Node List”, EUI地址会显示。结果:总结现在你可以做:– 创建自己的基于STM32的LoRa传感器节点– 设置Multi-conduit网关作为一个网关和网络服务器– 建立自己私有的基于STM32的LoRa网络ST的LoRa官方主页:/stm32-lrwan
本文作者twowinter,转载请注明作者1.核心库:libloragw这个目录包含了编译一个多通道基站库所需的源码。编译之后就会生成固定链接的libloragw.a。lora_gateway\libloragw\tst目录下还有不同子模块的测试程序。1.1 HAL介绍这部分也就是LoRa集中器的HAL层(LoRa concentrator Hardware Abstraction Layer),它是个C库,让大家使用少量的C函数就可以对LoRa集中器芯片进行配置硬件,以及收发数据包。LoRa集中器是数字化的多信道多数据包标准的射频芯片,使用LoRa或者FSK模式进行收发数据。1.2 HAL的组成这个库是由6(8)个模块组成:loragw_hal主模块,包含高等级函数来配置和使用集中器loragw_reg这个模块用来操作集中器的寄存器loragw_spi通过SPI接口来操作集中器的寄存器loragw_aux包含一个主机需要的wait_ms函数,用于指定ms的延时loragw_gps通过基准时基来同步集中器内部计数,例如例程中的GPS授时。loragw_radio配置 SX125x 和 SX127x。loragw_fpga (only for SX1301AP2 ref design)SX1301AP2参考设计才需要,用于操作FPGA的寄存器,以及配置FPGA功能。loragw_lbt (only for SX1301AP2 ref design)SX1301AP2参考设计才需要,用于配置和使用LBT功能。1.3 软件编译1.3.1 软件细节这个库按照ANSI C99进行编写。loragw_aux模块中的ms精确延时含有POSIX格式函数,嵌入式平台可以用硬件定时器进行重写。1.3.2 编译选项library.cfg 中 DEBUG_xxx 如果置为1,则会用 fprintf 输出对应的调试信息。1.3.3 编译流程对于交叉编译,需要设置 Makefile 中的 ARCH 和 CROSS_COMPILE 变量,或者在 shell 环境中,使用正确的工具链名字和路径。例如:export PATH=/home/foo/rpi-toolchain/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:$PATH export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabihf-libloragw目录下的Makefile会解析 library.cfg 文件,产生一个config.h的C头文件,包含 #define 选项。那些选项会使能或禁用loragw_xxx.h 文件和 *.c 原文件中的代码。library.cfg 也用来直接选择动态链接库。1.3.4 导出如果想在其他系统使用编译后的库,你需要导出这些文件:libloragw/library.cfg -& 根配置文件libloragw/libloragw.a -& 静态库libloragw/readme.md -& license要求libloragw/inc/config.h -& 从 library.cfg 衍生出的C配置标志libloragw/inc/loragw_*.h -& 你需要用到的头文件 (例如. _hal and _gps)在这个库链接到你的应用之后,只有 license 文件要求在程序文件中拷贝和保留。1.4 硬件条件1.4.1 硬件版本loragw_reg 和 loragw_hal 是针对Semtech硬件编写的特殊版本:Semtech SX1301 芯片Semtech SX1257 or SX1255 收发器如果硬件版本和库版本不匹配的话,这个库将无法使用。你可以用 test_loragw_reg 来测试软硬件是否匹配。1.4.2 SPI通信loragw_spi 的SPI函数适合平台相关的,如果你用别的SPI接口可能需要重写这个函数:SPI master matched to the Linux SPI device driver (provided)SPI over USB using FTDI components (not provided)native SPI using a microcontroller peripheral (not provided)你可以用 test_loragw_spi 来测试SPI通信。1.4.3 GPS接收为了使用库中的GPS模块,主机必须要通过串口连接GPS接收器,串口连接必须以“tty”设备出现在 /dev/ 目录,启用这个程序的用户必须用读写这个设备的权限。使用 chmod a+rw 来允许所有用户能操作指定的tty设备,或者使用sudo来运行你的程序(例如. sudo ./test_loragw_gps)。当前版本,库只从串口读取数据,在GPS接收器上电后会收到他们发出NMEA帧 以及 u-blox 模块私有的 UBX 消息。GPS接收器必须在发出PPS脉冲后发出UBX消息,让内部集中器的时间戳可以用GPS时基校准。如果GPS接收器发出了GGA NMEA语句,gateway则可以进行3D定位。1.5 使用1.5.1 设置软件环境对一个典型应用,你需要这么做:源码中包含 loragw_hal.h编译时链接 libloragw.a 静态库文件由于 loragw_aux 的依赖关系,需要链接 librt 库如果应用需要直接访问集中器配置寄存器的话(例如做些高级配置),你还需要这样做:源码中包含 loragw_reg.h1.5.2 使用软件API要在你的应用中使用 HAL,需要遵守如下规则:在射频启动之前需要配置好 radios path 和 IF+modem path只有在调用了 start 函数之后,配置才会传送给硬件只有在 radio 使能,同时IF+modem 使能,以及集中器启动后,才能接收数据包。只有在 radio 使能,以及集中器启动后,才能发送数据包。改变配置之前,必须停止集中器。一个对HAL的典型应用流程图如下:&configure the radios and IF+modems&&start the LoRa concentrator&loop {&fetch packets that were received by the concentrator&&process, store and/or forward received packets&&send packets through the concentrator&}&stop the concentrator&/!\ 注意,lgw_send 在LoRa集中器仍然发包时,或者即使在准备开始发包时,是非阻塞立即返回。当有数据包在发送时,将无法收到任何数据。你的应用需要考虑发包的时长,或者在尝试发包前检查下状态(使用 lgw_status)。当前一包未完成时立即发一包,会导致前一包无法发送,或者发送部分(会导致接收端出现CRC错误)。1.5.3 调试模式为了调试程序,可以激活调试信息后( 在 library.cfg 中设置 DEBUG_HAL=1 ),编译 loragw_hal 函数。这样就会输出很多细节信息,包括stderr的错误细节信息。2.帮助程序工程中的这些程序提供了一些示例,应该如何使用HAL库。帮助系统构建者单独测试不同部分。2.1. util_pkt_loggerThis software is used to set up a LoRa concentrator using a JSON configurationfile and then record all the packets received in a log file, indefinitely, untilthe user stops the application.这个软件用来让LoRa集中器使用JSON配置文件,以及记录所有的包于一个log文件,除非用户停止这个应用。2.2. util_spi_stressThis software is used to check the reliability of the link between the hostplatform (on which the program is run) and the LoRa concentrator register filethat is the interface through which all interaction with the LoRa concentratorhappens.这个软件用来检测主CPU与LoRa协调器寄存器文件的连接的稳定性。2.3. util_tx_testThis software is used to send test packets with a LoRa concentrator. The packetscontain little information, on no protocol (ie. MAC address) information butcan be used to assess the functionality of a gateway downlink using othergateways as receivers.这个软件用来做发包测试。包里没有协议信息,但可以用来检测基站下行功能,使用另一台基站来做接收。2.4. util_tx_continuousThis software is used to set LoRa concentrator in Tx continuous mode,for spectral measurement.这个软件用来设置LoRa集中器为持续TX模式,用于频谱测试。2.5. util_spectral_scanThis software is used to scan the spectral band in background, where the LoRa这个软件用来扫描基站工作环境的频段。2.6. util_lbt_testThis software is used to test "Listen-Before-Talk" channels timestamps.这个软件用来测试“Listen-Before-Talk”的信道时间戳。3. 帮助脚本3.1. reset_lgw.shThis script must be launched on IoT Start Kit platform to reset concentratorchip through GPIO, before starting any application using the concentrator.这个脚本仅在 IoT Start Kit 平台上运行,用于在启动任何应用前,通过GPIO复位集中器芯片。End
大多数厂家对LoRa的理解或印象仅仅停留在普遍被宣传的距离远,抗干扰,低功耗,如被洗脑一般,更有甚者,过度神话LoRa,简直无所不能的能解决一切问题,极其容易被忽悠掉坑里,我想应该先吐糟一下。某些厂家使用或者测试LoRa,往往过于肤浅,只关注LoRa能传多远距离、穿几层楼层,甚至在对比不同厂家产品的时候都只以距离为唯一的评判标准,其实LoRa芯片只来源于美国SEMTECH,各家拿到的是一样的芯片S...
IntroductioThis page describes how to build LoRa end-devices. We mostly focus on Arduino platforms ( and describe how to connect and use various LoRa radio module: Libelium LoRa, HopeRF RFM92W/RFM95W...
1. IntroductioThis page describes our low-cosgateway based on a Raspberry PI. The gateway can receive from any LoRa device and is designed to be fully customizable for a targeted application with post-processing features based on high-level languages such as python. Typical post-processing features are to push the received data on various IoT/cloud platforms. Currently, we provide example for DropBoxTM, FirebaseTM, ThingSpeakTM, SensorCloudTM, GroveStreamsTM, FIWARE.The work presented here is part of the EU H2020 WAZIUP project (grant agreement number 16-2019) which objective is to develop low-cost IoT solutions for deployment in sub-saharian African countries. Various applications are considered: water quality monitoring, cattle rustling, logistics and goods transportation. More details will come soon, but right now you can get the presentation of the developped gateway in.There are many advanced and well-integrated LoRa gateways capable of simultaneous reception on several channels and implementing the LoRaWAN specification (see slides). These gateways are based on the SX1301 baseband concentrator. Our LoRa gateway could be qualified as “single connection” as it uses the SX1272, much like an end-device would do. However, in order to increase LoRa transmission robutsness we improve the LoRa transmission with CSMA features (or so-called Listen Before Talk) and add Quality of Service guarantees with regards to radio time limitations. This solution keeps the cost of the gateway low and can satisfy small to medium size deployment scenario for ad-hoc application cases in various private usages, farming, agriculture, infrastructure surveillance, application-specific telemetry systems,… Note that more than 1 gateway can be deployed to serve several channel settings. However, it is probably not adapted, in the current state of development, to large-scale deployment with a large number of end customers from various different organizations with their own and different requirements regarding data management, confidentiality and security.Download:(drop me a mail if you use our development so that we could advertise it)gw_full_latest folder: the latest version of the gateway softwarethe modified SX1272 library (initial version comes from Libelium) with enhanced features: support of SX1276, LBT & CSMA-like, …the arduPi library for RPI1 and RPI2the lora_gateway.cpp code (which compile on both RPI and Arduino)the makefilethe post-processing python scripts: cloud management, encryption, etc.Arduino folderthe modified SX1272 library (initial version comes from Libelium) with enhanced features: support of SX1276, LBT & CSMA-like, …the lora_gateway.ino code (which compile on both RPI and Arduino)an interactive end-device sketchvarious templates for most of Arduino boards (Uno, Mega, Due, Pro Mini, Teensy, etc.). Work out-of-the box with the gateway.a README.md for some installation/compilation instructionsour, explaining our LoRa framework, and especially why we are not LoRaWAN compatibleDownload:for the Raspberry gateway (based on Raspbian Jessie)Supports Raspberry 1B+, RPI2 and RPI3.Get the zipped image, unzip it, install it on an 8GB SD card, seePlug the SD card into your RaspberryConnect a radio module (see below)Power-on the RaspberryThe LoRa gateway starts automatically when RPI is powered onWith an RPI3, the Raspberry will automatically act as a WiFi access point. For RPI 1&2, see instructions on githubUpdate to the latest gateway version:By default, incoming data are uploaded to ourWorks out-of-the-box with the2. Hardware componentsThe gateway is based on a Raspberry PI. RPI 1B+/2B/3B can be used. The LoRa modules comes from (a) Libelium LoRa radio module, (b) HopeRF RFM92W/HopeRF RFM95W (or RFM96W for 433MHz), (c) Modtronix inAir9/inAir9B (or inAir4 for 433MHz), (d) NiceRF LoRa1276. Libelium LoRa and RFM92W use the Semtech SX1272 chip while RFM95W, inAir9/9B and NiceRF LoRa1276 use the SX1276 which is actually more versatile.Figure: supported (tested) radio modulesFigure: Left: Hardware components with a Modtronix inAir9 radio module. Right: RPI GPIO header for RPI 1B (short) and RPI 2B/3B (long)Figure:GPIO header of the RPIUsing Libelium LoraFor the Libelium LoRa module, we directly connected the LoRa module without the connection bridge developed by Libelium to save the extra cost of the connection bridge, by just connecting the required SPI pins (MISO, MOSI, SPI_CLK and SPI_nSSEL), VCC and GND to the corresponding pins on the RPI (CE0 on the RPI for SPI_nSSEL and 3v3 for VCC). Pin out diagrams for the LoRa module in XBee format is shown below. The LoRa module from Libelium is however quite expensive: around 45EUR.Figure: XBee pin-out diagram for the Libelium LoRa moduleWe solder the wires to the pin as shown in the figure below. If the RPI is put in a case for outdoor usage, the radio module could just be fixed with the antenna or an SMA extension cable could be used. At the Raspberry side, you can simply plug the right cable end to the corresponding GPIO pin.Figure: using two 10-pin 2mm female socket to connect the LoRa module that has an XBee format. Right: the module is seen from the back sideFigure: connect the LoRa radio module to the RPI GPIO headerUsing HopeRF RFM92W/RFM95WNow, the HopeRF RFM92W (RFM95W) module is shown below. An adapter is need to have the break-out pins (the RFM92W module is quite small) and most importantly the antenna plug (which is in Female SMA). Note that the latest news from HopeRF indicated that the RFM92W is discontinued because the RFM95W is better. So you probably will have an RFM95W if you buy them now.
Figure: the RFM92W module (left), the RFM92W adapter (middle), the RFM92W and the adapter before soldering, comparison with the Libelium LoRa for size (right)After some delicate soldering, we have the RFM92W module ready to be plugged on our Raspberry like previously: just connect the right cable to the GPIO header or use an additional header for fast insertion/removal of the radio module.
Figure: the RFM92W and the adapter, after soldering (left), ready to be plugged on the Raspberry (middle), the adapter pin-out (right)The RFM92W (or RFM95W) with the adapter costs less than half of the Libelium LoRa (around 15EUR) which makes it quite attractive for our low-cost LoRa gateway. As both use the native SPI communication with the SX1272, the Libelium library can also drive the RFM92W, as explained in next section. See our low-cost gateway based on the RFM92W/95W at the end of the page.Using Modtronix inAir9We also tested with the Modtronix inAir9 which is based on the SX1276. This module has 2 advantages: it costs less than half of the Libelium LoRa (around 15EUR) and can come with the header pins already soldered! The left figure shows the radio module and the right figure shows the pin out.
To connect the inAir to the Raspberry, proceed as previously: just connect the right cable to the GPIO header or use an additional header for fast insertion/removal of the radio module. Our first tests show that the inAir is reliable. Given its low cost and readiness (the RFM92W/RFM95W need some soldering) it is definitely a good choice. Note that there is an inAir9B with +20dBm transmit power but regulation is quite strict on such transmit power usage.Using the LoRa GPS HatTheis also a nice solution based on an RFM95W. Look at thethat explain how to use their shield with our library (see example 4).Important notice for the SX1272 libraryNote that the original Libelium library to drive the LoRa module does not use DIO pins as many other libraries do, so there is no need to connect these pins. You can use other development codes using DIO pins by connecting the required pins that are mostly configured as follows DIO0 (RXdone or TX done), DIO1 (RX timeout) and DIO5 (ready). Of company, you have to check first. Some may also use the RST pin to reset the module.3. Main architectureInitially, the gateway was implemented on an Arduino (MEGA/Due) for test purpose and for having a “direct” transparent radio bridge. We enhanced the gateway code but maintained compatibility with Arduino therefore the main features are available on both platforms. On the RPI, we use the arduPI layer provided by Libelium to run both the SX1272 library and the gateway program. The original SX1272 library has been significantly improved to support also the SX1276, to add CSMA-like capability to increase LoRa efficiency and implement the possibility to dynamically ask for an ACK from the receiver side. This library basically drives the SX1272 through the SPI interface (it then works with no modifications with the HopeRF RFM92W and has some modifications for the SX1276). The most important point to mention is that the original library adds 5 bytes for internal usage as shown is the following figure, taken from the Libelium documentation.dst addr (1 bytesrc addr (1 bytesequence number (1 bytepayload length (1 bytespayload data (variable lengthretry counter (1 byteThe dst addr allows...
前言这是《LoRaWAN102》的译文,即LoRaWAN协议规范 V1.0.2 版本( 2016 年 7 月定稿)。我正在陆续对协议的各个章节进行翻译,具体其他章节的译文,以及译文之外的代码解析,可点此查看帖子。本文作者twowinter,转载请注明作者:翻译开始第17章 持续接收的终端具备Class C 能力的终端,通常应用于供电充足的场景,因此不必精简接收时间。Class C 的终端不能执行 Class B 。Class C 终端会尽可能地使用 RX2 窗口来监听。按照 Class A 的规定,终端是在 RX1 无数据收发才进行 RX2 接收。为了满足这个规定,终端会在上行发送结束和 RX1 接收窗口开启之间,打开一个短暂的 RX2 窗口,一旦 RX1 接收窗口关闭,终端会立即切换到 RX2 接收状态; RX2 接收窗口会程序打开,除非终端需要发送其他消息。注意:没有规定节点必须要告诉服务端它是 Class C 节点。这完全取决于服务端的应用程序,它们可以在 join 流程通过协议交互来获知是否是 Class C 节点。17.1 Class C 的第二接收窗口持续时间Class C 设备执行和 Class A 一样的两个接收窗口,但它们没有关闭 RX2 ,除非他们需要再次发送数据。因此它们几乎可以在任意时间用 RX2 来接收下行消息,包括MAC命令和ACK传输的下行消息。另外在发送结束和 RX1 开启之间还打开了一个短暂的RX2窗口。图13.Class C 终端的接收时隙时序图17.2 Class C 对多播下行的处理和 Class B 类似,Class C 设备也可以接收多播下行帧。多播地址和相关的 NWKSKEY 及 APPSKEY 都需要从应用层获取。Class C 多播下行帧也有相同的限制:不允许携带MAC命令,既不能放在FOpts域中,也不能放在 port 0 的 payload 中,因为多播下行无法像单播帧那样具备相同的鲁棒性。ACK 和 ADRACKReq 位必须要为0。MType 域需要为 Unconfirmed Data Down 类型的数值。FPending 位表明有更多的多播数据要发送。考虑到 Classs C 设备在大部分时间处于接收状态,FPending位不触发终端的任何特殊行为。翻译完

我要回帖

更多关于 sx1278驱动程序 的文章

 

随机推荐