设为首页收藏本站
查看: 519|回复: 0

【米尔瑞萨RZ/G2L开发板-创新应用】+ 基于RZ/G2L的lorawan集成网关

[复制链接]

3

主题

1

回帖

47

积分

新手上路

积分
47
wakojosin 发表于 2023-9-6 21:35:38 | 显示全部楼层 |阅读模式
本帖最后由 wakojosin 于 2023-9-6 22:30 编辑

概述
本项目硬件方面是由RZ/G2L开发板作为主板,以及GPML7931-PX作为网关的Lora网络模块组成的。
系统使用的 Ubuntu 20.04.6 LTS (GNU/Linux 5.10.83-cip1-yocto-standard aarch64)。
关于Ubuntu的移植,在另一篇文章中有介绍。
软件方面使用chirpstack及chirpstack-gateway-bridge、sx1302_hal驱动、emqx、postgresql、redis等;

配置与调试
设备树:
关闭CAN,因为需要用到CAN占用的引脚:
  1. &canfd {
  2.         pinctrl-0 = <&canfd1_pins>;
  3.         pinctrl-names = "default";
  4.         status = "disabled";

  5.         channel0 {
  6.                 status = "disabled";
  7.         };

  8.         channel1 {
  9.                 status = "disabled";
  10.         };
  11. };
复制代码
开启I2C2,用于lora模块里温度传感器:
  1. &pinctrl {
  2.     i2c2_pins: i2c2 {
  3.         pinmux = <RZG2L_PORT_PINMUX(3, 0, 2)>, /* SDA */
复制代码
软件配置
postgresql配置:
  1. sudo -u postgres psql

  2. create role chirpstack with login password 'chirpstack';
  3. create database chirpstack with owner chirpstack;
  4. \c chirpstack
  5. create extension pg_trgm;
  6. \q
复制代码
sx1302_hal里修改I2C_DEVICE为/dev/i2c-2:
reset_lgw.sh如下:
  1. SX1302_RESET_PIN=473     # SX1302 reset
  2. SX1302_RESET_PIN_DIR=P44_1

  3. WAIT_GPIO() {
  4.     sleep 0.1
  5. }

  6. init() {
  7.     # setup GPIOs
  8.     echo "$SX1302_RESET_PIN" > /sys/class/gpio/export; WAIT_GPIO

  9.     # set GPIOs as output
  10.     echo "out" > /sys/class/gpio/$SX1302_RESET_PIN_DIR/direction; WAIT_GPIO
  11. }

  12. reset() {
  13.     echo "CoreCell reset through GPIO$SX1302_RESET_PIN..."

  14.     # write output for SX1302 CoreCell power_enable and reset
  15.     echo "1" > /sys/class/gpio/$SX1302_RESET_PIN_DIR/value; WAIT_GPIO
  16.     echo "0" > /sys/class/gpio/$SX1302_RESET_PIN_DIR/value; WAIT_GPIO
  17. }

  18. term() {
  19.     # cleanup all GPIOs
  20.     if [ -d /sys/class/gpio/$SX1302_RESET_PIN_DIR ]
  21.     then
  22.         echo "$SX1302_RESET_PIN" > /sys/class/gpio/unexport; WAIT_GPIO
  23.     fi
  24. }

  25. case "$1" in
  26.     start)
  27.     term # just in case
  28.     init
  29.     reset
  30.     ;;
  31.     stop)
  32.     reset
  33.     term
  34.     ;;
  35.     *)
  36.     echo "Usage: $0 {start|stop}"
  37.     exit 1
  38.     ;;
  39. esac

  40. exit 0
复制代码
global_conf.json如下:

  1. {
  2.     "SX130x_conf": {
  3.         "com_type": "SPI",
复制代码
chirpstack-gateway-bridge配置,修改以下内容:

  1. marshaler="json"
复制代码
chirpstack配置,修改如下:
  1. # Network related configuration.
  2. [network]

  3.   # Network identifier (NetID, 3 bytes) encoded as HEX (e.g. 010203).
  4.   net_id="000000"

  5.   # Enabled regions.
  6.   #
  7.   # Multiple regions can be enabled simultaneously. Each region must match
  8.   # the 'name' parameter of the region configuration in '[[regions]]'.
  9.   enabled_regions=[
  10.     "cn470_0",
  11.   ]

  12. # API interface configuration.
  13. [api]

  14.   # interface:port to bind the API interface to.
  15.   bind="0.0.0.0:28080"
复制代码
region_cn470_0.toml:
  1. # MQTT configuration.
  2.       [regions.gateway.backend.mqtt]

  3.         # Topic prefix.
  4.         #
  5.         # The topic prefix can be used to define the region of the gateway.
  6.         # Note, there is no need to add a trailing '/' to the prefix. The trailing
  7.         # '/' is automatically added to the prefix if it is configured.
  8.         #topic_prefix= "cn470_0"
  9.         event_topic="gateway/+/event/+"
  10.         command_topic="gateway/{{gateway_id}}/command/{{command}}"

  11.         # MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
  12.         server="tcp://localhost:1883"

  13.         # Connect with the given username (optional)
  14.         username=""

  15.         # Connect with the given password (optional)
  16.         password=""
复制代码

调试与展示
启动lora_pkt_fwd


启动chirpstack


登录chirpstack


添加网关,网关ID与lora_pkt_fwd的配置中的ID保持一致


添加应用


添加设备配置,增加了一个名为test的配置信息,region选CN470,mac版本选1.0.2,与设备端保持一致


添加设备,增加了一个名为test的测试设备


设备连接,设备端的日志,通过设备端的日志可以看到设备入网成功,获取到了设备地址:


网关端的设备日志,可以看到网关收到了设备的入网请求,并且分配了设备地址:


发送数据测试:
设备端的日志,可以看到发送数据成功:


网关端的日志,可以看有设备数据上传,包含了设备数据,端口等信息:


软件框图



硬件
硬件框图,通过LoRa网络构建起了一个个域网,用于设备端与网关和云端之间通讯的桥梁。由于LoRa的远距离通讯的特点,可以很好的覆盖家庭、小农场、办公等环境的使用。



实物照片
RZG2L照片.jpg

应用与总结
通过RZ/G2L开发板搭建LoraWAN网关可以方便的实现局域网环境的LoraWAN网络环境的部署,为智慧家居、智慧农业等传感器提供网络支持。
由于官方没有提供ubuntu系统镜像所以只能自己移植,希望尽快能跟进,相对来说还是ubuntu、debian等发行版的系统生态更加完善,做开发部署更加方便。最后是希望以后有微信、QQ等平台的服务交流群,电话和邮箱还是没有交流群来的方便。

展示视频

【【米尔瑞萨RZ/G2L开发板-创新应用】+ 基于RZ/G2L的lorawan集成网关】
https://www.bilibili.com/video/BV1eh4y1K7T9




回复

使用道具 举报

您需要登录后才可以回帖 登录

本版积分规则

Archiver|手机版|小黑屋|米尔科技论坛   

GMT+8, 2024-5-5 22:35 , Processed in 0.254443 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表