当前位置: 首页 > news >正文

modbus slave 设备通过 网关thingsboard-gateway 将数据上传到thingsboard云平台

   搭建thingsboard物联网云平台花了大量时间,从小白到最后搭建成功,折磨了好几天,也感谢网友的帮助,提供了思路最终成功搞定,特此记录。

 一、thingsboard环境搭建(Ubuntu20.04LTS)

        参考官方文档,按部就班操作即可

        http://www.ithingsboard.com/docs/user-guide/install/ubuntu/

      

二、thingsboard-gateway环境搭建

      也是参考官方文档,直接安装

      Step 1. Download the deb file

wget https://github.com/thingsboard/thingsboard-gateway/releases/latest/download/python3-thingsboard-gateway.deb

Step 2. Install the gateway using apt

Install ThingsBoard IoT Gateway as package and run it as daemon use the following command:
 

sudo apt install ./python3-thingsboard-gateway.deb -y

The deb package will automatically install the necessary libraries for the IOT Gateway to work:

  1. System libraries: libffi-dev, libglib2.0-dev, libxml2-dev, libxslt-dev, libssl-dev, zlib1g-dev, python3-dev, python3-pip.
  2. Python modules: importlib, importlib-metadata, jsonschema, pymodbus, lxml, jsonpath-rw, paho-mqtt, pyserial, PyYAML, simplejson, pyrsistent.

Step 3. Check gateway status

systemctl status thingsboard-gateway

修改配置文件:/etc/thingsboard-gateway/config/tb_gateway.json

{"thingsboard": {"host": "127.0.0.1","port": 1883,"remoteShell": false,"remoteConfiguration": true,"statistics": {"enable": true,"statsSendPeriodInSeconds": 3600,"configuration": null},"deviceFiltering": {"enable": false,"filterFile": "list.json"},"maxPayloadSizeBytes": 1024,"minPackSendDelayMS": 200,"minPackSizeToSend": 500,"checkConnectorsConfigurationInSeconds": 60,"handleDeviceRenaming": true,"security": {"type": "accessToken","accessToken": "ke6h88w6f0fssjaq4s9e"},"qos": 1,"checkingDeviceActivity": {"checkDeviceInactivity": false,"inactivityTimeoutSeconds": 200,"inactivityCheckPeriodSeconds": 500},"ts": 1721138363329},"storage": {"type": "memory","read_records_count": 100,"max_records_count": 100000,"data_folder_path": "./data/","max_file_count": 10,"max_read_records_count": 10,"max_records_per_file": 10000,"data_file_path": "./data/data.db","messages_ttl_check_in_hours": 1,"messages_ttl_in_days": 7,"ts": 1721138363329},"grpc": {"enabled": false,"serverPort": 9595,"keepaliveTimeMs": 10000,"keepaliveTimeoutMs": 5000,"keepalivePermitWithoutCalls": true,"maxPingsWithoutData": 0,"minTimeBetweenPingsMs": 10000,"minPingIntervalWithoutDataMs": 5000,"keepAliveTimeMs": 10000,"keepAliveTimeoutMs": 5000},"connectors": [{"type": "modbus","name": "MODBUS CONNECT","configuration": "modbus_serial.json"}]
}

 mqtt_modbus.json配置

{"master": {"slaves": [{"type": "serial","method": "rtu","port": "/dev/ttyS1","baudrate": 9600,"timeout": 35,"stopbits": 1,"bytesize": 8,"byteOrder": "BIG","wordOrder": "BIG","retries": true,"retryOnEmpty": true,"retryOnInvalid": true,"pollPeriod": 5000,"unitId": 1,"deviceName": "Modbus Temperature Sensor","sendDataOnlyOnChange": false,"connectAttemptTimeMs": 5000,"connectAttemptCount": 5,"waitAfterFailedAttemptsMs": 300000,"attributes": [{"tag": "16int","type": "16int","functionCode": 4,"objectsCount": 2,"address": 3}],"timeseries": [{"tag": "temperature","type": "16uint","functionCode": 4,"objectsCount": 1,"address": 1},{"tag": "humidity","type": "16uint","functionCode": 4,"objectsCount": 1,"address": 2}],"attributeUpdates": [{"tag": "shared_attribute_write","type": "32int","functionCode": 6,"objectsCount": 2,"address": 29}],"rpc": [{"tag": "setValue","type": "16int","functionCode": 6,"objectsCount": 1,"address": 1},{"tag": "getValue","type": "16int","functionCode": 3,"objectsCount": 1,"address": 2}]}]},"id": "19c7e3fa-bfd8-4edb-9590-1fd570902b35"
}

三、modbus slave配置

在命令行重启网关:

sudo  systemctl restart thingsboard-gateway.service

云平台就会出现Modbus Temperature Sensor这个设备

四、新建调试界面,对设备进行调试

终于通信成功!!!!!

http://www.lryc.cn/news/402043.html

相关文章:

  • 安全防御:智能选路
  • Gitee使用教程2-克隆仓库(下载项目)并推送更新项目
  • Postfix+Dovecot+Roundcube开源邮件系统搭建系列1-2:系统搭建目标+MariaDB数据库配置(MySQL)
  • Flower花所比特币交易及交易费用科普
  • 1个Xpath定位可以在Web页面查找到多个元素Selenium
  • 智慧博物馆的“眼睛”:视频智能监控技术守护文物安全与智能化管理
  • vue中:class、watch、v-show使用
  • 中电金信-杭州工商银行|面试真题|2024年
  • 搞定前端面试题——ES6同步与异步机制、async/await的使用以及Promise的使用!!!
  • Redis数据结构--跳跃表 Skip List
  • 线状激光模组定制厂家哪家好?具体怎么收费?
  • 【Python游戏】编程开发贪吃蛇游戏(第一期)
  • 【机器学习入门】拥抱人工智能,从机器学习开始
  • 【React打卡学习第一天】
  • matlab PID tuner整定工具箱的用法
  • 富格林:可信办法阻挠虚假受骗
  • OPPO 2024届校招正式批笔试题-后端(C卷)
  • HTTP请求五类状态码详细介绍,以及部分处理思路
  • Log4j的原理及应用详解(三)
  • 【深度学习】PyTorch框架(4):初始网络、残差网络 和密集连接网络
  • 【关于PHP性能优化,内存优化,日志工具等问题处理】
  • R-CNN、Fast R-CNN和Faster R-CNN:目标检测的进化之路
  • Yolov8网络结构学习
  • 5.5 软件工程-系统测试
  • 网络故障处理及分析工具:Wireshark和Tcpdump集成
  • UDP客户端、服务端及简易聊天室实现 —— Java
  • 下载安装nodejs npm jarn笔记
  • Calibration相机内参数标定
  • MySQL源码安装
  • gtest单元测试:进程冻结与恢复管理模块的单元测试实现